summaryrefslogtreecommitdiff
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-08-07 15:52:19 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-08-07 15:52:19 -0400
commit9f3a742736cecda5a8778be70faa2f779458839f (patch)
tree500ef3701521e63254dbe82e5c71e7ccff746275 /fs/btrfs/ctree.c
parent8578f0f1fda41f8429a1037022b720275102ca65 (diff)
downloadlwn-9f3a742736cecda5a8778be70faa2f779458839f.tar.gz
lwn-9f3a742736cecda5a8778be70faa2f779458839f.zip
Btrfs: Do snapshot deletion in smaller chunks.
Before, snapshot deletion was a single atomic unit. This caused considerable lock contention and required an unbounded amount of space. Now, the drop_progress field in the root item is used to indicate how far along snapshot deletion is, and to resume where it left off. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 19a30b7c3a28..aa824e2c521f 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -659,9 +659,16 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root
struct buffer_head *b;
struct buffer_head *cow_buf;
struct btrfs_node *c;
+ struct btrfs_root_item *root_item = &root->root_item;
int slot;
int ret;
int level;
+ u8 lowest_level = 0;
+
+ if (btrfs_root_refs(root_item) == 0 && root->ref_cows) {
+ lowest_level = root_item->drop_level;
+ WARN_ON(ins_len || cow);
+ }
WARN_ON(p->nodes[0] != NULL);
WARN_ON(!mutex_is_locked(&root->fs_info->fs_mutex));
@@ -718,6 +725,9 @@ again:
slot = p->slots[level];
BUG_ON(btrfs_header_nritems(&c->header) == 1);
}
+ /* this is only true while dropping a snapshot */
+ if (level == lowest_level)
+ break;
b = read_tree_block(root, btrfs_node_blockptr(c, slot));
} else {
struct btrfs_leaf *l = (struct btrfs_leaf *)c;