]> git.hungrycats.org Git - linux/commit
btrfs: make chunk size validation to be simpler
authorQu Wenruo <wqu@suse.com>
Sun, 18 Oct 2026 04:17:02 +0000 (14:47 +1030)
committerDavid Sterba <dsterba@suse.com>
Fri, 30 Oct 2026 20:36:17 +0000 (21:36 +0100)
commit398652054bd45e4cd6499e8df6031016d9c5dcff
treecd7e39c823bf08248100835ea2256618e50bd6aa
parent9065b20db1369c882b790f1fb94faad7ef871028
btrfs: make chunk size validation to be simpler

Commit 6ded22c1bfe6 ("btrfs: reduce div64 calls by limiting the number
of stripes of a chunk to u32") introduced a chunk size limit check, but
it is using a wrong result in the comment:

  U32_MAX << BTRFS_STRIPE_LEN_SHIFT results 256T, not 256G.

Instead of calculating the size limit, using an immediate number
(SZ_256G).

This has the following benefit:

- Still large enough for future expansion
  Although the check is 1024 times more strict, I don't think we will
  allow 256G chunk anytime soon.

  And we have higher chance (10 more bits) to catch a bitflip in the
  high bits.

- Much harder to diverge from the comment
  We don't need to calculate the number anymore.

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