diff mbox series

[10/11] btrfs: don't split nocow extent_maps in btrfs_extract_ordered_extent

Message ID 20230328051957.1161316-11-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/11] btrfs: add function to create and return an ordered extent | expand

Commit Message

Christoph Hellwig March 28, 2023, 5:19 a.m. UTC
From: Boris Burkov <boris@bur.io>

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.

Signed-off-by: Boris Burkov <boris@bur.io>
[hch: split from a larger patch, wrote a commit log]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Tested-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
 fs/btrfs/inode.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 042018271baa37..a791faabb2ec87 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2622,6 +2622,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);
 }