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 <djwong@kernel.org>
[sandeen: add comment above forward-progress test]
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
diff --git a/scrub/inodes.c b/scrub/inodes.c
index 41e5fdc..ffe7eb3 100644
--- a/scrub/inodes.c
+++ b/scrub/inodes.c
@@ -210,6 +210,7 @@
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 @@
/* 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 @@
si->aborted = true;
goto out;
}
+ last_ino = scan_ino;
}
err: