btrfs: zoned: use regular writes for relocation
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Thu, 18 Nov 2021 08:58:16 +0000 (17:58 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Nov 2021 12:44:12 +0000 (13:44 +0100)
commit e6d261e3b1f777b499ce8f535ed44dd1b69278b7 upstream

Now that we have a dedicated block group for relocation, we can use
REQ_OP_WRITE instead of  REQ_OP_ZONE_APPEND for writing out the data on
relocation.

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/zoned.c

index 18ee85e1c9a2465e0f2ee87a8dd79f012af8a459..5672c24a2d58209a47dc95d0f92a527ece9e4711 100644 (file)
@@ -1304,6 +1304,17 @@ bool btrfs_use_zone_append(struct btrfs_inode *inode, u64 start)
        if (!is_data_inode(&inode->vfs_inode))
                return false;
 
+       /*
+        * Using REQ_OP_ZONE_APPNED for relocation can break assumptions on the
+        * extent layout the relocation code has.
+        * Furthermore we have set aside own block-group from which only the
+        * relocation "process" can allocate and make sure only one process at a
+        * time can add pages to an extent that gets relocated, so it's safe to
+        * use regular REQ_OP_WRITE for this special case.
+        */
+       if (btrfs_is_data_reloc_root(inode->root))
+               return false;
+
        cache = btrfs_lookup_block_group(fs_info, start);
        ASSERT(cache);
        if (!cache)