Skip to content

Commit

Permalink
scsi/098: Test F2FS write hint support
Browse files Browse the repository at this point in the history
  • Loading branch information
bvanassche committed Jan 10, 2024
1 parent 5555b07 commit 5429037
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
13 changes: 13 additions & 0 deletions common/scsi_debug
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ _have_scsi_debug_npo2() {
return 1
}

_have_scsi_debug_group_number_stats() {
modprobe -r scsi_debug >&/dev/null
if modprobe scsi_debug delay=0 >&/dev/null &&
[[ -e /sys/bus/pseudo/drivers/scsi_debug/group_number_stats ]]
then
modprobe -r scsi_debug >&/dev/null
return 0
fi
SKIP_REASONS+=("scsi_debug does not support group number statistics")
modprobe -r scsi_debug >&/dev/null
return 1
}

_scsi_debug_key_path() {
local key=${1}

Expand Down
57 changes: 57 additions & 0 deletions tests/scsi/098
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2022 Google LLC

. tests/zbd/rc
. common/null_blk
. common/scsi_debug

DESCRIPTION="test F2FS write hint support"
QUICK=1

requires() {
_have_fio
_have_driver f2fs
_have_program mkfs.f2fs
_have_scsi_debug_group_number_stats
}

test() {
echo "Running ${TEST_NAME}"

local mount_dir="$TMPDIR/mnt"

local scsi_debug_params=(
delay=0
dev_size_mb=1024
sector_size=4096
)
_init_scsi_debug "${scsi_debug_params[@]}" &&
local dev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail &&
ls -ld "${dev}" >>"${FULL}" &&
mkfs.f2fs "${dev}" >>"${FULL}" 2>&1 &&
mkdir -p "${mount_dir}" &&
mount -t f2fs -o whint_mode=fs-based "${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
head -n 999 /sys/bus/pseudo/drivers/scsi_debug/group_number_stats >> "${FULL}"
while read -r group count; do
if [ "$count" -gt 0 ]; then echo "$group"; fi
done < /sys/bus/pseudo/drivers/scsi_debug/group_number_stats
_exit_scsi_debug

if [ -z "$fail" ]; then
echo "Test complete"
else
echo "Test failed"
return 1
fi
}
5 changes: 5 additions & 0 deletions tests/scsi/098.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Running scsi/098
0
2
3
Test complete

0 comments on commit 5429037

Please sign in to comment.