* [PATCH] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support
@ 2024-07-12 0:05 fdmanana
2024-07-12 0:50 ` Qu Wenruo
2024-07-12 9:54 ` [PATCH v2] " fdmanana
0 siblings, 2 replies; 4+ messages in thread
From: fdmanana @ 2024-07-12 0:05 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, Filipe Manana
From: Filipe Manana <fdmanana@suse.com>
Commit 199d0a992536df3702a0c4843d2a449d54f399c2 ("common/btrfs: introduce
_require_btrfs_send_version") turned _require_btrfs_send_v2 into a generic
helper to detect support for any send stream version, however it's only
working for detecting kernel support, it misses detecting the support from
btrfs-progs - it always checks only that it supports v2 (the send command
supports the --compressed-data option).
Fix that by verifying that btrfs-progs supports the requested version.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
common/btrfs | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/common/btrfs b/common/btrfs
index be5948db..953dc2a0 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -777,17 +777,30 @@ _require_btrfs_corrupt_block()
_require_btrfs_send_version()
{
local version=$1
+ local ret
- # 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,
+ # 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 $version"
[ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
_notrun "kernel does not support send stream $version"
+
+ # Now check that btrfs-progs supports the requested stream version.
+ _scratch_mkfs &> /dev/null || \
+ _fail "mkfs failed at _require_btrfs_send_version"
+ _scratch_mount
+ $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
+ $SCRATCH_MNT/snap &> /dev/null
+ $BTRFS_UTIL_PROG send --proto $version -f /dev/null \
+ $SCRATCH_MNT/snap 2> /dev/null
+ ret=$?
+ _scratch_unmount
+
+ if [ $ret -ne 0 ]; then
+ _notrun "btrfs-progs does not support send stream version $version"
+ fi
}
# Get the bytenr associated to a file extent item at a given file offset.
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support
2024-07-12 0:05 [PATCH] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support fdmanana
@ 2024-07-12 0:50 ` Qu Wenruo
2024-07-12 9:54 ` [PATCH v2] " fdmanana
1 sibling, 0 replies; 4+ messages in thread
From: Qu Wenruo @ 2024-07-12 0:50 UTC (permalink / raw)
To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana
在 2024/7/12 09:35, fdmanana@kernel.org 写道:
> From: Filipe Manana <fdmanana@suse.com>
>
> Commit 199d0a992536df3702a0c4843d2a449d54f399c2 ("common/btrfs: introduce
> _require_btrfs_send_version") turned _require_btrfs_send_v2 into a generic
> helper to detect support for any send stream version, however it's only
> working for detecting kernel support, it misses detecting the support from
> btrfs-progs - it always checks only that it supports v2 (the send command
> supports the --compressed-data option).
>
> Fix that by verifying that btrfs-progs supports the requested version.
>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
> common/btrfs | 21 +++++++++++++++++----
> 1 file changed, 17 insertions(+), 4 deletions(-)
>
> diff --git a/common/btrfs b/common/btrfs
> index be5948db..953dc2a0 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -777,17 +777,30 @@ _require_btrfs_corrupt_block()
> _require_btrfs_send_version()
> {
> local version=$1
> + local ret
>
> - # 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,
> + # 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 $version"
>
> [ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
> _notrun "kernel does not support send stream $version"
> +
> + # Now check that btrfs-progs supports the requested stream version.
> + _scratch_mkfs &> /dev/null || \
> + _fail "mkfs failed at _require_btrfs_send_version"
> + _scratch_mount
> + $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
> + $SCRATCH_MNT/snap &> /dev/null
> + $BTRFS_UTIL_PROG send --proto $version -f /dev/null \
> + $SCRATCH_MNT/snap 2> /dev/null
IHMO we can just skip the -f option and redirect both stderr and stdout
into /dev/null.
Otherwise looks good to me.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> + ret=$?
> + _scratch_unmount
> +
> + if [ $ret -ne 0 ]; then
> + _notrun "btrfs-progs does not support send stream version $version"
> + fi
> }
>
> # Get the bytenr associated to a file extent item at a given file offset.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support
2024-07-12 0:05 [PATCH] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support fdmanana
2024-07-12 0:50 ` Qu Wenruo
@ 2024-07-12 9:54 ` fdmanana
2024-07-12 16:14 ` Anand Jain
1 sibling, 1 reply; 4+ messages in thread
From: fdmanana @ 2024-07-12 9:54 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, Filipe Manana, Qu Wenruo
From: Filipe Manana <fdmanana@suse.com>
Commit 199d0a992536df3702a0c4843d2a449d54f399c2 ("common/btrfs: introduce
_require_btrfs_send_version") turned _require_btrfs_send_v2 into a generic
helper to detect support for any send stream version, however it's only
working for detecting kernel support, it misses detecting the support from
btrfs-progs - it always checks only that it supports v2 (the send command
supports the --compressed-data option).
Fix that by verifying that btrfs-progs supports the requested version.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
V2: Don't use -f /dev/null in the send command, just redirect stdout and
stderr to /dev/null.
Add Qu's review tag.
common/btrfs | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/common/btrfs b/common/btrfs
index be5948db..c0be7c08 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -777,17 +777,29 @@ _require_btrfs_corrupt_block()
_require_btrfs_send_version()
{
local version=$1
+ local ret
- # 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,
+ # 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 $version"
[ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
_notrun "kernel does not support send stream $version"
+
+ # Now check that btrfs-progs supports the requested stream version.
+ _scratch_mkfs &> /dev/null || \
+ _fail "mkfs failed at _require_btrfs_send_version"
+ _scratch_mount
+ $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
+ $SCRATCH_MNT/snap &> /dev/null
+ $BTRFS_UTIL_PROG send --proto $version $SCRATCH_MNT/snap &> /dev/null
+ ret=$?
+ _scratch_unmount
+
+ if [ $ret -ne 0 ]; then
+ _notrun "btrfs-progs does not support send stream version $version"
+ fi
}
# Get the bytenr associated to a file extent item at a given file offset.
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support
2024-07-12 9:54 ` [PATCH v2] " fdmanana
@ 2024-07-12 16:14 ` Anand Jain
0 siblings, 0 replies; 4+ messages in thread
From: Anand Jain @ 2024-07-12 16:14 UTC (permalink / raw)
To: fdmanana, fstests; +Cc: linux-btrfs, Filipe Manana, Qu Wenruo
On 12/07/2024 17:54, fdmanana@kernel.org wrote:
> From: Filipe Manana <fdmanana@suse.com>
>
> Commit 199d0a992536df3702a0c4843d2a449d54f399c2 ("common/btrfs: introduce
> _require_btrfs_send_version") turned _require_btrfs_send_v2 into a generic
> helper to detect support for any send stream version, however it's only
> working for detecting kernel support, it misses detecting the support from
> btrfs-progs - it always checks only that it supports v2 (the send command
> supports the --compressed-data option).
>
> Fix that by verifying that btrfs-progs supports the requested version.
>
> Reviewed-by: Qu Wenruo <wqu@suse.com>
> Signed-off-by: Filipe Manana <fdmanana@suse.com>
> ---
>
> V2: Don't use -f /dev/null in the send command, just redirect stdout and
> stderr to /dev/null.
> Add Qu's review tag.
>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Applied.
Thanks, Anand
> common/btrfs | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/common/btrfs b/common/btrfs
> index be5948db..c0be7c08 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -777,17 +777,29 @@ _require_btrfs_corrupt_block()
> _require_btrfs_send_version()
> {
> local version=$1
> + local ret
>
> - # 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,
> + # 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 $version"
>
> [ $(cat /sys/fs/btrfs/features/send_stream_version) -ge $version ] || \
> _notrun "kernel does not support send stream $version"
> +
> + # Now check that btrfs-progs supports the requested stream version.
> + _scratch_mkfs &> /dev/null || \
> + _fail "mkfs failed at _require_btrfs_send_version"
> + _scratch_mount
> + $BTRFS_UTIL_PROG subvolume snapshot -r $SCRATCH_MNT \
> + $SCRATCH_MNT/snap &> /dev/null
> + $BTRFS_UTIL_PROG send --proto $version $SCRATCH_MNT/snap &> /dev/null
> + ret=$?
> + _scratch_unmount
> +
> + if [ $ret -ne 0 ]; then
> + _notrun "btrfs-progs does not support send stream version $version"
> + fi
> }
>
> # Get the bytenr associated to a file extent item at a given file offset.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-07-12 16:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-12 0:05 [PATCH] btrfs: fix _require_btrfs_send_version to detect btrfs-progs support fdmanana
2024-07-12 0:50 ` Qu Wenruo
2024-07-12 9:54 ` [PATCH v2] " fdmanana
2024-07-12 16:14 ` Anand Jain
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox