From 1066be0dd6f2671dae7c73db69624d659e40f8a1 Mon Sep 17 00:00:00 2001 From: Chandan Babu R Date: Tue, 9 Mar 2021 10:31:12 +0530 Subject: [PATCH] _check_xfs_filesystem: sync fs before running scrub Tests can create a scenario in which a call to syncfs() issued at the end of the execution of the test script would return an error code. xfs_scrub internally calls syncfs() before starting the actual online consistency check operation. Since this call to syncfs() fails, xfs_scrub ends up returning without performing consistency checks on the test filesystem. This can mask a possible on-disk data structure corruption. To fix the above stated problem, this commit invokes syncfs() prior to executing xfs_scrub. Suggested-by: Darrick J. Wong Reviewed-by: Darrick J. Wong Reviewed-by: Allison Henderson Signed-off-by: Chandan Babu R --- common/xfs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/xfs b/common/xfs index fe4dea99..4469f045 100644 --- a/common/xfs +++ b/common/xfs @@ -503,6 +503,17 @@ _check_xfs_filesystem() # Run online scrub if we can. mntpt="$(_is_dev_mounted $device)" if [ -n "$mntpt" ] && _supports_xfs_scrub "$mntpt" "$device"; then + # Tests can create a scenario in which a call to syncfs() issued + # at the end of the execution of the test script would return an + # error code. xfs_scrub internally calls syncfs() before + # starting the actual online consistency check operation. Since + # such a call to syncfs() fails, xfs_scrub ends up returning + # without performing consistency checks on the test + # filesystem. This can mask a possible on-disk data structure + # corruption. Hence consume such a possible syncfs() failure + # before executing a scrub operation. + $XFS_IO_PROG -c syncfs $mntpt >> $seqres.full 2>&1 + "$XFS_SCRUB_PROG" $scrubflag -v -d -n $mntpt > $tmp.scrub 2>&1 if [ $? -ne 0 ]; then _log_err "_check_xfs_filesystem: filesystem on $device failed scrub" -- 2.30.2