Skip to content

Commit

Permalink
Merge pull request osandov#136 from bvanassche/data-lifetime
Browse files Browse the repository at this point in the history
scsi/008: Add a data lifetime test
  • Loading branch information
kawasaki authored Apr 9, 2024
2 parents f073dac + 35b67ba commit b97cfd8
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 2 deletions.
7 changes: 5 additions & 2 deletions common/fio
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,13 @@ _run_fio() {
args+=("--runtime=$TIMEOUT")
fi

if ! fio "${args[@]}" "$@"; then
echo "fio exited with status $?"
fio "${args[@]}" "$@"
local rc=$?
if [ $rc != 0 ]; then
echo "fio exited with status $rc"
cat "$TMPDIR"/fio_perf
fi
return $rc
}

# Wrapper around _run_fio used if you need some I/O but don't really care much
Expand Down
13 changes: 13 additions & 0 deletions common/scsi_debug
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,19 @@ _scsi_debug_key_path() {
echo "$path"
}

_have_scsi_debug_group_number_stats() {
local ret=0

modprobe -qr scsi_debug >&/dev/null
modprobe -q scsi_debug delay=0 >&/dev/null
if ! [[ -e ${SD_PSEUDO_PATH}/group_number_stats ]]; then
SKIP_REASONS+=("scsi_debug does not support group number statistics")
ret=1
fi
modprobe -qr scsi_debug >&/dev/null
return ${ret}
}

declare -a SCSI_DEBUG_HOSTS
declare -a SCSI_DEBUG_TARGETS
declare -a SCSI_DEBUG_DEVICES
Expand Down
81 changes: 81 additions & 0 deletions tests/scsi/008
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
# SPDX-License-Identifier: GPL-3.0+
# Copyright (C) 2024 Google LLC

. tests/scsi/rc
. common/scsi_debug

DESCRIPTION="test block data lifetime support"
QUICK=1

requires() {
_have_scsi_debug_group_number_stats
# For patch "Fall back to F_SET_RW_HINT if F_SET_FILE_RW_HINT is not
# supported"
# (https://github.com/axboe/fio/commit/0cfea592fedf0011e695a604a6961e9cbc1fe9b6).
_have_fio_ver 3 37
}

submit_io() {
local stats_attr=/sys/bus/pseudo/drivers/scsi_debug/group_number_stats
echo "$1 ($3)"
echo "$*" >>"${FULL}"
local direct_io=$2
echo 0 > "${stats_attr}" &&
local fio_args wh &&
for wh in none short medium long extreme; do
if [ "${direct_io}" = 0 ]; then
sync
echo 1 > /proc/sys/vm/drop_caches
fi
fio_args=(
--buffer_pattern='"'"$wh"'"'
--direct="${direct_io}"
--disable_clat=1
--disable_slat=1
--end_fsync=$((1 - direct_io))
--filename="${dev}"
--group_reporting=1
--gtod_reduce=1
--ioengine="$3"
--ioscheduler=none
--name=whint_"$wh"
--norandommap
--rw=randwrite
--size=4M
--thread=1
--write_hint="$wh"
)
echo "fio ${fio_args[*]}" >>"${FULL}" 2>&1
fio "${fio_args[@]}" >>"${FULL}" 2>&1 || return $?
done &&
grep -v ' 0$' "${stats_attr}" >> "${FULL}"
while read -r group count; do
if [ "$count" -gt 0 ]; then echo "$group"; fi
done < "${stats_attr}"
}

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

local scsi_debug_params=(
delay=0
)
_configure_scsi_debug "${scsi_debug_params[@]}" &&
local dev="/dev/${SCSI_DEBUG_DEVICES[0]}" fail &&
ls -ldi "${dev}" >>"${FULL}" &&
submit_io "Direct I/O" 1 pvsync &&
submit_io "Direct I/O" 1 libaio &&
submit_io "Direct I/O" 1 io_uring &&
submit_io "Buffered I/O" 0 pvsync ||
fail=true

_exit_scsi_debug

if [ -z "$fail" ]; then
echo "Test complete"
else
echo "Test failed"
return 1
fi
}
26 changes: 26 additions & 0 deletions tests/scsi/008.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Running scsi/008
Direct I/O (pvsync)
1
2
3
4
5
Direct I/O (libaio)
1
2
3
4
5
Direct I/O (io_uring)
1
2
3
4
5
Buffered I/O (pvsync)
1
2
3
4
5
Test complete

0 comments on commit b97cfd8

Please sign in to comment.