Skip to content

Commit be691b5

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: split bios to the fs sector size boundary
Btrfs like other file systems can't really deal with I/O not aligned to it's internal block size (which strangely is called sector size in btrfs, for historical reasons), but the block layer split helper doesn't even know about that. Round down the split boundary so that all I/Os are aligned. Fixes: d5e4377 ("btrfs: split zone append bios in btrfs_submit_bio") CC: [email protected] # 6.12 Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 6c3864e commit be691b5

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

fs/btrfs/bio.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -649,8 +649,14 @@ static u64 btrfs_append_map_length(struct btrfs_bio *bbio, u64 map_length)
649649
map_length = min(map_length, bbio->fs_info->max_zone_append_size);
650650
sector_offset = bio_split_rw_at(&bbio->bio, &bbio->fs_info->limits,
651651
&nr_segs, map_length);
652-
if (sector_offset)
653-
return sector_offset << SECTOR_SHIFT;
652+
if (sector_offset) {
653+
/*
654+
* bio_split_rw_at() could split at a size smaller than our
655+
* sectorsize and thus cause unaligned I/Os. Fix that by
656+
* always rounding down to the nearest boundary.
657+
*/
658+
return ALIGN_DOWN(sector_offset << SECTOR_SHIFT, bbio->fs_info->sectorsize);
659+
}
654660
return map_length;
655661
}
656662

0 commit comments

Comments
 (0)