Codex complains that the ESTALE in the switch statement results in the
rest of the bulkstat batch being skipped, and that ECANCELED doesn't
actually abort the walk immediately. scrub_scan_user_files is only
called during phases 5 and 6, which is after we've verified all the file
metadata in the filesystem. Therefore, an ESTALE here means that the
file was deleted, so we skip it and move on to the next file. Fix both
issues.
Cc: linux-xfs@vger.kernel.org # v6.14.0
Fixes: 279b0d0e8d73f1 ("xfs_scrub: call bulkstat directly if we're only scanning user files")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
enum abort_state {
RUNNING = 0,
ABORTED,
+ CANCELLED,
};
static inline int abort_state_ret(enum abort_state s)
goto out;
}
case ECANCELED:
- error = 0;
- fallthrough;
+ si->aborted = CANCELLED;
+ goto out;
default:
goto err;
}
case 0:
break;
case ESTALE:
- case ECANCELED:
+ /*
+ * scrub_scan_user_files is only called during phases
+ * 5 and 6, which is after we've verified all the file
+ * metadata in the filesystem. Therefore, an ESTALE
+ * here means that the file was deleted, so we skip it
+ * and move on to the next file.
+ */
error = 0;
- fallthrough;
+ break;
+ case ECANCELED:
+ /*
+ * Helper function wants us to stop iterating, so stop
+ * the walk immediately.
+ */
+ si->aborted = CANCELLED;
+ goto out;
default:
goto err;
}