]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/fuzzy: fix some problems with the post-repair fs modification code
authorDarrick J. Wong <djwong@kernel.org>
Fri, 30 Dec 2022 22:19:41 +0000 (14:19 -0800)
committerZorro Lang <zlang@kernel.org>
Sat, 25 Feb 2023 13:11:19 +0000 (21:11 +0800)
While auditing the fuzz tester code, I noticed there were numerous
problems with the code that test-drives the filesystem after we've run
the repair strategy.  Now that we've made sure that the repair strategy
checks its own efficacy, we can rearrange this function to try making
mods and then re-check the filesystem afterwards.  Also, disable
xfs_repair prefetch to reduce the likelihood of OOM kills.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/fuzzy

index ac8453235f2199ed5fcad1583acf332583517112..37a1f33da41adb0f2e7835f309546cf3d8f3c986 100644 (file)
@@ -380,37 +380,43 @@ _scratch_xfs_fuzz_field_modifyfs() {
        local fuzz_action="$1"
        local repair="$2"
 
-       # Try to mount the filesystem
-       echo "+ Make sure error is gone (online)"
+       # Try to mount the filesystem so that we can make changes
+       __fuzz_notify "+ Mount filesystem to make changes"
        _try_scratch_mount 2>&1
        res=$?
-       if [ $res -eq 0 ]; then
-               # Make sure online scrub says the filesystem is clean now
-               if [ "${repair}" != "none" ]; then
-                       echo "++ Online scrub"
-                       _scratch_scrub -n -e continue 2>&1
-                               res=$?
-                               test $res -ne 0 && \
-                                       (>&2 echo "online re-scrub ($res) with ${field} = ${fuzzverb}.")
-                       fi
-               fi
+       if [ $res -ne 0 ]; then
+               (>&2 echo "${fuzz_action}: pre-mod mount failed ($res).")
+               return $res
+       fi
+
+       # Try modifying the filesystem again
+       __fuzz_notify "++ Try to write filesystem again"
+       _scratch_fuzz_modify 100 2>&1
 
-               # Try modifying the filesystem again
-               __fuzz_notify "++ Try to write filesystem again"
-               _scratch_fuzz_modify 100 2>&1
+       # If we didn't repair anything, there's no point in checking further,
+       # the fs is still corrupt.
+       if [ "${repair}" = "none" ]; then
                __scratch_xfs_fuzz_unmount
-       else
-               (>&2 echo "re-mount failed ($res) with ${fuzz_action}.")
+               return 0
        fi
 
-       # See if repair finds a clean fs
-       if [ "${repair}" != "none" ]; then
-               echo "+ Re-check the filesystem (offline)"
-               _scratch_xfs_repair -n 2>&1
-               res=$?
-               test $res -ne 0 && \
-                       (>&2 echo "re-repair failed ($res) with ${field} = ${fuzzverb}.")
-       fi
+       # Run an online check to make sure the fs is still ok, unless we
+       # are running the norepair strategy.
+       __fuzz_notify "+ Re-check the filesystem (online)"
+       _scratch_scrub -n -e continue 2>&1
+       res=$?
+       test $res -ne 0 && \
+               (>&2 echo "${fuzz_action}: online post-mod scrub failed ($res).")
+
+       __scratch_xfs_fuzz_unmount
+
+       # Run an offline check to make sure the fs is still ok, unless we
+       # are running the norepair strategy.
+       __fuzz_notify "+ Re-check the filesystem (offline)"
+       _scratch_xfs_repair -P -n 2>&1
+       res=$?
+       test $res -ne 0 && \
+               (>&2 echo "${fuzz_action}: offline post-mod scrub failed ($res).")
 
        return 0
 }