]> Pileus Git - ~andy/linux/commitdiff
Btrfs: Use mutex_lock_nested for tree locking
authorChris Mason <chris.mason@oracle.com>
Tue, 22 Jul 2008 15:18:09 +0000 (11:18 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 25 Sep 2008 15:04:05 +0000 (11:04 -0400)
Lockdep has the notion of locking subclasses so that you can identify
locks you expect to be taken after other locks of the same class.  This
changes the per-extent buffer btree locking routines to use a subclass based
on the level in the tree.

Unfortunately, lockdep can only handle 8 total subclasses, and the btrfs
max level is also 8.  So when lockdep is on, use a lower max level.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/ctree.h
fs/btrfs/locking.c

index f8fccdac305546e3e27a3ca3387f01486b3fbe28..eeb5afa6e9b1c45230227bcb30398d55e7fae93c 100644 (file)
@@ -42,7 +42,11 @@ struct btrfs_ordered_sum;
 
 #define BTRFS_MAGIC "_B5RfS_M"
 
-#define BTRFS_MAX_LEVEL 8
+#ifdef CONFIG_LOCKDEP
+# define BTRFS_MAX_LEVEL 7
+#else
+# define BTRFS_MAX_LEVEL 8
+#endif
 
 /* holds pointers to all of the tree roots */
 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
index 01a9ac2be3f7d2aaf828f493e1e89ea413328e30..27a02376ab14449cc777a471778629909c3d4f83 100644 (file)
@@ -37,7 +37,7 @@ int btrfs_tree_lock(struct extent_buffer *eb)
                        return 0;
        }
        cpu_relax();
-       mutex_lock(&eb->mutex);
+       mutex_lock_nested(&eb->mutex, BTRFS_MAX_LEVEL - btrfs_header_level(eb));
        return 0;
 }