]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/rc: add repair fsck flag -f for ext4
authorLeah Rumancik <leah.rumancik@gmail.com>
Wed, 25 Jun 2025 21:20:22 +0000 (14:20 -0700)
committerZorro Lang <zlang@kernel.org>
Thu, 26 Jun 2025 20:03:33 +0000 (04:03 +0800)
There is a descrepancy between the fsck flags for ext4 during
filesystem repair and filesystem checking which causes occasional test
failures. In particular, _check_generic_filesystems uses -f for force
checking, but _repair_scratch_fs does not. In some tests, such as
generic/441, we sometimes exit fsck repair early with the filesystem
being deemed "clean" but then _check_generic_filesystems finds issues
during the forced full check. Bringing these flags in sync fixes the
flakes.

Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc

index fbab26b25d00866b4601e780d8c3f3e7a3d4e73d..c6393576de133486870d61697a688a8081322501 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -1551,6 +1551,7 @@ _repair_scratch_fs()
     *)
        local dev=$SCRATCH_DEV
        local fstyp=$FSTYP
+       local fsopts=
        if [ $FSTYP = "overlay" -a -n "$OVL_BASE_SCRATCH_DEV" ]; then
                _repair_overlay_scratch_fs
                # Fall through to repair base fs
@@ -1558,8 +1559,11 @@ _repair_scratch_fs()
                fstyp=$OVL_BASE_FSTYP
                _unmount $OVL_BASE_SCRATCH_MNT
        fi
-       # Let's hope fsck -y suffices...
-       fsck -t $fstyp -y $dev 2>&1
+       if [[ "$FSTYP" =~ ext[234]$ ]]; then
+               fsopts="-f"
+       fi
+
+       fsck -t $fstyp -y ${fsopts} $dev 2>&1
        local res=$?
        case $res in
        $FSCK_OK|$FSCK_NONDESTRUCT|$FSCK_REBOOT)
@@ -1603,8 +1607,11 @@ _repair_test_fs()
                res=$?
                ;;
        *)
-               # Let's hope fsck -y suffices...
-               fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
+               local fsopts=
+               if [[ "$FSTYP" =~ ext[234]$ ]]; then
+                       fsopts="-f"
+               fi
+               fsck -t $FSTYP -y ${fsopts} $TEST_DEV >$tmp.repair 2>&1
                res=$?
                if test "$res" -lt 4 ; then
                        res=0