Re: [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment

David Sterba <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
On Wed, Jun 24, 2026 at 03:08:01PM +0800, Sun YangKai wrote:
> The comment claims room for "14 chunks with 3 stripes each", which
> was correct when the structs were smaller.  Since then three additions
> grew each entry:
> 
>   commit e17cade25ff8 ("Btrfs: Add chunk uuids and update multi-device back references")
>     added btrfs_chunk.length (+8) and stripe.dev_uuid (+16)
> 
>   commit 321aecc65671 ("Btrfs: Add RAID10 support")
>     added btrfs_chunk.sub_stripes (+2)
> 
> A 3-stripe entry now takes:
> 
>   sizeof(btrfs_disk_key) + btrfs_chunk_item_size(3)
>     = 17 + 80 + 32 * (3 - 1)
>     = 161 bytes
> 
> 2048 / 161 ≈ 12.7, so "14" is no longer achievable.  Update to 12
> and add the explicit calculation so it does not rot again.
> 
> Signed-off-by: Sun YangKai <[email protected]>

Reviewed-by: David Sterba <[email protected]>

> --- a/include/uapi/linux/btrfs_tree.h
> +++ b/include/uapi/linux/btrfs_tree.h
> @@ -504,7 +504,11 @@ struct btrfs_header {
>  
>  /*
>   * This is a very generous portion of the super block, giving us room to
> - * translate 14 chunks with 3 stripes each.
> + * translate 12 chunks with 3 stripes each.
> + *
> + * Each entry takes sizeof(btrfs_disk_key) + btrfs_chunk_item_size(n),
> + * which for a 3-stripe chunk is 17 + 80 + 32 * (3 - 1) = 161 bytes.
> + * 2048 / 161 ≈ 12.7, so at most 12 entries fit.

Nice, thanks.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.