Skip to contentSkip to conversation

xfs: disable sparse inode chunk alignment check when there is no alignment

PATCH In review Darrick J. Wong 3 participants 4 messages Jan 31, 2024 – Feb 1, 2024 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: disable sparse inode chunk alignment check when there is no alignment

From: Darrick J. Wong <[email protected]>

While testing a 64k-blocksize filesystem, I noticed that xfs/709 fails to rebuild the inode btree with a bunch of "Corruption remains" messages. It turns out that when the inode chunk size is smaller than a single filesystem block, no block alignments constraints are necessary for inode chunk allocations, and sb_spino_align is zero. Hence we can skip the check.

Fixes dbfbf3bdf639 ("xfs: repair inode btrees")
---
 fs/xfs/scrub/ialloc_repair.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/ialloc_repair.c +1 -1
index b3f7182dd2f5d..e94f108000825 100644
@@ -369,7 +369,7 @@ xrep_ibt_check_inode_ext(
 	 * On a sparse inode fs, this cluster could be part of a sparse chunk.
 	 * Sparse clusters must be aligned to sparse chunk alignment.
 	 */
-	if (xfs_has_sparseinodes(mp) &&
+	if (xfs_has_sparseinodes(mp) && mp->m_sb.sb_spino_align &&
 	    (!IS_ALIGNED(agbno, mp->m_sb.sb_spino_align) ||
 	     !IS_ALIGNED(agbno + len, mp->m_sb.sb_spino_align)))
 		return -EFSCORRUPTED;
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

While testing a 64k-blocksize filesystem, I noticed that xfs/709 fails to rebuild the inode btree with a bunch of "Corruption remains" messages. It turns out that when the inode chunk size is smaller than a single filesystem block, no block alignments constraints are necessary for inode chunk allocations, and sb_spino_align is zero. Hence we can skip the check.

Should sparse inodes even be enabled by mkfs in this case?

Regardless, if sb_spino_align = 0 then xfs_ialloc_setup_geometry() does:

	igeo->ialloc_min_blks = igeo->ialloc_blks;

And this turns off sparse inode allocation for this situation....

Quoted 11 lines
Fixes dbfbf3bdf639 ("xfs: repair inode btrees")
---
 fs/xfs/scrub/ialloc_repair.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/ialloc_repair.c +0 -0
index b3f7182dd2f5d..e94f108000825 100644

fs/xfs/scrub/ialloc_repair.c xrep_ibt_check_inode_ext( · line 375

Quoted 8 lines
fs/xfs/scrub/ialloc_repair.c +1 -1
@@ -369,7 +369,7 @@ xrep_ibt_check_inode_ext(
 	 * On a sparse inode fs, this cluster could be part of a sparse chunk.
 	 * Sparse clusters must be aligned to sparse chunk alignment.
 	 */
-	if (xfs_has_sparseinodes(mp) &&
+	if (xfs_has_sparseinodes(mp) && mp->m_sb.sb_spino_align &&
 	    (!IS_ALIGNED(agbno, mp->m_sb.sb_spino_align) ||
 	     !IS_ALIGNED(agbno + len, mp->m_sb.sb_spino_align)))
 		return -EFSCORRUPTED;

... which makes this additional check reasonable.

Signature · 2 lines
Dave Chinner
[email protected]
#2 lore raw
Quoted 11 lines · Dave Chinner
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

While testing a 64k-blocksize filesystem, I noticed that xfs/709 fails to rebuild the inode btree with a bunch of "Corruption remains" messages. It turns out that when the inode chunk size is smaller than a single filesystem block, no block alignments constraints are necessary for inode chunk allocations, and sb_spino_align is zero. Hence we can skip the check.

Should sparse inodes even be enabled by mkfs in this case?

Probably not, it's totally useless for inopblock <= 64.

Quoted 29 lines

Regardless, if sb_spino_align = 0 then xfs_ialloc_setup_geometry() does:

	igeo->ialloc_min_blks = igeo->ialloc_blks;

And this turns off sparse inode allocation for this situation....

Quoted 11 lines
Fixes dbfbf3bdf639 ("xfs: repair inode btrees")
---
 fs/xfs/scrub/ialloc_repair.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/scrub/ialloc_repair.c +0 -0
index b3f7182dd2f5d..e94f108000825 100644

fs/xfs/scrub/ialloc_repair.c xrep_ibt_check_inode_ext( · line 375

Quoted 8 lines
fs/xfs/scrub/ialloc_repair.c +1 -1
@@ -369,7 +369,7 @@ xrep_ibt_check_inode_ext(
 	 * On a sparse inode fs, this cluster could be part of a sparse chunk.
 	 * Sparse clusters must be aligned to sparse chunk alignment.
 	 */
-	if (xfs_has_sparseinodes(mp) &&
+	if (xfs_has_sparseinodes(mp) && mp->m_sb.sb_spino_align &&
 	    (!IS_ALIGNED(agbno, mp->m_sb.sb_spino_align) ||
 	     !IS_ALIGNED(agbno + len, mp->m_sb.sb_spino_align)))
 		return -EFSCORRUPTED;

... which makes this additional check reasonable.

Quoted 1 line

Thanks!

--D

Quoted 5 lines
Signature · 3 lines
-- 
Dave Chinner
[email protected]