]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: check for relocation inodes on zoned btrfs in should_nocow
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Wed, 8 Sep 2021 16:19:29 +0000 (01:19 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Oct 2021 17:08:01 +0000 (19:08 +0200)
Prepare for allowing preallocation for relocation inodes.

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>
fs/btrfs/inode.c

index 7d27d6626888f1ca0a370110d5594eba030a682b..9b05af75d91090b8bbe11f6e2452fb1d7e51571f 100644 (file)
@@ -1944,7 +1944,15 @@ int btrfs_run_delalloc_range(struct btrfs_inode *inode, struct page *locked_page
        const bool zoned = btrfs_is_zoned(inode->root->fs_info);
 
        if (should_nocow(inode, start, end)) {
-               ASSERT(!zoned);
+               /*
+                * Normally on a zoned device we're only doing COW writes, but
+                * in case of relocation on a zoned filesystem we have taken
+                * precaution, that we're only writing sequentially. It's safe
+                * to use run_delalloc_nocow() here, like for  regular
+                * preallocated inodes.
+                */
+               ASSERT(!zoned ||
+                      (zoned && btrfs_is_data_reloc_root(inode->root)));
                ret = run_delalloc_nocow(inode, locked_page, start, end,
                                         page_started, nr_written);
        } else if (!inode_can_compress(inode) ||