]> git.hungrycats.org Git - linux/commitdiff
Revert "Revert "btrfs: reloc: Also queue orphan reloc tree for cleanup to avoid BUG_O...
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 9 Dec 2019 01:43:27 +0000 (20:43 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 9 Dec 2019 01:43:27 +0000 (20:43 -0500)
This reverts commit 94853269656ae5b4564cecbf4458003883d8409e.

fs/btrfs/relocation.c

index efc1f36749d777bc2f728fdc12af7a57d28f34c3..623797cb0b681e5a333a4e634ac93bd49045b7ad 100644 (file)
@@ -2162,22 +2162,30 @@ static int clean_dirty_subvols(struct reloc_control *rc)
        struct btrfs_root *root;
        struct btrfs_root *next;
        int ret = 0;
+       int ret2;
 
        list_for_each_entry_safe(root, next, &rc->dirty_subvol_roots,
                                 reloc_dirty_list) {
-               struct btrfs_root *reloc_root = root->reloc_root;
+               if (root->root_key.objectid != BTRFS_TREE_RELOC_OBJECTID) {
+                       /* Merged subvolume, cleanup its reloc root */
+                       struct btrfs_root *reloc_root = root->reloc_root;
 
-               clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
-               list_del_init(&root->reloc_dirty_list);
-               root->reloc_root = NULL;
-               if (reloc_root) {
-                       int ret2;
+                       clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
+                       list_del_init(&root->reloc_dirty_list);
+                       root->reloc_root = NULL;
+                       if (reloc_root) {
 
-                       ret2 = btrfs_drop_snapshot(reloc_root, NULL, 0, 1);
+                               ret2 = btrfs_drop_snapshot(reloc_root, NULL, 0, 1);
+                               if (ret2 < 0 && !ret)
+                                       ret = ret2;
+                       }
+                       btrfs_put_fs_root(root);
+               } else {
+                       /* Orphan reloc tree, just clean it up */
+                       ret2 = btrfs_drop_snapshot(root, NULL, 0, 1);
                        if (ret2 < 0 && !ret)
                                ret = ret2;
                }
-               btrfs_put_fs_root(root);
        }
        return ret;
 }
@@ -2465,6 +2473,9 @@ again:
                        }
                } else {
                        list_del_init(&reloc_root->root_list);
+                       /* Don't forget to queue this reloc root for cleanup */
+                       list_add_tail(&reloc_root->reloc_dirty_list,
+                                     &rc->dirty_subvol_roots);
                }
        }