]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
btrfs: simplify support block size check
authorQu Wenruo <wqu@suse.com>
Sat, 9 Aug 2025 04:40:48 +0000 (14:10 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 22 Sep 2025 08:54:31 +0000 (10:54 +0200)
commitd728f2e5f8a075756ce60410c1ecb3a0b61f2bf8
tree0e06169e70eebca1ebcae1356104f35e1ede57e9
parent0a6dcd42353b96ab4a74796aed1541591de5890c
btrfs: simplify support block size check

Currently we manually check the block size against 3 different values:

- 4K
- PAGE_SIZE
- MIN_BLOCKSIZE

Those 3 values can match or differ from each other.  This makes it
pretty complex to output the supported block sizes.

Considering we're going to add block size > page size support soon, this
can make the support block size sysfs attribute much harder to
implement.

To make it easier, factor out a helper, btrfs_supported_blocksize() to
do a simple check for the block size.

Then utilize it in the two locations:

- btrfs_validate_super()
  This is very straightforward

- supported_sectorsizes_show()
  Iterate through all valid block sizes, and only output supported ones.

  This is to make future full range block sizes support much easier.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
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/disk-io.c
fs/btrfs/fs.c
fs/btrfs/fs.h
fs/btrfs/sysfs.c