* [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment
@ 2026-06-24 7:08 Sun YangKai
2026-06-24 15:35 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Sun YangKai @ 2026-06-24 7:08 UTC (permalink / raw)
To: linux-btrfs; +Cc: Sun YangKai
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 <sunk67188@gmail.com>
---
include/uapi/linux/btrfs_tree.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index cc3b9f7dccaf..78404abc4ba2 100644
--- 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.
*/
#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment
2026-06-24 7:08 [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment Sun YangKai
@ 2026-06-24 15:35 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2026-06-24 15:35 UTC (permalink / raw)
To: Sun YangKai; +Cc: linux-btrfs
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 <sunk67188@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
> --- 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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-24 15:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-24 7:08 [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment Sun YangKai
2026-06-24 15:35 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox