From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <david@fromorbit.com>, linux-xfs@vger.kernel.org
Subject: [PATCH 22/21] xfs: fix sb_spino_align checks for large fsblock sizes
Date: Tue, 26 Nov 2024 12:26:19 -0800 [thread overview]
Message-ID: <20241126202619.GO9438@frogsfrogsfrogs> (raw)
In-Reply-To: <173258397748.4032920.4159079744952779287.stgit@frogsfrogsfrogs>
From: Darrick J. Wong <djwong@kernel.org>
For a sparse inodes filesystem, mkfs.xfs computes the values of
sb_spino_align and sb_inoalignmt with the following code:
int cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
if (cfg->sb_feat.crcs_enabled)
cluster_size *= cfg->inodesize / XFS_DINODE_MIN_SIZE;
sbp->sb_spino_align = cluster_size >> cfg->blocklog;
sbp->sb_inoalignmt = XFS_INODES_PER_CHUNK *
cfg->inodesize >> cfg->blocklog;
On a V5 filesystem with 64k fsblocks and 512 byte inodes, this results
in cluster_size = 8192 * (512 / 256) = 16384. As a result,
sb_spino_align and sb_inoalignmt are both set to zero. Unfortunately,
this trips the new sb_spino_align check that was just added to
xfs_validate_sb_common, and the mkfs fails:
# mkfs.xfs -f -b size=64k, /dev/sda
meta-data=/dev/sda isize=512 agcount=4, agsize=81136 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=1
= reflink=1 bigtime=1 inobtcount=1 nrext64=1
= exchange=0 metadir=0
data = bsize=65536 blocks=324544, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=65536 ascii-ci=0, ftype=1, parent=0
log =internal log bsize=65536 blocks=5006, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=65536 blocks=0, rtextents=0
= rgcount=0 rgsize=0 extents
Discarding blocks...Sparse inode alignment (0) is invalid.
Metadata corruption detected at 0x560ac5a80bbe, xfs_sb block 0x0/0x200
libxfs_bwrite: write verifier failed on xfs_sb bno 0x0/0x1
mkfs.xfs: Releasing dirty buffer to free list!
found dirty buffer (bulk) on free list!
Sparse inode alignment (0) is invalid.
Metadata corruption detected at 0x560ac5a80bbe, xfs_sb block 0x0/0x200
libxfs_bwrite: write verifier failed on xfs_sb bno 0x0/0x1
mkfs.xfs: writing AG headers failed, err=22
Prior to commit 59e43f5479cce1 this all worked fine, even if "sparse"
inodes are somewhat meaningless when everything fits in a single
fsblock. Adjust the checks to handle existing filesystems.
Fixes: 59e43f5479cce1 ("xfs: sb_spino_align is not verified")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
fs/xfs/libxfs/xfs_sb.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index a809513a290cf4..3b5623611eba02 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -494,12 +494,13 @@ xfs_validate_sb_common(
return -EINVAL;
}
- if (!sbp->sb_spino_align ||
- sbp->sb_spino_align > sbp->sb_inoalignmt ||
- (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0) {
+ if (sbp->sb_spino_align &&
+ (sbp->sb_spino_align > sbp->sb_inoalignmt ||
+ (sbp->sb_inoalignmt % sbp->sb_spino_align) != 0)) {
xfs_warn(mp,
- "Sparse inode alignment (%u) is invalid.",
- sbp->sb_spino_align);
+"Sparse inode alignment (%u) is invalid, must be integer factor of (%u).",
+ sbp->sb_spino_align,
+ sbp->sb_inoalignmt);
return -EINVAL;
}
} else if (sbp->sb_spino_align) {
next prev parent reply other threads:[~2024-11-26 20:26 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-26 1:18 [PATCHBOMB] xfs/fstests: largeish pile of bug fixes Darrick J. Wong
2024-11-26 1:20 ` [PATCHSET v3] fstests: random fixes for v2024.11.17 Darrick J. Wong
2024-11-26 1:20 ` [PATCH 01/16] generic/757: fix various bugs in this test Darrick J. Wong
2024-11-28 7:56 ` Zorro Lang
2024-11-26 1:21 ` [PATCH 02/16] generic/757: convert to thinp Darrick J. Wong
2024-11-28 8:08 ` Zorro Lang
2024-11-26 1:21 ` [PATCH 03/16] xfs/113: fix failure to corrupt the entire directory Darrick J. Wong
2024-11-26 1:21 ` [PATCH 04/16] xfs/508: fix test for 64k blocksize Darrick J. Wong
2024-11-26 1:21 ` [PATCH 05/16] common/rc: capture dmesg when oom kills happen Darrick J. Wong
2024-11-26 1:22 ` [PATCH 06/16] generic/562: handle ENOSPC while cloning gracefully Darrick J. Wong
2024-11-26 4:55 ` Christoph Hellwig
2024-11-26 1:22 ` [PATCH 07/16] xfs/163: skip test if we can't shrink due to enospc issues Darrick J. Wong
2024-11-26 1:22 ` [PATCH 08/16] xfs/009: allow logically contiguous preallocations Darrick J. Wong
2024-11-26 1:22 ` [PATCH 09/16] generic/251: use sentinel files to kill the fstrim loop Darrick J. Wong
2024-11-26 1:23 ` [PATCH 10/16] generic/251: constrain runtime via time/load/soak factors Darrick J. Wong
2024-11-26 1:23 ` [PATCH 11/16] generic/251: don't copy the fsstress source code Darrick J. Wong
2024-11-26 1:23 ` [PATCH 12/16] common/rc: _scratch_mkfs_sized supports extra arguments Darrick J. Wong
2024-11-26 1:23 ` [PATCH 13/16] xfs/157: do not drop necessary mkfs options Darrick J. Wong
2024-11-26 1:24 ` [PATCH 14/16] generic/366: fix directio requirements checking Darrick J. Wong
2024-11-26 1:24 ` [PATCH 15/16] generic/454: actually set attr value for llamapirate subtest Darrick J. Wong
2024-11-26 4:56 ` Christoph Hellwig
2024-11-26 1:24 ` [PATCH 16/16] xfs/122: add tests for commitrange structures Darrick J. Wong
2024-11-26 4:57 ` Christoph Hellwig
2024-11-26 20:27 ` [PATCH 17/16] generic/459: prevent collisions between test VMs backed by a shared disk pool Darrick J. Wong
2024-11-27 5:43 ` Christoph Hellwig
2024-11-27 16:35 ` Darrick J. Wong
2024-11-26 1:20 ` [PATCHSET] xfs: bug fixes for 6.13 Darrick J. Wong
2024-11-26 1:24 ` [PATCH 01/21] xfs: fix off-by-one error in fsmap's end_daddr usage Darrick J. Wong
2024-11-26 1:25 ` [PATCH 02/21] xfs: metapath scrubber should use the already loaded inodes Darrick J. Wong
2024-11-26 1:25 ` [PATCH 03/21] xfs: keep quota directory inode loaded Darrick J. Wong
2024-11-26 1:25 ` [PATCH 04/21] xfs: return a 64-bit block count from xfs_btree_count_blocks Darrick J. Wong
2024-11-26 1:26 ` [PATCH 05/21] xfs: don't drop errno values when we fail to ficlone the entire range Darrick J. Wong
2024-11-26 1:26 ` [PATCH 06/21] xfs: separate healthy clearing mask during repair Darrick J. Wong
2024-11-26 1:26 ` [PATCH 07/21] xfs: set XFS_SICK_INO_SYMLINK_ZAPPED explicitly when zapping a symlink Darrick J. Wong
2024-11-26 1:26 ` [PATCH 08/21] xfs: mark metadir repair tempfiles with IRECOVERY Darrick J. Wong
2024-11-26 1:27 ` [PATCH 09/21] xfs: fix null bno_hint handling in xfs_rtallocate_rtg Darrick J. Wong
2024-11-26 1:27 ` [PATCH 10/21] xfs: fix error bailout in xfs_rtginode_create Darrick J. Wong
2024-11-26 1:27 ` [PATCH 11/21] xfs: update btree keys correctly when _insrec splits an inode root block Darrick J. Wong
2024-11-26 5:01 ` Christoph Hellwig
2024-11-26 1:27 ` [PATCH 12/21] xfs: fix scrub tracepoints when inode-rooted btrees are involved Darrick J. Wong
2024-11-26 5:01 ` Christoph Hellwig
2024-11-26 1:28 ` [PATCH 13/21] xfs: unlock inodes when erroring out of xfs_trans_alloc_dir Darrick J. Wong
2024-11-26 5:03 ` Christoph Hellwig
2024-11-26 1:28 ` [PATCH 14/21] xfs: only run precommits once per transaction object Darrick J. Wong
2024-11-26 5:09 ` Christoph Hellwig
2024-11-26 1:28 ` [PATCH 15/21] xfs: remove recursion in __xfs_trans_commit Darrick J. Wong
2024-11-26 5:11 ` Christoph Hellwig
2024-11-26 5:11 ` Christoph Hellwig
2024-11-26 18:20 ` Darrick J. Wong
2024-11-27 5:44 ` Christoph Hellwig
2024-11-26 1:28 ` [PATCH 16/21] xfs: don't lose solo superblock counter update transactions Darrick J. Wong
2024-11-26 5:14 ` Christoph Hellwig
2024-11-26 18:23 ` Darrick J. Wong
2024-11-26 1:29 ` [PATCH 17/21] xfs: don't lose solo dquot " Darrick J. Wong
2024-11-26 5:18 ` Christoph Hellwig
2024-11-26 18:23 ` Darrick J. Wong
2024-11-26 1:29 ` [PATCH 18/21] xfs: separate dquot buffer reads from xfs_dqflush Darrick J. Wong
2024-11-26 5:27 ` Christoph Hellwig
2024-11-26 1:29 ` [PATCH 19/21] xfs: clean up log item accesses in xfs_qm_dqflush{,_done} Darrick J. Wong
2024-11-26 5:28 ` Christoph Hellwig
2024-11-26 18:25 ` Darrick J. Wong
2024-11-26 1:29 ` [PATCH 20/21] xfs: attach dquot buffer to dquot log item buffer Darrick J. Wong
2024-11-26 5:42 ` Christoph Hellwig
2024-11-26 1:30 ` [PATCH 21/21] xfs: convert quotacheck to attach dquot buffers Darrick J. Wong
2024-11-26 5:42 ` Christoph Hellwig
2024-12-17 2:06 ` Lai, Yi
2024-11-26 20:26 ` Darrick J. Wong [this message]
2024-11-29 8:20 ` [PATCH 22/21] xfs: fix sb_spino_align checks for large fsblock sizes Christoph Hellwig
2024-12-07 0:41 ` Luis Chamberlain
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=20241126202619.GO9438@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=david@fromorbit.com \
--cc=linux-xfs@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox