From f0f5329a00ba5e9aec012212e3d9d8c2ff8f5cfa Mon Sep 17 00:00:00 2001 From: Boris Burkov Date: Tue, 28 Mar 2023 14:19:56 +0900 Subject: btrfs: don't split NOCOW extent_maps in btrfs_extract_ordered_extent NOCOW writes just overwrite an existing extent map, which thus should not be split in btrfs_extract_ordered_extent. The NOCOW case can't currently happen as btrfs_extract_ordered_extent is only used on zoned devices that do not support NOCOW writes, but this will change soon. Reviewed-by: Josef Bacik Tested-by: Johannes Thumshirn Signed-off-by: Boris Burkov [ hch: split from a larger patch, wrote a commit log ] Signed-off-by: Christoph Hellwig Signed-off-by: David Sterba --- fs/btrfs/inode.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 357d1626df1a..26aeb4f000f5 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -2621,6 +2621,14 @@ int btrfs_extract_ordered_extent(struct btrfs_bio *bbio, ret = btrfs_split_ordered_extent(ordered, len); if (ret) return ret; + + /* + * Don't split the extent_map for NOCOW extents, as we're writing into + * a pre-existing one. + */ + if (test_bit(BTRFS_ORDERED_NOCOW, &ordered->flags)) + return 0; + return split_extent_map(inode, bbio->file_offset, ordered_len, len); } -- cgit v1.2.3