-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nvme: add test for controller rescan under I/O load
Add a test that repeatedly rescans nvme controllers while doing IO on an nvme namespace connected to these controllers. The purpose of the test is to make sure that no I/O errors or data corruption occurs because of the rescan operations. The test uses sub-second sleeps, which can't be easily accomplished in bash because of missing floating-point arithmetic (and because usleep(1) isn't portable). Therefore an awk program is used to trigger the device rescans. Link: https://lore.kernel.org/linux-nvme/[email protected]/ Signed-off-by: Martin Wilck <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
- Loading branch information
Showing
3 changed files
with
96 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,76 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0+ | ||
# Copyright (C) 2024 Martin Wilck, SUSE LLC | ||
# | ||
# Repeatedly rescans nvme controllers while doing IO on an nvme namespace | ||
# connected to these controllers, and make sure that no I/O errors or data | ||
# corruption occurs. | ||
|
||
. tests/nvme/rc | ||
|
||
DESCRIPTION="test controller rescan under I/O load" | ||
TIMED=1 | ||
: "${TIMEOUT:=60}" | ||
|
||
rescan_controller() { | ||
local path | ||
path="$1/rescan_controller" | ||
|
||
[[ -f "$path" ]] || { | ||
echo "cannot rescan $1" | ||
return 1 | ||
} | ||
|
||
awk -f "$TMPDIR/rescan.awk" \ | ||
-v path="$path" -v timeout="$TIMEOUT" -v seed="$2" & | ||
} | ||
|
||
create_rescan_script() { | ||
cat >"$TMPDIR/rescan.awk" <<EOF | ||
@load "time" | ||
BEGIN { | ||
srand(seed); | ||
finish = gettimeofday() + strtonum(timeout); | ||
while (gettimeofday() < finish) { | ||
sleep(0.1 + 5 * rand()); | ||
printf("1\n") > path; | ||
close(path); | ||
} | ||
} | ||
EOF | ||
} | ||
|
||
test_device() { | ||
local -a ctrls | ||
local i st line | ||
|
||
echo "Running ${TEST_NAME}" | ||
create_rescan_script | ||
|
||
while IFS= read -r line; do | ||
ctrls+=("$line") | ||
done < <(_nvme_get_ctrl_list) | ||
_run_fio_verify_io --filename="$TEST_DEV" --time_based &> "$FULL" & | ||
|
||
for i in "${!ctrls[@]}"; do | ||
rescan_controller "${ctrls[$i]}" "$i" | ||
done | ||
|
||
while true; do | ||
wait -n &>/dev/null | ||
st=$? | ||
case $st in | ||
127) | ||
break | ||
;; | ||
0) | ||
;; | ||
*) | ||
echo "child process exited with $st!" | ||
;; | ||
esac | ||
done | ||
|
||
echo "Test complete" | ||
} |
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,2 @@ | ||
Running nvme/053 | ||
Test complete |
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