Btrfs: Add a skip_locking parameter to struct path, and make various funcs honor it

Allocations may need to read in block groups from the extent allocation tree,
which will require a tree search and take locks on the extent allocation
tree.  But, those locks might already be held in other places, leading
to deadlocks.

Since the alloc_mutex serializes everything right now, it is safe to
skip the btree locking while caching block groups.  A better fix will be
to either create a recursive lock or find a way to back off existing
locks while caching block groups.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
This commit is contained in:
Chris Mason
2008-06-25 16:01:30 -04:00
parent 168fd7d271
commit 5cd57b2cbb
3 changed files with 25 additions and 14 deletions

View File

@@ -88,6 +88,12 @@ static int cache_block_group(struct btrfs_root *root,
return -ENOMEM;
path->reada = 2;
/*
* we get into deadlocks with paths held by callers of this function.
* since the alloc_mutex is protecting things right now, just
* skip the locking here
*/
path->skip_locking = 1;
first_free = block_group->key.objectid;
key.objectid = block_group->key.objectid;
key.offset = 0;