forked from osandov/blktests
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
scsi/097: Test SCSI disk write hint support
- Loading branch information
1 parent
5429037
commit 4b906c1
Showing
2 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0+ | ||
# Copyright (C) 2022 Google LLC | ||
|
||
. tests/zbd/rc | ||
. common/null_blk | ||
. common/scsi_debug | ||
|
||
DESCRIPTION="test block write hint support" | ||
QUICK=1 | ||
|
||
requires() { | ||
_have_fio | ||
_have_scsi_debug_group_number_stats | ||
} | ||
|
||
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=( | ||
--bs=4K | ||
--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 | ||
dev_size_mb=1024 | ||
sector_size=4096 | ||
) | ||
_init_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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
Running scsi/097 | ||
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 |