Skip to content

Commit a2f6387

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: convert: prevent data chunks to go beyond device size
[BUG] There is a bug report that kernel is rejecting a converted btrfs that has dev extents beyond device boundary. The involved device extent is at 999627694980, length is 30924800, meanwhile the device is 999658557440. The device is size not aligned to 64K, meanwhile the dev extent is aligned to 64K. [CAUSE] For converted btrfs, the source fs has all its freedom to choose its size, as long as it's aligned to the fs block size. So when adding new converted data block groups we need to do extra alignment, but in make_convert_data_block_groups() we are rounding up the end, which can exceed the device size. [FIX] Instead of rounding up to stripe boundary, rounding it down to prevent going beyond the device boundary. Reported-by: Andieqqq <zeige265975@gmail.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 2b01da5 commit a2f6387

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

convert/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ static int make_convert_data_block_groups(struct btrfs_trans_handle *trans,
948948
u64 cur_backup = cur;
949949

950950
len = min(max_chunk_size,
951-
round_up(cache->start + cache->size,
952-
BTRFS_STRIPE_LEN) - cur);
951+
round_down(cache->start + cache->size,
952+
BTRFS_STRIPE_LEN) - cur);
953953
ret = btrfs_alloc_data_chunk(trans, fs_info, &cur_backup, len);
954954
if (ret < 0)
955955
break;

0 commit comments

Comments
 (0)