diff mbox series

btrfs: verify data checksum during _check_btrfs_filesystem()

Message ID 61bb187a554ff0397665a8898ca2bd56419b6944.1686640441.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: verify data checksum during _check_btrfs_filesystem() | expand

Commit Message

Qu Wenruo June 13, 2023, 7:14 a.m. UTC
By default btrfs only checks the metadata consistency, but sometimes if
we have some corruption in data while the test case doesn't utilize
scrub to verify, or there is some bugs in scrub itself, we will not
detect those problems.

So here we do one step further by utilizing --check-data-csum option, so
that if there is some data corruption, we can detect them early.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 common/btrfs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Qu Wenruo June 13, 2023, 8:10 a.m. UTC | #1
On 2023/6/13 15:14, Qu Wenruo wrote:
> By default btrfs only checks the metadata consistency, but sometimes if
> we have some corruption in data while the test case doesn't utilize
> scrub to verify, or there is some bugs in scrub itself, we will not
> detect those problems.
> 
> So here we do one step further by utilizing --check-data-csum option, so
> that if there is some data corruption, we can detect them early.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

This is a little overkilled, for example btrfs/215 intentionally corrupt 
some data for testing, thus this would cause false alerts.

I'll try to find a way to append options so that test cases can 
determine if they want checksum verification case by case.

Thanks,
Qu
> ---
>   common/btrfs | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index bd4dc31fa5a8..be8ac04cd9a3 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -144,7 +144,7 @@ _check_btrfs_filesystem()
>   		rm -f $tmp.qgroup_report
>   	fi
>   
> -	$BTRFS_UTIL_PROG check $device >$tmp.fsck 2>&1
> +	$BTRFS_UTIL_PROG check --check-data-csum $device >$tmp.fsck 2>&1
>   	if [ $? -ne 0 ]; then
>   		_log_err "_check_btrfs_filesystem: filesystem on $device is inconsistent"
>   		echo "*** fsck.$FSTYP output ***"	>>$seqres.full
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index bd4dc31fa5a8..be8ac04cd9a3 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -144,7 +144,7 @@  _check_btrfs_filesystem()
 		rm -f $tmp.qgroup_report
 	fi
 
-	$BTRFS_UTIL_PROG check $device >$tmp.fsck 2>&1
+	$BTRFS_UTIL_PROG check --check-data-csum $device >$tmp.fsck 2>&1
 	if [ $? -ne 0 ]; then
 		_log_err "_check_btrfs_filesystem: filesystem on $device is inconsistent"
 		echo "*** fsck.$FSTYP output ***"	>>$seqres.full