From: Filipe Manana Date: Mon, 28 Nov 2022 12:07:21 +0000 (+0000) Subject: btrfs: add a _require_btrfs_send_v2 helper X-Git-Tag: v2022.12.11~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=676b0a09706d6db31b453e1c5aabce4204b541de;p=xfstests-dev.git btrfs: add a _require_btrfs_send_v2 helper Add a helper to check that both btrfs-progs and kernel support the v2 send stream, so that we can have tests specific for send v2 stream. Reviewed-by: Josef Bacik Signed-off-by: Filipe Manana Signed-off-by: Zorro Lang --- diff --git a/common/btrfs b/common/btrfs index d27d3384..ee673a93 100644 --- a/common/btrfs +++ b/common/btrfs @@ -585,3 +585,17 @@ _require_btrfs_corrupt_block() { _require_command "$BTRFS_CORRUPT_BLOCK_PROG" btrfs-corrupt-block } + +_require_btrfs_send_v2() +{ + # 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" + + [ $(cat /sys/fs/btrfs/features/send_stream_version) -gt 1 ] || \ + _notrun "kernel does not support send stream v2" +}