]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: don't skip bulkstat batch when scrub_scan_user_files helper returns ESTALE
authorDarrick J. Wong <djwong@kernel.org>
Wed, 24 Jun 2026 18:15:48 +0000 (11:15 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Thu, 25 Jun 2026 13:42:53 +0000 (15:42 +0200)
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>
scrub/inodes.c

index bf1cbdd6c7698b8a31ad4b3127d682c8c251d2d1..7ce5f7ffeb62a1189efc337c00f52b08368e33b9 100644 (file)
@@ -360,6 +360,7 @@ bulkstat_for_inumbers(
 enum abort_state {
        RUNNING = 0,
        ABORTED,
+       CANCELLED,
 };
 
 static inline int abort_state_ret(enum abort_state s)
@@ -544,8 +545,8 @@ _("Changed too many times during scan; giving up."));
                        goto out;
                }
                case ECANCELED:
-                       error = 0;
-                       fallthrough;
+                       si->aborted = CANCELLED;
+                       goto out;
                default:
                        goto err;
                }
@@ -761,9 +762,22 @@ scan_user_files(
                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;
                }