diff mbox series

[2/4] xfs: add a _scratch_require_xfs_scrub helper

Message ID 20240112050833.2255899-3-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [1/4] xfs: check that the mountpoint is actually mounted in _supports_xfs_scrub | expand

Commit Message

Christoph Hellwig Jan. 12, 2024, 5:08 a.m. UTC
Add a helper to call _supports_xfs_scrub with $SCRATCH_MNT and
$SCRATCH_DEV.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 common/xfs    | 7 +++++++
 tests/xfs/556 | 2 +-
 tests/xfs/716 | 2 +-
 3 files changed, 9 insertions(+), 2 deletions(-)

Comments

Zorro Lang Jan. 12, 2024, 1:32 p.m. UTC | #1
On Fri, Jan 12, 2024 at 06:08:31AM +0100, Christoph Hellwig wrote:
> Add a helper to call _supports_xfs_scrub with $SCRATCH_MNT and
> $SCRATCH_DEV.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  common/xfs    | 7 +++++++
>  tests/xfs/556 | 2 +-
>  tests/xfs/716 | 2 +-
>  3 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/common/xfs b/common/xfs
> index 4e54d75cc..b71ba8d1e 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -662,6 +662,13 @@ _supports_xfs_scrub()
>  	return 0
>  }
>  
> +# Does the scratch file system support scrub?
> +_scratch_require_xfs_scrub()

Usually we name a require helper as _require_xxxxxxxx, you can find that
by running `grep -rsn scratch_require common/` and `grep -rsn require_scratch common/`.

So better to change this name to _require_scratch_xfs_scrub. That's a simple
change, I can help to change that when I merge this patchset.

Thanks,
Zorro

> +{
> +	_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || \
> +		_notrun "Scrub not supported"
> +}
> +
>  # Save a snapshot of a corrupt xfs filesystem for later debugging.
>  _xfs_metadump() {
>  	local metadump="$1"
> diff --git a/tests/xfs/556 b/tests/xfs/556
> index 061d8d572..6be993273 100755
> --- a/tests/xfs/556
> +++ b/tests/xfs/556
> @@ -40,7 +40,7 @@ _scratch_mkfs >> $seqres.full
>  _dmerror_init
>  _dmerror_mount >> $seqres.full 2>&1
>  
> -_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || _notrun "Scrub not supported"
> +_scratch_require_xfs_scrub
>  
>  # Write a file with 4 file blocks worth of data
>  victim=$SCRATCH_MNT/a
> diff --git a/tests/xfs/716 b/tests/xfs/716
> index 930a0ecbb..4cfb27f18 100755
> --- a/tests/xfs/716
> +++ b/tests/xfs/716
> @@ -31,7 +31,7 @@ _require_test_program "punch-alternating"
>  _scratch_mkfs > $tmp.mkfs
>  _scratch_mount
>  
> -_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || _notrun "Scrub not supported"
> +_scratch_require_xfs_scrub
>  
>  # Force data device extents so that we can create a file with the exact bmbt
>  # that we need regardless of rt configuration.
> -- 
> 2.39.2
> 
>
Christoph Hellwig Jan. 12, 2024, 2:14 p.m. UTC | #2
On Fri, Jan 12, 2024 at 09:32:05PM +0800, Zorro Lang wrote:
> Usually we name a require helper as _require_xxxxxxxx, you can find that
> by running `grep -rsn scratch_require common/` and `grep -rsn require_scratch common/`.
> 
> So better to change this name to _require_scratch_xfs_scrub. That's a simple
> change, I can help to change that when I merge this patchset.

Fine with me.  I just took the name that Darrick suggested.
Darrick J. Wong Jan. 12, 2024, 4:42 p.m. UTC | #3
On Fri, Jan 12, 2024 at 03:14:10PM +0100, Christoph Hellwig wrote:
> On Fri, Jan 12, 2024 at 09:32:05PM +0800, Zorro Lang wrote:
> > Usually we name a require helper as _require_xxxxxxxx, you can find that
> > by running `grep -rsn scratch_require common/` and `grep -rsn require_scratch common/`.
> > 
> > So better to change this name to _require_scratch_xfs_scrub. That's a simple
> > change, I can help to change that when I merge this patchset.
> 
> Fine with me.  I just took the name that Darrick suggested.

Either name is fine with me, so go with what the maintainer recommends.
Sorry for the churn :)

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> 
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 4e54d75cc..b71ba8d1e 100644
--- a/common/xfs
+++ b/common/xfs
@@ -662,6 +662,13 @@  _supports_xfs_scrub()
 	return 0
 }
 
+# Does the scratch file system support scrub?
+_scratch_require_xfs_scrub()
+{
+	_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || \
+		_notrun "Scrub not supported"
+}
+
 # Save a snapshot of a corrupt xfs filesystem for later debugging.
 _xfs_metadump() {
 	local metadump="$1"
diff --git a/tests/xfs/556 b/tests/xfs/556
index 061d8d572..6be993273 100755
--- a/tests/xfs/556
+++ b/tests/xfs/556
@@ -40,7 +40,7 @@  _scratch_mkfs >> $seqres.full
 _dmerror_init
 _dmerror_mount >> $seqres.full 2>&1
 
-_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || _notrun "Scrub not supported"
+_scratch_require_xfs_scrub
 
 # Write a file with 4 file blocks worth of data
 victim=$SCRATCH_MNT/a
diff --git a/tests/xfs/716 b/tests/xfs/716
index 930a0ecbb..4cfb27f18 100755
--- a/tests/xfs/716
+++ b/tests/xfs/716
@@ -31,7 +31,7 @@  _require_test_program "punch-alternating"
 _scratch_mkfs > $tmp.mkfs
 _scratch_mount
 
-_supports_xfs_scrub $SCRATCH_MNT $SCRATCH_DEV || _notrun "Scrub not supported"
+_scratch_require_xfs_scrub
 
 # Force data device extents so that we can create a file with the exact bmbt
 # that we need regardless of rt configuration.