]> git.hungrycats.org Git - linux/commitdiff
Revert "btrfs: relocation: Fix KASAN reports caused by extended reloc tree lifespan"
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 10 Feb 2020 03:22:45 +0000 (22:22 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Mon, 10 Feb 2020 03:22:45 +0000 (22:22 -0500)
This reverts commit 22e5f140dd4d563a52f50d847f42f18dca9d962d.

fs/btrfs/relocation.c

index acceadee50ce4824cbfd513f12b1b9dfa2b507ca..ab91e544986a923fd893ef3d50f926a06c15a51a 100644 (file)
@@ -517,22 +517,6 @@ static int update_backref_cache(struct btrfs_trans_handle *trans,
        return 1;
 }
 
-/*
- * Check if this subvolume tree has valid reloc(*) tree.
- *
- * *: Reloc tree after swap is considered dead, thus not considered as valid.
- *    This is enough for most callers, as they don't distinguish dead reloc
- *    root from no reloc root.
- *    But should_ignore_root() below is a special case.
- */
-static bool have_reloc_root(struct btrfs_root *root)
-{
-       if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
-               return false;
-       if (!root->reloc_root)
-               return false;
-       return true;
-}
 
 static int should_ignore_root(struct btrfs_root *root)
 {
@@ -541,10 +525,6 @@ static int should_ignore_root(struct btrfs_root *root)
        if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state))
                return 0;
 
-       /* This root has been merged with its reloc tree, we can ignore it */
-       if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
-               return 1;
-
        reloc_root = root->reloc_root;
        if (!reloc_root)
                return 0;
@@ -1498,7 +1478,8 @@ int btrfs_update_reloc_root(struct btrfs_trans_handle *trans,
        struct btrfs_root_item *root_item;
        int ret;
 
-       if (!have_reloc_root(root))
+       if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state) ||
+           !root->reloc_root)
                goto out;
 
        reloc_root = root->reloc_root;
@@ -2221,11 +2202,6 @@ static int clean_dirty_subvols(struct reloc_control *rc)
                                if (ret2 < 0 && !ret)
                                        ret = ret2;
                        }
-                       /*
-                        * Need barrier to ensure clear_bit() only happens after
-                        * root->reloc_root = NULL.
-                        */
-                       smp_mb__before_atomic();
                        clear_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state);
                        btrfs_put_fs_root(root);
                } else {
@@ -4779,7 +4755,7 @@ void btrfs_reloc_pre_snapshot(struct btrfs_pending_snapshot *pending,
        struct btrfs_root *root = pending->root;
        struct reloc_control *rc = root->fs_info->reloc_ctl;
 
-       if (!rc || !have_reloc_root(root))
+       if (!root->reloc_root || !rc)
                return;
 
        if (!rc->merge_reloc_tree)
@@ -4813,7 +4789,7 @@ int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
        struct reloc_control *rc = root->fs_info->reloc_ctl;
        int ret;
 
-       if (!rc || !have_reloc_root(root))
+       if (!root->reloc_root || !rc)
                return 0;
 
        rc = root->fs_info->reloc_ctl;