]> www.infradead.org Git - users/hch/blktests.git/commitdiff
tests/zbd: Add tests for SCSI devices with gap zones
authorBart Van Assche <bvanassche@acm.org>
Thu, 21 Apr 2022 17:43:15 +0000 (10:43 -0700)
committerBart Van Assche <bvanassche@acm.org>
Wed, 3 Aug 2022 14:06:47 +0000 (07:06 -0700)
Verify that I/O on top of BTRFS or F2FS on top of zoned scsi_debug works
fine if gap zones are present.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
tests/zbd/009 [new file with mode: 0755]
tests/zbd/009.out [new file with mode: 0644]
tests/zbd/010 [new file with mode: 0644]
tests/zbd/010.out [new file with mode: 0644]

diff --git a/tests/zbd/009 b/tests/zbd/009
new file mode 100755 (executable)
index 0000000..af430e7
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Google LLC
+
+. tests/zbd/rc
+. common/scsi_debug
+
+DESCRIPTION="test gap zone support with BTRFS"
+QUICK=1
+
+requires() {
+       _have_fio
+       _have_driver btrfs
+       _have_module_param scsi_debug zone_cap_mb
+       _have_program mkfs.btrfs
+       _have_scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       local params=(
+               delay=0
+               dev_size_mb=1024
+               sector_size=4096
+               zbc=host-managed
+               zone_cap_mb=3
+               zone_nr_conv=0
+               zone_size_mb=4
+       )
+       _init_scsi_debug "${params[@]}" || return 1
+
+       local dev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail
+
+       mkfs.btrfs -O zoned "${dev}" >>"${FULL}" 2>&1 &&
+       local mount_dir="$TMPDIR/mnt" &&
+       mkdir -p "${mount_dir}" &&
+       mount -t btrfs "${dev}" "${mount_dir}" &&
+       local fio_args=(
+               --size=1M
+               --directory="${mount_dir}"
+               --time_based
+               --runtime=10
+       ) &&
+       _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1 ||
+       fail=true
+
+       umount "${mount_dir}" >>"${FULL}" 2>&1
+
+       _exit_scsi_debug
+
+       if [ -z "$fail" ]; then
+               echo "Test complete"
+       else
+               echo "Test failed"
+               return 1
+       fi
+}
diff --git a/tests/zbd/009.out b/tests/zbd/009.out
new file mode 100644 (file)
index 0000000..e57ce5f
--- /dev/null
@@ -0,0 +1,2 @@
+Running zbd/009
+Test complete
diff --git a/tests/zbd/010 b/tests/zbd/010
new file mode 100644 (file)
index 0000000..6d634b0
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-3.0+
+# Copyright (C) 2022 Google LLC
+
+. tests/zbd/rc
+. common/null_blk
+. common/scsi_debug
+
+DESCRIPTION="test gap zone support with F2FS"
+QUICK=1
+
+requires() {
+       _have_fio
+       _have_driver f2fs
+       _have_modules null_blk
+       _have_module_param scsi_debug zone_cap_mb
+       _have_program mkfs.f2fs
+       _have_scsi_debug
+}
+
+test() {
+       echo "Running ${TEST_NAME}"
+
+       local mount_dir="$TMPDIR/mnt"
+
+       local null_blk_params=(
+               blocksize=4096
+               completion_nsec=0
+               memory_backed=1
+               size=1024 # MB
+               submit_queues=1
+               power=1
+       )
+       _init_null_blk nr_devices=0 queue_mode=2 &&
+       _configure_null_blk nullb0 "${null_blk_params[@]}" || return $?
+       local cdev=/dev/nullb0
+
+       local scsi_debug_params=(
+               delay=0
+               dev_size_mb=1024
+               sector_size=4096
+               zbc=host-managed
+               zone_cap_mb=3
+               zone_nr_conv=0
+               zone_size_mb=4
+       )
+       _init_scsi_debug "${scsi_debug_params[@]}" &&
+       local zdev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail &&
+       ls -ld "${cdev}" "${zdev}" >>"${FULL}" &&
+       mkfs.f2fs -m "${cdev}" -c "${zdev}" >>"${FULL}" 2>&1 &&
+       mkdir -p "${mount_dir}" &&
+       mount -t f2fs "${cdev}" "${mount_dir}" &&
+       local fio_args=(
+               --size=1M
+               --directory="${mount_dir}"
+               --time_based
+               --runtime=10
+       ) &&
+       _run_fio_verify_io "${fio_args[@]}" >>"${FULL}" 2>&1 ||
+       fail=true
+
+       umount "${mount_dir}" >>"${FULL}" 2>&1
+       _exit_scsi_debug
+       _exit_null_blk
+
+       if [ -z "$fail" ]; then
+               echo "Test complete"
+       else
+               echo "Test failed"
+               return 1
+       fi
+}
diff --git a/tests/zbd/010.out b/tests/zbd/010.out
new file mode 100644 (file)
index 0000000..931d112
--- /dev/null
@@ -0,0 +1,2 @@
+Running zbd/010
+Test complete