Commit 3c8f2422 authored by Josef Bacik's avatar Josef Bacik

Btrfs: update drop progress before stopping snapshot dropping

Alex pointed out a problem and fix that exists in the drop one snapshot at a
time patch.  If we decide we need to exit for whatever reason (umount for
example) we will just exit the snapshot dropping without updating the drop
progress.  So the next time we go to resume we will BUG_ON() because we can't
find the extent we left off at because we never updated it.  This patch fixes
the problem.

Cc: stable@vger.kernel.org
Reported-by: default avatarAlex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent b8a33fc7
...@@ -7552,11 +7552,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -7552,11 +7552,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root); wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
while (1) { while (1) {
if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
pr_debug("btrfs: drop snapshot early exit\n");
err = -EAGAIN;
goto out_end_trans;
}
ret = walk_down_tree(trans, root, path, wc); ret = walk_down_tree(trans, root, path, wc);
if (ret < 0) { if (ret < 0) {
...@@ -7584,7 +7579,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -7584,7 +7579,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
} }
BUG_ON(wc->level == 0); BUG_ON(wc->level == 0);
if (btrfs_should_end_transaction(trans, tree_root)) { if (btrfs_should_end_transaction(trans, tree_root) ||
(!for_reloc && btrfs_need_cleaner_sleep(root))) {
ret = btrfs_update_root(trans, tree_root, ret = btrfs_update_root(trans, tree_root,
&root->root_key, &root->root_key,
root_item); root_item);
...@@ -7595,6 +7591,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root, ...@@ -7595,6 +7591,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
} }
btrfs_end_transaction_throttle(trans, tree_root); btrfs_end_transaction_throttle(trans, tree_root);
if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
pr_debug("btrfs: drop snapshot early exit\n");
err = -EAGAIN;
goto out_free;
}
trans = btrfs_start_transaction(tree_root, 0); trans = btrfs_start_transaction(tree_root, 0);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
err = PTR_ERR(trans); err = PTR_ERR(trans);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment