diff mbox series

[v7,20/39] btrfs: limit ordered extent size to max_zone_append_size

Message ID 20200911123259.3782926-21-naohiro.aota@wdc.com (mailing list archive)
State New, archived
Headers show
Series btrfs: zoned block device support | expand

Commit Message

Naohiro Aota Sept. 11, 2020, 12:32 p.m. UTC
With zone append writing, the logical address must be modified to match the
actual written physical address. If multiple bios serve one ordered extent,
the bios can reside in a non-contiguous physical region, resulting in the
non-contiguous logical region. It is troublesome to handle such a case, so
one ordered extent must be served by one bio, limited to
max_zone_apend_size. Thus, this commit limits the size of an ordered extent
as well.

This size limitation results in file extents fragmentation. In the future,
we can merge contiguous ordered extents as an optimization.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
 fs/btrfs/extent_io.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index 63cdf67e6885..c21d1dbe314e 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -1865,6 +1865,7 @@  noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
 				    u64 *end)
 {
 	struct extent_io_tree *tree = &BTRFS_I(inode)->io_tree;
+	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
 	u64 max_bytes = BTRFS_MAX_EXTENT_SIZE;
 	u64 delalloc_start;
 	u64 delalloc_end;
@@ -1873,6 +1874,10 @@  noinline_for_stack bool find_lock_delalloc_range(struct inode *inode,
 	int ret;
 	int loops = 0;
 
+	if (fs_info && fs_info->max_zone_append_size)
+		max_bytes = ALIGN_DOWN(fs_info->max_zone_append_size,
+				       PAGE_SIZE);
+
 again:
 	/* step one, find a bunch of delalloc bytes starting at start */
 	delalloc_start = *start;