btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment
PATCH 1/1 btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment
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 bytes2048 / 161 ≈ 12.7, so "14" is no longer achievable. Update to 12 and add the explicit calculation so it does not rot again.
--- include/uapi/linux/btrfs_tree.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
include/uapi/linux/btrfs_tree.h +5 -1
@@ -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
Signature · 1 line
2.54.0
Quoted 12 lines · 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:
Quoted 8 lines
sizeof(btrfs_disk_key)+btrfs_chunk_item_size(3)= 17 + 80 + 32 * (3 - 1) = 161 bytes2048 / 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]>
include/uapi/linux/btrfs_tree.h struct btrfs_header { · line 511
Quoted 12 lines
include/uapi/linux/btrfs_tree.h +5
-1@@ -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.