diff mbox series

[v2,1/4] common/btrfs: introduce _require_btrfs_send_version

Message ID b9f5d4d4ebe898034c36b3b7094b758c2df73e1b.1710411934.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series fstests: btrfs pending misc fixes | expand

Commit Message

Anand Jain March 14, 2024, 10:37 a.m. UTC
Rename _require_btrfs_send_v2() to _require_btrfs_send_version() and
check if the Btrfs kernel supports the v3 stream.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 common/btrfs    | 10 ++++++----
 tests/btrfs/281 |  2 +-
 tests/btrfs/284 |  2 +-
 3 files changed, 8 insertions(+), 6 deletions(-)

Comments

Boris Burkov March 14, 2024, 4:40 p.m. UTC | #1
On Thu, Mar 14, 2024 at 04:07:37PM +0530, Anand Jain wrote:
> Rename _require_btrfs_send_v2() to _require_btrfs_send_version() and
> check if the Btrfs kernel supports the v3 stream.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Boris Burkov <boris@bur.io>
> ---
>  common/btrfs    | 10 ++++++----
>  tests/btrfs/281 |  2 +-
>  tests/btrfs/284 |  2 +-
>  3 files changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index aa344706cd5f..ae13fb55cbc6 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -662,18 +662,20 @@ _require_btrfs_corrupt_block()
>  	_require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
>  }
>  
> -_require_btrfs_send_v2()
> +_require_btrfs_send_version()
>  {
> +	local version=$1
> +
>  	# Check first if btrfs-progs supports the v2 stream.
>  	_require_btrfs_command send --compressed-data
>  
>  	# Now check the kernel support. If send_stream_version does not exists,
>  	# then it's a kernel that only supports v1.
>  	[ -f /sys/fs/btrfs/features/send_stream_version ] || \
> -		_notrun "kernel does not support send stream v2"
> +		_notrun "kernel does not support send stream $version"
>  
> -	[ $(cat /sys/fs/btrfs/features/send_stream_version) -gt 1 ] || \
> -		_notrun "kernel does not support send stream v2"
> +	[ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
> +		_notrun "kernel does not support send stream $version"
>  }
>  
>  # Get the bytenr associated to a file extent item at a given file offset.
> diff --git a/tests/btrfs/281 b/tests/btrfs/281
> index 6407522567b8..ddc7d9e8b06d 100755
> --- a/tests/btrfs/281
> +++ b/tests/btrfs/281
> @@ -22,7 +22,7 @@ _begin_fstest auto quick send compress clone fiemap
>  _supported_fs btrfs
>  _require_test
>  _require_scratch_reflink
> -_require_btrfs_send_v2
> +_require_btrfs_send_version 2
>  _require_xfs_io_command "fiemap"
>  _require_fssum
>  _require_btrfs_no_nodatacow
> diff --git a/tests/btrfs/284 b/tests/btrfs/284
> index c6692668f7fc..0df494bc8ab4 100755
> --- a/tests/btrfs/284
> +++ b/tests/btrfs/284
> @@ -12,7 +12,7 @@ _begin_fstest auto quick send compress snapshot
>  
>  # Modify as appropriate.
>  _supported_fs btrfs
> -_require_btrfs_send_v2
> +_require_btrfs_send_version 2
>  _require_test
>  # The size needed is variable as it depends on the specific randomized
>  # operations from fsstress and on the value of $LOAD_FACTOR. But require at
> -- 
> 2.39.3
>
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index aa344706cd5f..ae13fb55cbc6 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -662,18 +662,20 @@  _require_btrfs_corrupt_block()
 	_require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block
 }
 
-_require_btrfs_send_v2()
+_require_btrfs_send_version()
 {
+	local version=$1
+
 	# Check first if btrfs-progs supports the v2 stream.
 	_require_btrfs_command send --compressed-data
 
 	# Now check the kernel support. If send_stream_version does not exists,
 	# then it's a kernel that only supports v1.
 	[ -f /sys/fs/btrfs/features/send_stream_version ] || \
-		_notrun "kernel does not support send stream v2"
+		_notrun "kernel does not support send stream $version"
 
-	[ $(cat /sys/fs/btrfs/features/send_stream_version) -gt 1 ] || \
-		_notrun "kernel does not support send stream v2"
+	[ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
+		_notrun "kernel does not support send stream $version"
 }
 
 # Get the bytenr associated to a file extent item at a given file offset.
diff --git a/tests/btrfs/281 b/tests/btrfs/281
index 6407522567b8..ddc7d9e8b06d 100755
--- a/tests/btrfs/281
+++ b/tests/btrfs/281
@@ -22,7 +22,7 @@  _begin_fstest auto quick send compress clone fiemap
 _supported_fs btrfs
 _require_test
 _require_scratch_reflink
-_require_btrfs_send_v2
+_require_btrfs_send_version 2
 _require_xfs_io_command "fiemap"
 _require_fssum
 _require_btrfs_no_nodatacow
diff --git a/tests/btrfs/284 b/tests/btrfs/284
index c6692668f7fc..0df494bc8ab4 100755
--- a/tests/btrfs/284
+++ b/tests/btrfs/284
@@ -12,7 +12,7 @@  _begin_fstest auto quick send compress snapshot
 
 # Modify as appropriate.
 _supported_fs btrfs
-_require_btrfs_send_v2
+_require_btrfs_send_version 2
 _require_test
 # The size needed is variable as it depends on the specific randomized
 # operations from fsstress and on the value of $LOAD_FACTOR. But require at