From 81f28acda2f27bfd79bc7ed6f8edc8d7ef80b870 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 3 Feb 2025 14:00:27 -0800 Subject: [PATCH] common/populate: correct the parent pointer name creation formulae The formulae used to compute the number of parent pointers that we have to create in a child file in order to generate a particular xattr structure are not even close to correct -- the first one needs a bit of adjustment, but the second one is way off and creates far too many files. Fix the computation, and document where the magic numbers come from. Cc: # v2024.06.27 Fixes: 0c02207d61af9a ("populate: create hardlinks for parent pointers") Signed-off-by: "Darrick J. Wong" Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- common/populate | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/common/populate b/common/populate index 4cf9c069..c907e04e 100644 --- a/common/populate +++ b/common/populate @@ -473,13 +473,18 @@ _scratch_xfs_populate() { __populate_create_dir "${SCRATCH_MNT}/PPTRS" 1 '' \ --hardlink --format "two_%d" - # Create one xattr leaf block of parent pointers - nr="$((blksz * 2 / 16))" + # Create one xattr leaf block of parent pointers. The name is + # 8 bytes and, the handle is 12 bytes, which rounds up to 24 + # bytes per record, plus xattr structure overhead. + nr="$((blksz / 24))" __populate_create_dir "${SCRATCH_MNT}/PPTRS" ${nr} '' \ --hardlink --format "many%04d" - # Create multiple xattr leaf blocks of large parent pointers - nr="$((blksz * 16 / 16))" + # Create multiple xattr leaf blocks of large parent pointers. + # The name is 256 bytes and the handle is 12 bytes, which + # rounds up to 272 bytes per record, plus xattr structure + # overhead. + nr="$((blksz * 2 / 272))" __populate_create_dir "${SCRATCH_MNT}/PPTRS" ${nr} '' \ --hardlink --format "y%0254d" -- 2.39.5