Skip to content

Commit 3c8f242

Browse files
author
Josef Bacik
committed
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: [email protected] Reported-by: Alex Lyakas <[email protected]> Signed-off-by: Josef Bacik <[email protected]>
1 parent b8a33fc commit 3c8f242

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/btrfs/extent-tree.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7552,11 +7552,6 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
75527552
wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
75537553

75547554
while (1) {
7555-
if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
7556-
pr_debug("btrfs: drop snapshot early exit\n");
7557-
err = -EAGAIN;
7558-
goto out_end_trans;
7559-
}
75607555

75617556
ret = walk_down_tree(trans, root, path, wc);
75627557
if (ret < 0) {
@@ -7584,7 +7579,8 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
75847579
}
75857580

75867581
BUG_ON(wc->level == 0);
7587-
if (btrfs_should_end_transaction(trans, tree_root)) {
7582+
if (btrfs_should_end_transaction(trans, tree_root) ||
7583+
(!for_reloc && btrfs_need_cleaner_sleep(root))) {
75887584
ret = btrfs_update_root(trans, tree_root,
75897585
&root->root_key,
75907586
root_item);
@@ -7595,6 +7591,12 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
75957591
}
75967592

75977593
btrfs_end_transaction_throttle(trans, tree_root);
7594+
if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
7595+
pr_debug("btrfs: drop snapshot early exit\n");
7596+
err = -EAGAIN;
7597+
goto out_free;
7598+
}
7599+
75987600
trans = btrfs_start_transaction(tree_root, 0);
75997601
if (IS_ERR(trans)) {
76007602
err = PTR_ERR(trans);

0 commit comments

Comments
 (0)