diff mbox series

[v2,2/3] fstests: change how we test for supported raid configs

Message ID 86703e27bdb8c49950be6ea65ac228ece3ecc315.1712346845.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series fstests: various RAID56 related fixes for btrfs | expand

Commit Message

Josef Bacik April 5, 2024, 7:56 p.m. UTC
In btrfs there's a few ways we limit the RAID profiles we'll use.  We
have the raid56 feature that can be compiled out, zoned devices don't
support certain raid configurations, and you can manually set
BTRFS_PROFILE_CONFIGS to limit what you're testing.

To handle all of these different scenarios in the same way, update
_btrfs_get_profile_configs() to check for RAID56 support and remove it
if it is not there, and then add _require_btrfs_raid_type and
_check_btrfs_raid_type to get all the settings and then check if the
requested raid type is available.

From there I've updated all of the existing tests that use

_require_btrfs_fs_feature raid56

to use

_require_btrfs_raid_type <type>

where appropriate.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 common/btrfs    | 29 ++++++++++++++++++++++++-----
 tests/btrfs/125 |  2 +-
 tests/btrfs/148 |  3 ++-
 tests/btrfs/157 |  2 +-
 tests/btrfs/158 |  2 +-
 5 files changed, 29 insertions(+), 9 deletions(-)

Comments

Anand Jain April 9, 2024, 3:33 a.m. UTC | #1
On 4/6/24 03:56, Josef Bacik wrote:
> In btrfs there's a few ways we limit the RAID profiles we'll use.  We
> have the raid56 feature that can be compiled out, zoned devices don't
> support certain raid configurations, and you can manually set
> BTRFS_PROFILE_CONFIGS to limit what you're testing.
> 
> To handle all of these different scenarios in the same way, update
> _btrfs_get_profile_configs() to check for RAID56 support and remove it
> if it is not there, and then add _require_btrfs_raid_type and
> _check_btrfs_raid_type to get all the settings and then check if the
> requested raid type is available.
> 
>  From there I've updated all of the existing tests that use
> 
> _require_btrfs_fs_feature raid56
> 
> to use
> 
> _require_btrfs_raid_type <type>
> 
> where appropriate.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>   common/btrfs    | 29 ++++++++++++++++++++++++-----
>   tests/btrfs/125 |  2 +-
>   tests/btrfs/148 |  3 ++-
>   tests/btrfs/157 |  2 +-
>   tests/btrfs/158 |  2 +-
>   5 files changed, 29 insertions(+), 9 deletions(-)
> 
> diff --git a/common/btrfs b/common/btrfs
> index e1b29c61..845d01ea 100644
> --- a/common/btrfs
> +++ b/common/btrfs
> @@ -98,11 +98,6 @@ _require_btrfs_fs_feature()
>   	modprobe btrfs > /dev/null 2>&1
>   	[ -e /sys/fs/btrfs/features/$feat ] || \
>   		_notrun "Feature $feat not supported by the available btrfs version"
> -
> -	if [ $feat = "raid56" ]; then
> -		# Zoned btrfs only supports SINGLE profile
> -		_require_non_zoned_device "${SCRATCH_DEV}"
> -	fi
>   }
>   
>   _require_btrfs_fs_sysfs()
> @@ -218,6 +213,8 @@ _btrfs_get_profile_configs()
>   		return
>   	fi
>   
> +	modprobe btrfs > /dev/null 2>&1
> +
>   	local unsupported=()
>   	if [ "$1" == "replace" ]; then
>   		# We can't do replace with these profiles because they
> @@ -237,6 +234,14 @@ _btrfs_get_profile_configs()
>   		)
>   	fi
>   
> +	if [ ! -e /sys/fs/btrfs/features/raid56 ]; then
> +		# We don't have raid56 compiled in, remove them
> +		unsupported+=(
> +			"raid5"
> +			"raid6"
> +		)
> +	fi
> +
>   	if _scratch_btrfs_is_zoned; then
>   		# Zoned btrfs only supports SINGLE profile
>   		unsupported+=(
> @@ -792,3 +797,17 @@ _has_btrfs_sysfs_feature_attr()
>   
>   	test -e /sys/fs/btrfs/features/$feature_attr
>   }
> +
> +_check_btrfs_raid_type()
> +{
> +	_btrfs_get_profile_configs
> +	if [[ ! "${_btrfs_profile_configs[@]}" =~ "$1" ]]; then
> +		return 1
> +	fi
> +	return 0
> +}
> +
> +_require_btrfs_raid_type()
> +{
> +	_check_btrfs_raid_type $1 || _notrun "$1 isn't supported by the profile config"
> +}


We also call notrun for zoned devices.
I suggest tweaking the notrun message to:

    _notrun "$1 isn't supported by the profile config or scratch device"

I have made this change and applied it.

Reviewed-by: Anand Jain <anand.jain@oracle.com>

Thanks, Anand


> diff --git a/tests/btrfs/125 b/tests/btrfs/125
> index 1b6e5d78..d957c139 100755
> --- a/tests/btrfs/125
> +++ b/tests/btrfs/125
> @@ -41,7 +41,7 @@ _supported_fs btrfs
>   _require_scratch_dev_pool 3
>   _test_unmount
>   _require_btrfs_forget_or_module_loadable
> -_require_btrfs_fs_feature raid56
> +_require_btrfs_raid_type raid5
>   
>   _scratch_dev_pool_get 3
>   
> diff --git a/tests/btrfs/148 b/tests/btrfs/148
> index 65a26292..9bbcd8e9 100755
> --- a/tests/btrfs/148
> +++ b/tests/btrfs/148
> @@ -17,7 +17,8 @@ _supported_fs btrfs
>   _require_scratch
>   _require_scratch_dev_pool 4
>   _require_odirect
> -_require_btrfs_fs_feature raid56
> +_require_btrfs_raid_type raid5
> +_require_btrfs_raid_type raid6
>   
>   _scratch_dev_pool_get 4
>   
> diff --git a/tests/btrfs/157 b/tests/btrfs/157
> index 022db511..8441a786 100755
> --- a/tests/btrfs/157
> +++ b/tests/btrfs/157
> @@ -32,7 +32,7 @@ _begin_fstest auto quick raid read_repair
>   _supported_fs btrfs
>   _require_scratch_dev_pool 4
>   _require_btrfs_command inspect-internal dump-tree
> -_require_btrfs_fs_feature raid56
> +_require_btrfs_raid_type raid6
>   
>   get_physical()
>   {
> diff --git a/tests/btrfs/158 b/tests/btrfs/158
> index aa85835a..cd4f604c 100755
> --- a/tests/btrfs/158
> +++ b/tests/btrfs/158
> @@ -24,7 +24,7 @@ _begin_fstest auto quick raid scrub
>   _supported_fs btrfs
>   _require_scratch_dev_pool 4
>   _require_btrfs_command inspect-internal dump-tree
> -_require_btrfs_fs_feature raid56
> +_require_btrfs_raid_type raid5
>   
>   get_physical()
>   {
diff mbox series

Patch

diff --git a/common/btrfs b/common/btrfs
index e1b29c61..845d01ea 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -98,11 +98,6 @@  _require_btrfs_fs_feature()
 	modprobe btrfs > /dev/null 2>&1
 	[ -e /sys/fs/btrfs/features/$feat ] || \
 		_notrun "Feature $feat not supported by the available btrfs version"
-
-	if [ $feat = "raid56" ]; then
-		# Zoned btrfs only supports SINGLE profile
-		_require_non_zoned_device "${SCRATCH_DEV}"
-	fi
 }
 
 _require_btrfs_fs_sysfs()
@@ -218,6 +213,8 @@  _btrfs_get_profile_configs()
 		return
 	fi
 
+	modprobe btrfs > /dev/null 2>&1
+
 	local unsupported=()
 	if [ "$1" == "replace" ]; then
 		# We can't do replace with these profiles because they
@@ -237,6 +234,14 @@  _btrfs_get_profile_configs()
 		)
 	fi
 
+	if [ ! -e /sys/fs/btrfs/features/raid56 ]; then
+		# We don't have raid56 compiled in, remove them
+		unsupported+=(
+			"raid5"
+			"raid6"
+		)
+	fi
+
 	if _scratch_btrfs_is_zoned; then
 		# Zoned btrfs only supports SINGLE profile
 		unsupported+=(
@@ -792,3 +797,17 @@  _has_btrfs_sysfs_feature_attr()
 
 	test -e /sys/fs/btrfs/features/$feature_attr
 }
+
+_check_btrfs_raid_type()
+{
+	_btrfs_get_profile_configs
+	if [[ ! "${_btrfs_profile_configs[@]}" =~ "$1" ]]; then
+		return 1
+	fi
+	return 0
+}
+
+_require_btrfs_raid_type()
+{
+	_check_btrfs_raid_type $1 || _notrun "$1 isn't supported by the profile config"
+}
diff --git a/tests/btrfs/125 b/tests/btrfs/125
index 1b6e5d78..d957c139 100755
--- a/tests/btrfs/125
+++ b/tests/btrfs/125
@@ -41,7 +41,7 @@  _supported_fs btrfs
 _require_scratch_dev_pool 3
 _test_unmount
 _require_btrfs_forget_or_module_loadable
-_require_btrfs_fs_feature raid56
+_require_btrfs_raid_type raid5
 
 _scratch_dev_pool_get 3
 
diff --git a/tests/btrfs/148 b/tests/btrfs/148
index 65a26292..9bbcd8e9 100755
--- a/tests/btrfs/148
+++ b/tests/btrfs/148
@@ -17,7 +17,8 @@  _supported_fs btrfs
 _require_scratch
 _require_scratch_dev_pool 4
 _require_odirect
-_require_btrfs_fs_feature raid56
+_require_btrfs_raid_type raid5
+_require_btrfs_raid_type raid6
 
 _scratch_dev_pool_get 4
 
diff --git a/tests/btrfs/157 b/tests/btrfs/157
index 022db511..8441a786 100755
--- a/tests/btrfs/157
+++ b/tests/btrfs/157
@@ -32,7 +32,7 @@  _begin_fstest auto quick raid read_repair
 _supported_fs btrfs
 _require_scratch_dev_pool 4
 _require_btrfs_command inspect-internal dump-tree
-_require_btrfs_fs_feature raid56
+_require_btrfs_raid_type raid6
 
 get_physical()
 {
diff --git a/tests/btrfs/158 b/tests/btrfs/158
index aa85835a..cd4f604c 100755
--- a/tests/btrfs/158
+++ b/tests/btrfs/158
@@ -24,7 +24,7 @@  _begin_fstest auto quick raid scrub
 _supported_fs btrfs
 _require_scratch_dev_pool 4
 _require_btrfs_command inspect-internal dump-tree
-_require_btrfs_fs_feature raid56
+_require_btrfs_raid_type raid5
 
 get_physical()
 {