All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems
@ 2023-08-17 15:40 Anand Jain
  2023-08-18 15:13 ` Darrick J. Wong
  2023-08-21  9:05 ` [PATCH v2] " Anand Jain
  0 siblings, 2 replies; 5+ messages in thread
From: Anand Jain @ 2023-08-17 15:40 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs, zlang, ddiss

There are two repair functions: _repair_scratch_fs() and
_repair_test_fs(). As the names suggest, these functions are designed to
repair the filesystems SCRATCH_DEV and TEST_DEV, respectively. However,
these functions never called proper comamnd for the filesystem type btrfs.
This patch fixes it. Thx.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/rc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/common/rc b/common/rc
index 66d270acf069..49effbf760c0 100644
--- a/common/rc
+++ b/common/rc
@@ -1177,6 +1177,15 @@ _repair_scratch_fs()
 	fi
 	return $res
         ;;
+    btrfs)
+	echo "btrfs check --repair --force $SCRATCH_DEV"
+	btrfs check --repair --force $SCRATCH_DEV 2>&1
+	local res=$?
+	if [ $res -ne 0 ]; then
+		_dump_err2 "btrfs repair failed, err=$res"
+	fi
+	return $res
+	;;
     bcachefs)
 	# With bcachefs, if fsck detects any errors we consider it a bug and we
 	# want the test to fail:
@@ -1229,6 +1238,11 @@ _repair_test_fs()
 			res=$?
 		fi
 		;;
+	btrfs)
+		echo 'btrfs check --repair --force "$@"' > /tmp.repair 2>&1
+		btrfs check --repair --force "$@" >> /tmp.repair 2>&1
+		res=$?
+		;;
 	*)
 		# Let's hope fsck -y suffices...
 		fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
-- 
2.39.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems
  2023-08-17 15:40 [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems Anand Jain
@ 2023-08-18 15:13 ` Darrick J. Wong
  2023-08-21  7:47   ` Anand Jain
  2023-08-21  9:05 ` [PATCH v2] " Anand Jain
  1 sibling, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2023-08-18 15:13 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs, zlang, ddiss

On Thu, Aug 17, 2023 at 11:40:04PM +0800, Anand Jain wrote:
> There are two repair functions: _repair_scratch_fs() and
> _repair_test_fs(). As the names suggest, these functions are designed to
> repair the filesystems SCRATCH_DEV and TEST_DEV, respectively. However,
> these functions never called proper comamnd for the filesystem type btrfs.
> This patch fixes it. Thx.

Heh.  This sounds like a good improvement. :)

> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  common/rc | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index 66d270acf069..49effbf760c0 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1177,6 +1177,15 @@ _repair_scratch_fs()
>  	fi
>  	return $res
>          ;;
> +    btrfs)
> +	echo "btrfs check --repair --force $SCRATCH_DEV"
> +	btrfs check --repair --force $SCRATCH_DEV 2>&1

Should you allow callers of _repair_{test,scratch}_fs to pass in
arguments?

--D

> +	local res=$?
> +	if [ $res -ne 0 ]; then
> +		_dump_err2 "btrfs repair failed, err=$res"
> +	fi
> +	return $res
> +	;;
>      bcachefs)
>  	# With bcachefs, if fsck detects any errors we consider it a bug and we
>  	# want the test to fail:
> @@ -1229,6 +1238,11 @@ _repair_test_fs()
>  			res=$?
>  		fi
>  		;;
> +	btrfs)
> +		echo 'btrfs check --repair --force "$@"' > /tmp.repair 2>&1
> +		btrfs check --repair --force "$@" >> /tmp.repair 2>&1
> +		res=$?
> +		;;
>  	*)
>  		# Let's hope fsck -y suffices...
>  		fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
> -- 
> 2.39.3
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems
  2023-08-18 15:13 ` Darrick J. Wong
@ 2023-08-21  7:47   ` Anand Jain
  0 siblings, 0 replies; 5+ messages in thread
From: Anand Jain @ 2023-08-21  7:47 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-btrfs, zlang, ddiss



On 18/08/2023 23:13, Darrick J. Wong wrote:
> On Thu, Aug 17, 2023 at 11:40:04PM +0800, Anand Jain wrote:
>> There are two repair functions: _repair_scratch_fs() and
>> _repair_test_fs(). As the names suggest, these functions are designed to
>> repair the filesystems SCRATCH_DEV and TEST_DEV, respectively. However,
>> these functions never called proper comamnd for the filesystem type btrfs.
>> This patch fixes it. Thx.
> 
> Heh.  This sounds like a good improvement. :)

:-)  (btrfs-progs has eloborate repair test cases.)

> 
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   common/rc | 14 ++++++++++++++
>>   1 file changed, 14 insertions(+)
>>
>> diff --git a/common/rc b/common/rc
>> index 66d270acf069..49effbf760c0 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -1177,6 +1177,15 @@ _repair_scratch_fs()
>>   	fi
>>   	return $res
>>           ;;
>> +    btrfs)
>> +	echo "btrfs check --repair --force $SCRATCH_DEV"
>> +	btrfs check --repair --force $SCRATCH_DEV 2>&1
> 
> Should you allow callers of _repair_{test,scratch}_fs to pass in
> arguments?

As I searched, no caller is passing any arguments, so we could
enhance it when required, IMO.

The _xfs_repair_test_fs() function is not found. It looks like
it needs a fix.

Thanks, Anand


> --D
> 
>> +	local res=$?
>> +	if [ $res -ne 0 ]; then
>> +		_dump_err2 "btrfs repair failed, err=$res"
>> +	fi
>> +	return $res
>> +	;;
>>       bcachefs)
>>   	# With bcachefs, if fsck detects any errors we consider it a bug and we
>>   	# want the test to fail:
>> @@ -1229,6 +1238,11 @@ _repair_test_fs()
>>   			res=$?
>>   		fi
>>   		;;
>> +	btrfs)
>> +		echo 'btrfs check --repair --force "$@"' > /tmp.repair 2>&1
>> +		btrfs check --repair --force "$@" >> /tmp.repair 2>&1
>> +		res=$?
>> +		;;
>>   	*)
>>   		# Let's hope fsck -y suffices...
>>   		fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
>> -- 
>> 2.39.3
>>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2] fstests: use btrfs check repair for repairing btrfs filesystems
  2023-08-17 15:40 [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems Anand Jain
  2023-08-18 15:13 ` Darrick J. Wong
@ 2023-08-21  9:05 ` Anand Jain
  2023-09-13 17:06   ` Zorro Lang
  1 sibling, 1 reply; 5+ messages in thread
From: Anand Jain @ 2023-08-21  9:05 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

There are two repair functions: _repair_scratch_fs() and
_repair_test_fs(). As the names suggest, these functions are designed to
repair the filesystems SCRATCH_DEV and TEST_DEV, respectively. However,
these functions never called proper comamnd for the filesystem type btrfs.
This patch fixes it. Thx.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:

When I reran the tests, they hung because 'btrfs check --repair' was
waiting for confirmation to fix the tree, despite using the '--force'
option. This is a bug. However, we still need to support the older
btrfs-progs. So, pass in a 'yes' response.

Uses BTRFS_UTIL_PROG instead of btrfs.

 common/rc | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/common/rc b/common/rc
index 5002369b9b34..45cb56816c05 100644
--- a/common/rc
+++ b/common/rc
@@ -1187,6 +1187,15 @@ _repair_scratch_fs()
 	fi
 	return $res
         ;;
+    btrfs)
+	echo "yes|$BTRFS_UTIL_PROG check --repair --force $SCRATCH_DEV"
+	yes | $BTRFS_UTIL_PROG check --repair --force $SCRATCH_DEV 2>&1
+	local res=$?
+	if [ $res -ne 0 ]; then
+		_dump_err2 "btrfs repair failed, err=$res"
+	fi
+	return $res
+	;;
     bcachefs)
 	# With bcachefs, if fsck detects any errors we consider it a bug and we
 	# want the test to fail:
@@ -1239,6 +1248,13 @@ _repair_test_fs()
 			res=$?
 		fi
 		;;
+	btrfs)
+	echo 'yes|$BTRFS_UTIL_PROG check --repair --force "$TEST_DEV"' > \
+								/tmp.repair 2>&1
+	yes | $BTRFS_UTIL_PROG check --repair --force "$TEST_DEV" >> \
+								/tmp.repair 2>&1
+		res=$?
+		;;
 	*)
 		# Let's hope fsck -y suffices...
 		fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] fstests: use btrfs check repair for repairing btrfs filesystems
  2023-08-21  9:05 ` [PATCH v2] " Anand Jain
@ 2023-09-13 17:06   ` Zorro Lang
  0 siblings, 0 replies; 5+ messages in thread
From: Zorro Lang @ 2023-09-13 17:06 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Mon, Aug 21, 2023 at 05:05:09PM +0800, Anand Jain wrote:
> There are two repair functions: _repair_scratch_fs() and
> _repair_test_fs(). As the names suggest, these functions are designed to
> repair the filesystems SCRATCH_DEV and TEST_DEV, respectively. However,
> these functions never called proper comamnd for the filesystem type btrfs.
> This patch fixes it. Thx.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---

This patch looks good to me. It's been several weeks past, there's not more
review points or better idea from others either. So I'd like to merge it, to
support btrfs specific repair.

Reviewed-by: Zorro Lang <zlang@redhat.com>

> v2:
> 
> When I reran the tests, they hung because 'btrfs check --repair' was
> waiting for confirmation to fix the tree, despite using the '--force'
> option. This is a bug. However, we still need to support the older
> btrfs-progs. So, pass in a 'yes' response.
> 
> Uses BTRFS_UTIL_PROG instead of btrfs.
> 
>  common/rc | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index 5002369b9b34..45cb56816c05 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -1187,6 +1187,15 @@ _repair_scratch_fs()
>  	fi
>  	return $res
>          ;;
> +    btrfs)
> +	echo "yes|$BTRFS_UTIL_PROG check --repair --force $SCRATCH_DEV"
> +	yes | $BTRFS_UTIL_PROG check --repair --force $SCRATCH_DEV 2>&1
> +	local res=$?
> +	if [ $res -ne 0 ]; then
> +		_dump_err2 "btrfs repair failed, err=$res"
> +	fi
> +	return $res
> +	;;
>      bcachefs)
>  	# With bcachefs, if fsck detects any errors we consider it a bug and we
>  	# want the test to fail:
> @@ -1239,6 +1248,13 @@ _repair_test_fs()
>  			res=$?
>  		fi
>  		;;
> +	btrfs)
> +	echo 'yes|$BTRFS_UTIL_PROG check --repair --force "$TEST_DEV"' > \
> +								/tmp.repair 2>&1
> +	yes | $BTRFS_UTIL_PROG check --repair --force "$TEST_DEV" >> \
> +								/tmp.repair 2>&1
> +		res=$?
> +		;;
>  	*)
>  		# Let's hope fsck -y suffices...
>  		fsck -t $FSTYP -y $TEST_DEV >$tmp.repair 2>&1
> -- 
> 2.38.1
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-13 17:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-17 15:40 [PATCH] fstests: use btrfs check repair for repairing btrfs filesystems Anand Jain
2023-08-18 15:13 ` Darrick J. Wong
2023-08-21  7:47   ` Anand Jain
2023-08-21  9:05 ` [PATCH v2] " Anand Jain
2023-09-13 17:06   ` Zorro Lang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.