zbd: Initialize open zones list referring zone status at fio start
[fio.git] / t / zbd / run-tests-against-zoned-nullb
1 #!/bin/bash
2 #
3 # Copyright (C) 2018 Western Digital Corporation or its affiliates.
4 #
5 # This file is released under the GPL.
6
7 scriptdir="$(cd "$(dirname "$0")" && pwd)"
8
9 zone_size=1
10 zone_capacity=1
11 if [[ ${1} == "-h" ]]; then
12     echo "Usage: ${0} [OPTIONS]"
13     echo "Options:"
14     echo -e "\t-h Show this message."
15     echo -e "\t-zone-cap Use null blk with zone capacity less than zone size."
16     echo -e "\tany option supported by test-zbd-support script."
17     exit 1
18 elif [[ ${1} == "-zone-cap" ]]; then
19     zone_size=4
20     zone_capacity=3
21     shift
22 fi
23
24 for d in /sys/kernel/config/nullb/*; do [ -d "$d" ] && rmdir "$d"; done
25 modprobe -r null_blk
26 modprobe null_blk nr_devices=0 || exit $?
27 for d in /sys/kernel/config/nullb/*; do
28     [ -d "$d" ] && rmdir "$d"
29 done
30 modprobe -r null_blk
31 [ -e /sys/module/null_blk ] && exit $?
32 modprobe null_blk nr_devices=0 &&
33     cd /sys/kernel/config/nullb &&
34     mkdir nullb0 &&
35     cd nullb0 || exit $?
36
37 if ((zone_capacity < zone_size)); then
38     if [[ ! -w zone_capacity ]]; then
39         echo "null blk does not support zone capacity"
40         exit 1
41     fi
42     echo "${zone_capacity}" > zone_capacity
43 fi
44
45 echo 1 > zoned &&
46     echo "${zone_size}" > zone_size &&
47     echo 0 > completion_nsec &&
48     echo 4096 > blocksize &&
49     echo 1024 > size &&
50     echo 1 > memory_backed &&
51     echo 1 > power || exit $?
52
53 "${scriptdir}"/test-zbd-support "$@" /dev/nullb0