btrfs: do not special case the extent root for switch commit roots
authorJosef Bacik <josef@toxicpanda.com>
Fri, 5 Nov 2021 20:45:39 +0000 (16:45 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jan 2022 14:09:48 +0000 (15:09 +0100)
This is a leftover from when we used to independently swap the extent
root's commit root and the fs tree commit roots.  At the time I simply
changed the helper to a list_add.  There's actually no reason to not add
the extent root to the switch commit root at this point, we don't care
about the order we do the switching since it's all done under the
commit_root_sem.

If we re-mark the extent root dirty after adding it to the
switch_commits list we'll see that BTRFS_ROOT_DIRTY isn't set and then
list_move it back onto the dirty list, and then we'll redo the tree
update and everything will be ok.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/transaction.c

index 5b8f71aeccc9d42f3577a48eea266f6548d67237..c9f85c412b23e56e45708a2a127d1cb1bd6d3f28 100644 (file)
@@ -1278,9 +1278,8 @@ again:
                root = list_entry(next, struct btrfs_root, dirty_list);
                clear_bit(BTRFS_ROOT_DIRTY, &root->state);
 
-               if (root != fs_info->extent_root)
-                       list_add_tail(&root->dirty_list,
-                                     &trans->transaction->switch_commits);
+               list_add_tail(&root->dirty_list,
+                             &trans->transaction->switch_commits);
                ret = update_cowonly_root(trans, root);
                if (ret)
                        return ret;
@@ -1310,9 +1309,6 @@ again:
        if (!list_empty(&fs_info->dirty_cowonly_roots))
                goto again;
 
-       list_add_tail(&fs_info->extent_root->dirty_list,
-                     &trans->transaction->switch_commits);
-
        /* Update dev-replace pointer once everything is committed */
        fs_info->dev_replace.committed_cursor_left =
                fs_info->dev_replace.cursor_left_last_write_of_item;