[PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment

Sun YangKai <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
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]>
---
 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
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.