]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - fs/btrfs/extent-tree.c
btrfs: zoned: add a dedicated data relocation block group
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Thu, 18 Nov 2021 08:58:14 +0000 (17:58 +0900)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:48:41 +0000 (09:48 +0100)
commit763e267236e7efd98cbc4cabe76f5ea3502f2a56
treea411a29fcb43ba582b5662053151d389c03ca2c5
parentb8f762a2b3199e221057e0859a6fad4c447b36e4
btrfs: zoned: add a dedicated data relocation block group

BugLink: https://bugs.launchpad.net/bugs/1951820
commit c2707a25562343511bf9a3a6a636a16a822204eb upstream

Relocation in a zoned filesystem can fail with a transaction abort with
error -22 (EINVAL). This happens because the relocation code assumes that
the extents we relocated the data to have the same size the source extents
had and ensures this by preallocating the extents.

But in a zoned filesystem we currently can't preallocate the extents as
this would break the sequential write required rule. Therefore it can
happen that the writeback process kicks in while we're still adding pages
to a delalloc range and starts writing out dirty pages.

This then creates destination extents that are smaller than the source
extents, triggering the following safety check in get_new_location():

 1034         if (num_bytes != btrfs_file_extent_disk_num_bytes(leaf, fi)) {
 1035                 ret = -EINVAL;
 1036                 goto out;
 1037         }

Temporarily create a dedicated block group for the relocation process, so
no non-relocation data writes can interfere with the relocation writes.

This is needed that we can switch the relocation process on a zoned
filesystem from the REQ_OP_ZONE_APPEND writing we use for data to a scheme
like in a non-zoned filesystem using REQ_OP_WRITE and preallocation.

Fixes: 32430c614844 ("btrfs: zoned: enable relocation on a zoned filesystem")
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>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
fs/btrfs/block-group.c
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c
fs/btrfs/zoned.c
fs/btrfs/zoned.h