Skip to contentSkip to conversation

xfs: fix the forward progress assertion in xfs_iwalk_run_callbacks

PATCH In review Darrick J. Wong 3 participants 3 messages Dec 8, 2020 – Dec 9, 2020 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: fix the forward progress assertion in xfs_iwalk_run_callbacks

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

In commit 27c14b5daa82 we started tracking the last inode seen during an inode walk to avoid infinite loops if a corrupt inobt record happens to have a lower ir_startino than the record preceeding it. Unfortunately, the assertion trips over the case where there are completely empty inobt records (which can happen quite easily on 64k page filesystems) because we advance the tracking cursor without actually putting the empty record into the processing buffer. Fix the assert to allow for this case.

Reported-by [email protected]
Fixes 27c14b5daa82 ("xfs: ensure inobt record walks always make forward progress")
---
 fs/xfs/xfs_iwalk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_iwalk.c +1 -1
index 2a45138831e3..eae3aff9bc97 100644
@@ -363,7 +363,7 @@ xfs_iwalk_run_callbacks(
 	/* Delete cursor but remember the last record we cached... */
 	xfs_iwalk_del_inobt(tp, curpp, agi_bpp, 0);
 	irec = &iwag->recs[iwag->nr_recs - 1];
-	ASSERT(next_agino == irec->ir_startino + XFS_INODES_PER_CHUNK);
+	ASSERT(next_agino >= irec->ir_startino + XFS_INODES_PER_CHUNK);
 
 	error = xfs_iwalk_ag_recs(iwag);
 	if (error)
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Darrick J. Wong

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

In commit 27c14b5daa82 we started tracking the last inode seen during an inode walk to avoid infinite loops if a corrupt inobt record happens to have a lower ir_startino than the record preceeding it. Unfortunately, the assertion trips over the case where there are completely empty inobt records (which can happen quite easily on 64k page filesystems) because we advance the tracking cursor without actually putting the empty record into the processing buffer. Fix the assert to allow for this case.

Quoted 4 lines
Reported-by [email protected]
Fixes 27c14b5daa82 ("xfs: ensure inobt record walks always make forward progress")

---

Looks good to me, and I just gave it a test on the same P9 machine which triggered this bug, test passed.

Quoted 17 lines
 fs/xfs/xfs_iwalk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_iwalk.c +1 -1
index 2a45138831e3..eae3aff9bc97 100644
@@ -363,7 +363,7 @@ xfs_iwalk_run_callbacks(
 	/* Delete cursor but remember the last record we cached... */
 	xfs_iwalk_del_inobt(tp, curpp, agi_bpp, 0);
 	irec = &iwag->recs[iwag->nr_recs - 1];
-	ASSERT(next_agino == irec->ir_startino + XFS_INODES_PER_CHUNK);
+	ASSERT(next_agino >= irec->ir_startino + XFS_INODES_PER_CHUNK);
 
 	error = xfs_iwalk_ag_recs(iwag);
 	if (error)
Reviewed-by on v1 1/1
#2 lore raw
In reply to Darrick J. Wong
Quoted 22 lines · Darrick J. Wong

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

In commit 27c14b5daa82 we started tracking the last inode seen during an inode walk to avoid infinite loops if a corrupt inobt record happens to have a lower ir_startino than the record preceeding it. Unfortunately, the assertion trips over the case where there are completely empty inobt records (which can happen quite easily on 64k page filesystems) because we advance the tracking cursor without actually putting the empty record into the processing buffer. Fix the assert to allow for this case.

Reported-by [email protected]
Fixes 27c14b5daa82 ("xfs: ensure inobt record walks always make forward progress")
---
 fs/xfs/xfs_iwalk.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_iwalk.c +0 -0
index 2a45138831e3..eae3aff9bc97 100644

fs/xfs/xfs_iwalk.c xfs_iwalk_run_callbacks( · line 366

Quoted 5 lines
fs/xfs/xfs_iwalk.c +1 -1
@@ -363,7 +363,7 @@ xfs_iwalk_run_callbacks(
 	/* Delete cursor but remember the last record we cached... */
 	xfs_iwalk_del_inobt(tp, curpp, agi_bpp, 0);
 	irec = &iwag->recs[iwag->nr_recs - 1];
-	ASSERT(next_agino == irec->ir_startino + XFS_INODES_PER_CHUNK);
+	ASSERT(next_agino >= irec->ir_startino + XFS_INODES_PER_CHUNK);

Looks sensible.

Signature · 2 lines
Dave Chinner
[email protected]