patch-2.1.130 linux/fs/hfs/binsert.c

Next file: linux/fs/minix/inode.c
Previous file: linux/fs/hfs/ChangeLog
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.129/linux/fs/hfs/binsert.c linux/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 @@
 		/* 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 {

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov