Re: [PATCH] btrfs: do not check support for an invalid sectorsize

From: Qu Wenruo

Date: Mon Nov 02 2026 - 19:09:45 EST




在 2026/11/3 10:36, Siddharth Mishra 写道:
On Mon, Nov 2, 2026 at 4:42 PM Qu Wenruo <wqu@xxxxxxxx> wrote:
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 8e8fb942d..b348591f8 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2520,9 +2520,7 @@ int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
sectorsize > BTRFS_MAX_METADATA_BLOCKSIZE)) {
btrfs_err(fs_info, "invalid sectorsize %u", sectorsize);
ret = -EINVAL;
- }
-
- if (unlikely(!btrfs_supported_blocksize(sectorsize))) {
+ } else if (unlikely(!btrfs_supported_blocksize(sectorsize))) {

If you want to change this, you should touch all callsites.
Not only this one, but every unlikely() branch to return immediately.

I do not like the ad-hoc fix just be cause you can trigger an ASSERT().

Thanks for the response. I'm assuming you mean I change the whole function
to return -EINVAL on the first failure it encounters and not just the sectorsize
because it reached an ASSERT. Given that, I'll send a v2 right away where
any failed check in btrfs_validate_super() returns early rather than
continuing ahead.

Already done

https://lore.kernel.org/linux-btrfs/7350d541824422978116bfb536d2c7bc68cbb826.1793664043.git.wqu@xxxxxxxx/

Siddharth Mishra