From: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> To allow running tests against null_blk devices with the zoned mode enabled, introduce the config ZONED variable. If set (ZONED=1), tests that create a null_blk device as a test target device will be executed against a zoned null device. _init_null_blk is modified to prepare null_blk as a zoned blocked device if ZONED is set. To avoid "modprobe -r null_blk" failures, rmdir calls on all sysfs nullbX directories is added. Introduce a helper function _null_blk_not_zoned() to check if _init_null_blk() creates zoned device or not. This function can be used within test script implementation of the requires() function to ensure that the test is run only for non-zoned null_blk device. The use of the ZONED variable requires that the kernel be compiled with CONFIG_BLK_DEV_ZONED enabled. Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx> --- Documentation/running-tests.md | 11 +++++++++++ check | 1 + common/null_blk | 23 ++++++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Documentation/running-tests.md b/Documentation/running-tests.md index 8f32af3..0416d6d 100644 --- a/Documentation/running-tests.md +++ b/Documentation/running-tests.md @@ -82,6 +82,17 @@ passing the `-d` command line option or setting the `DEVICE_ONLY` variable. DEVICE_ONLY=1 ``` +### Zoned Block Device + +Some test items prepare virtual devices such as null_blk. To configure the +virtual device as a zoned block device, set `ZONED` variable. The use of the +ZONED variable requires that the kernel be compiled with CONFIG_BLK_DEV_ZONED +enabled. + +```sh +ZONED=1 +``` + ### Custom Setup The `config` file is really just a bash file that is sourced at the beginning diff --git a/check b/check index 6c6d9f5..141ebb6 100755 --- a/check +++ b/check @@ -591,6 +591,7 @@ fi # Default configuration. : "${DEVICE_ONLY:=0}" : "${QUICK_RUN:=0}" +: "${ZONED:=0}" : "${OUTPUT:=results}" if [[ -v EXCLUDE ]] && ! declare -p EXCLUDE | grep -q '^declare -a'; then # If EXCLUDE was not defined as an array, convert it to one. diff --git a/common/null_blk b/common/null_blk index 937ece0..a78c95d 100644 --- a/common/null_blk +++ b/common/null_blk @@ -8,8 +8,29 @@ _have_null_blk() { _have_modules null_blk } +_null_blk_not_zoned() { + if [[ "${ZONED}" != "0" ]]; then + # shellcheck disable=SC2034 + SKIP_REASON="null_blk zoned mode not supported" + return 1 + fi + return 0 +} + _init_null_blk() { - if ! modprobe -r null_blk || ! modprobe null_blk "$@"; then + for d in /sys/kernel/config/nullb/*; + do [[ -d "$d" ]] && rmdir "$d"; done + + local _zoned="" + if [[ ${ZONED} -ne 0 ]] ; then + if ! _have_kernel_option BLK_DEV_ZONED ; then + echo -n "ZONED specified for kernel with " + echo "CONFIG_BLK_DEV_ZONED disabled" + return 1 + fi + _zoned="zoned=1" + fi + if ! modprobe -r null_blk || ! modprobe null_blk "$@" "${_zoned}" ; then return 1 fi -- 2.20.1