From: Sun YangKai <sunk67188@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: Sun YangKai <sunk67188@gmail.com>
Subject: [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment
Date: Wed, 24 Jun 2026 15:08:01 +0800 [thread overview]
Message-ID: <20260624070806.4534-1-sunk67188@gmail.com> (raw)
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
next reply other threads:[~2026-06-24 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-24 7:08 Sun YangKai [this message]
2026-06-24 15:35 ` [PATCH] btrfs: uapi: fix stale BTRFS_SYSTEM_CHUNK_ARRAY_SIZE comment David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260624070806.4534-1-sunk67188@gmail.com \
--to=sunk67188@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.