From: Darrick J. Wong Date: Wed, 18 May 2022 02:53:22 +0000 (-0400) Subject: xfs_scrub: don't revisit scanned inodes when reprocessing a stale inode X-Git-Tag: v5.18.0-rc1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9f4d6358e28ba1ecbe39ef1df9b309985fa7fa0c;p=thirdparty%2Fxfsprogs-dev.git xfs_scrub: don't revisit scanned inodes when reprocessing a stale inode If we decide to restart an inode chunk walk because one of the inodes is stale, make sure that we don't walk an inode that's been scanned before. This ensure we always make forward progress. Found by observing backwards inode scan progress while running xfs/285. Signed-off-by: Darrick J. Wong [sandeen: add comment above forward-progress test] Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/scrub/inodes.c b/scrub/inodes.c index 41e5fdc75..ffe7eb334 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -210,6 +210,7 @@ scan_ag_bulkstat( struct scan_inodes *si = ichunk->si; struct xfs_bulkstat *bs; struct xfs_inumbers *inumbers = &ireq->inumbers[0]; + uint64_t last_ino = 0; int i; int error; int stale_count = 0; @@ -229,8 +230,14 @@ retry: /* Iterate all the inodes. */ bs = &breq->bulkstat[0]; for (i = 0; !si->aborted && i < inumbers->xi_alloccount; i++, bs++) { + uint64_t scan_ino = bs->bs_ino; + + /* ensure forward progress if we retried */ + if (scan_ino < last_ino) + continue; + descr_set(&dsc_bulkstat, bs); - handle.ha_fid.fid_ino = bs->bs_ino; + handle.ha_fid.fid_ino = scan_ino; handle.ha_fid.fid_gen = bs->bs_gen; error = si->fn(ctx, &handle, bs, si->arg); switch (error) { @@ -260,6 +267,7 @@ _("Changed too many times during scan; giving up.")); si->aborted = true; goto out; } + last_ino = scan_ino; } err: