]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
btrfs: fix _require_btrfs_send_version to detect btrfs-progs support
authorFilipe Manana <fdmanana@suse.com>
Fri, 12 Jul 2024 09:54:24 +0000 (10:54 +0100)
committerZorro Lang <zlang@kernel.org>
Fri, 12 Jul 2024 19:05:35 +0000 (03:05 +0800)
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>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
common/btrfs

index be5948db7e4957673b72a6b0396b03cfd852dc1c..c0be7c08acc389cb8c19b501466f6ffabd2398da 100644 (file)
@@ -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.