diff mbox series

[V6,01/13] _check_xfs_filesystem: sync fs before running scrub

Message ID 20210309050124.23797-2-chandanrlinux@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series xfs: Tests to verify inode fork extent count overflow detection | expand

Commit Message

Chandan Babu R March 9, 2021, 5:01 a.m. UTC
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 <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
 common/xfs | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Darrick J. Wong March 9, 2021, 5:03 a.m. UTC | #1
On Tue, Mar 09, 2021 at 10:31:12AM +0530, Chandan Babu R wrote:
> 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 <djwong@kernel.org>
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>

Looks good to me,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  common/xfs | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 2156749d..41dd8676 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -467,6 +467,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.29.2
>
Allison Henderson March 10, 2021, 6:12 a.m. UTC | #2
On 3/8/21 10:01 PM, Chandan Babu R wrote:
> 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 <djwong@kernel.org>
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Ok, makes sense
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
>   common/xfs | 11 +++++++++++
>   1 file changed, 11 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 2156749d..41dd8676 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -467,6 +467,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"
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 2156749d..41dd8676 100644
--- a/common/xfs
+++ b/common/xfs
@@ -467,6 +467,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"