diff mbox series

[1/3] btrfs-progs: convert: make sure the length of data chunks are also stripe aligned

Message ID 6ce46f8501e65e023b8860f44faf822e3448adb8.1705375819.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: make convert to generate chunks aligned to stripe boundary | expand

Commit Message

Qu Wenruo Jan. 16, 2024, 3:31 a.m. UTC
Although scrub code is updated to handle the unaligned chunk length,
there is also no harm if we can alloc data chunk with both start and
length aligned.

This patch would handle this by rounding up the end bytenr when
allocating data chunks for the conversion.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 convert/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/convert/main.c b/convert/main.c
index c9e50c036f92..77b7c0516ae5 100644
--- a/convert/main.c
+++ b/convert/main.c
@@ -984,7 +984,8 @@  static int make_convert_data_block_groups(struct btrfs_trans_handle *trans,
 			u64 cur_backup = cur;
 
 			len = min(max_chunk_size,
-				  cache->start + cache->size - cur);
+				  round_up(cache->start + cache->size,
+					   BTRFS_STRIPE_LEN) - cur);
 			ret = btrfs_alloc_data_chunk(trans, fs_info, &cur_backup, len);
 			if (ret < 0)
 				break;