]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: add extra ASSERT()s to catch unaligned bios
authorQu Wenruo <wqu@suse.com>
Mon, 15 Sep 2025 09:03:50 +0000 (18:33 +0930)
committerDavid Sterba <dsterba@suse.com>
Tue, 23 Sep 2025 06:49:25 +0000 (08:49 +0200)
commite9bed72e883e7c6e6a2057ea29fcd4ba69225f91
tree478543e16f929c49b6b577b931f5ac7ddca01416
parent67378b754608a3524d125bfa5744508a49fe48be
btrfs: add extra ASSERT()s to catch unaligned bios

Btrfs uses btrfs_bio to handle read/write of logical address, for the
incoming bs > ps support, btrfs has extra requirements:

- One folio must contain at least one fs block
- No fs block can cross folio boundaries

This requirement is not hard to maintain, thanks to the address space's
minimal folio order.

But not all btrfs bios are generated through address space, e.g.
compression and scrub.

To catch possible unaligned bios, introduce a helper,
assert_bbio_alginment(), for each btrfs_bio in btrfs_submit_bbio().

This will check the following things:

- bv_offset is aligned to block size
- bv_len is aligned to block size

With a btrfs bio passing above checks, unless it's empty it will ensure
the requirements for bs > ps support.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/bio.c