diff options
Diffstat (limited to 'fs/hfs/binsert.c')
-rw-r--r-- | fs/hfs/binsert.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/fs/hfs/binsert.c b/fs/hfs/binsert.c index daab8c22d..0c0c5076a 100644 --- a/fs/hfs/binsert.c +++ b/fs/hfs/binsert.c @@ -17,6 +17,20 @@ /*================ File-local functions ================*/ +/* btree locking functions */ +static inline void hfs_btree_lock(struct hfs_btree *tree) +{ + while (tree->lock) + hfs_sleep_on(&tree->wait); + tree->lock = 1; +} + +static inline void hfs_btree_unlock(struct hfs_btree *tree) +{ + tree->lock = 0; + hfs_wake_up(&tree->wait); +} + /* * binsert_nonfull() * @@ -512,15 +526,11 @@ restart: /* make certain we have enough nodes to proceed */ if ((tree->bthFree - tree->reserved) < reserve) { hfs_brec_relse(&brec, NULL); - while (tree->lock) { - hfs_sleep_on(&tree->wait); - } - tree->lock = 1; + hfs_btree_lock(tree); if ((tree->bthFree - tree->reserved) < reserve) { hfs_btree_extend(tree); } - tree->lock = 0; - hfs_wake_up(&tree->wait); + hfs_btree_unlock(tree); if ((tree->bthFree - tree->reserved) < reserve) { return -ENOSPC; } else { |