Skip to content

Commit

Permalink
block/031: allow to run with built-in null_blk driver
Browse files Browse the repository at this point in the history
The test case block/031 sets the null_blk parameter shared_tag_bitmap=1
for testing. The parameter has been set as a module parameter, so the
null_blk driver must be loadable. However, null_blk allows you to set
shared_tag_bitmap as a configfs parameter since the kernel commit
7012eef520cb ("null_blk: add configfs variables for 2 options"). The
test case can now be run with the built-in null_blk driver by specifying
shared_tag_bitmap through configfs.

Modify the test case for that purpose. Refer to the null_blk feature
list and check if shared_tag_bitmap can be specified through configfs.
If so, specify the parameter as an option of _configure_null_blk and set
it through configfs. If not, check in requires() that shared_tag_bitmap
can be specified as a module parameter. Then call _init_null_blk() in
test() and specify shared_tag_bitmap=1 at null_blk module load.

Also, change the null_blk device name from nullb0 to nullb1 since the
default null_blk device name nullb0 is not usable with the built-in
null_blk driver.

Reviewed-by: Chaitanya Kulkarni <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
  • Loading branch information
kawasaki committed Jan 23, 2024
1 parent 4e10207 commit 4f6b3fc
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions tests/block/031
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,43 @@ DESCRIPTION="do IO on null-blk with a host tag set"
TIMED=1

requires() {
_have_fio && _have_null_blk && _have_module_param null_blk shared_tag_bitmap
_have_fio
_have_null_blk
if ! _have_null_blk_feature shared_tag_bitmap; then
_have_module_param null_blk shared_tag_bitmap
fi
}

test() {
local fio_status bs=512
local -a opts=(nullb1 completion_nsec=0 blocksize="$bs" size=1 \
submit_queues="$(nproc)" memory_backed=1)

: "${TIMEOUT:=30}"
if ! _init_null_blk nr_devices=0 shared_tag_bitmap=1; then
echo "Loading null_blk failed"
return 1
# _configure_null_blk() sets null_blk parameters via configfs, while
# _init_null_blk() sets null_blk parameters as module parameters. Old
# kernels require shared_tag_bitmap as a module parameter. In that case,
# call _init_null_blk() for shared_tag_bitmap.
if _have_null_blk_feature shared_tag_bitmap; then
opts+=(shared_tag_bitmap=1)
else
if ! _init_null_blk shared_tag_bitmap=1; then
echo "Loading null_blk failed"
return 1
fi
fi
if ! _configure_null_blk nullb0 completion_nsec=0 blocksize=$bs size=1\
submit_queues="$(nproc)" memory_backed=1 power=1; then
if ! _configure_null_blk "${opts[@]}" power=1; then
echo "Configuring null_blk failed"
return 1
fi
fio --verify=md5 --rw=randwrite --bs=$bs --loops=$((10**6)) \
--iodepth=64 --group_reporting --sync=1 --direct=1 \
--ioengine=libaio --runtime="${TIMEOUT}" --thread \
--name=block-031 --filename=/dev/nullb0 \
--name=block-031 --filename=/dev/nullb1 \
--output="${RESULTS_DIR}/block/fio-output-031.txt" \
>>"$FULL"
fio_status=$?
rmdir /sys/kernel/config/nullb/nullb0
rmdir /sys/kernel/config/nullb/nullb1
_exit_null_blk
case $fio_status in
0) echo "Passed";;
Expand Down

0 comments on commit 4f6b3fc

Please sign in to comment.