summaryrefslogtreecommitdiff
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-06-25 16:01:31 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commite7a84565bcdb239caad29ccbe559ef978090ac7e (patch)
treeaaeba005e713cde2030c27451d98847accff116d /fs/btrfs/extent-tree.c
parenta74a4b97b61beede185b4b3ad359d7d378b0d312 (diff)
downloadlwn-e7a84565bcdb239caad29ccbe559ef978090ac7e.tar.gz
lwn-e7a84565bcdb239caad29ccbe559ef978090ac7e.zip
Btrfs: Add btree locking to the tree defragmentation code
The online btree defragger is simplified and rewritten to use standard btree searches instead of a walk up / down mechanism. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 89cc4f611869..a9b3a25a45b7 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2201,6 +2201,7 @@ int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len,
{
mutex_unlock(&root->fs_info->alloc_mutex);
lookup_extent_ref(NULL, root, start, len, refs);
+ cond_resched();
mutex_lock(&root->fs_info->alloc_mutex);
return lookup_extent_ref(NULL, root, start, len, refs);
}
@@ -2280,6 +2281,7 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
next = read_tree_block(root, bytenr, blocksize,
ptr_gen);
+ cond_resched();
mutex_lock(&root->fs_info->alloc_mutex);
/* we've dropped the lock, double check */
@@ -2329,6 +2331,7 @@ out:
*level += 1;
BUG_ON(ret);
mutex_unlock(&root->fs_info->alloc_mutex);
+ cond_resched();
return 0;
}
@@ -2448,6 +2451,10 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
break;
if (wret < 0)
ret = wret;
+ if (trans->transaction->in_commit) {
+ ret = -EAGAIN;
+ break;
+ }
}
for (i = 0; i <= orig_level; i++) {
if (path->nodes[i]) {