Test that do use _configure_null_blk already configure do not actually
require a built-in null_blk driver. Relax the check in _have_null_blk
to just require a driver instead of a module, and instead set a skip
reason instead of failing in _init_null_blk when null_blk is built-in
or otherwise not available.
Also try to load the null_blk module in _configure_null_blk as
_init_null_blk is optional now and we thus can't rely on the module
to be loaded.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
#
# null_blk helper functions.
+. common/shellcheck
+
_have_null_blk() {
- _have_modules null_blk
+ _have_driver null_blk
}
_remove_null_blk_devices() {
if (( RUN_FOR_ZONED )); then zoned="zoned=1"; fi
if ! modprobe -r null_blk || ! modprobe null_blk "$@" "${zoned}" ; then
+ SKIP_REASON="requires modular null_blk"
return 1
fi
# Configure one null_blk instance with name $1 and parameters $2..${$#}.
_configure_null_blk() {
local nullb=/sys/kernel/config/nullb/$1 param val
-
shift
+
+ if [[ ! -d /sys/module/null_blk ]]; then
+ modprobe -q null_blk
+ fi
+
mkdir "$nullb" || return $?
while [[ $# -gt 0 ]]; do
param="${1%%=*}"
_exit_null_blk() {
_remove_null_blk_devices
udevadm settle
- modprobe -r null_blk
+ modprobe -r -q null_blk
}