Skip to content

Commit 576c698

Browse files
committed
Skip tests if scsi_debug module is already loaded and in use
Several tests across block/, scsi/, dm/, md/, zbd/, nvme/ require exclusive access to the scsi_debug module because they load, unload or reconfigure it. When scsi_debug is already loaded by the environment (e.g., by another driver or a previous setup), these tests fail with: modprobe: FATAL: Module scsi_debug is in use. Unloading scsi_debug failed scsi_debug 327680 4 Instead of modifying common rc files—which would overskip unrelated tests, this patch adds "_module_not_in_use scsi_debug" only to the tests that actually depend on exclusive access to scsi_debug. Signed-off-by: Disha Goel <[email protected]>
1 parent f14914d commit 576c698

7 files changed

Lines changed: 25 additions & 7 deletions

File tree

common/scsi_debug

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,25 @@
55
# scsi_debug helper functions.
66

77
_have_scsi_debug() {
8-
_have_driver scsi_debug
8+
_have_module scsi_debug
9+
if [[ -d /sys/module/scsi_debug ]]; then
10+
_module_not_in_use scsi_debug || return 1
11+
12+
if [[ -e /sys/bus/pseudo/drivers/scsi_debug/add_host ]]; then
13+
if [[ $(cat /sys/bus/pseudo/drivers/scsi_debug/add_host) -gt 1 ]]; then
14+
SKIP_REASON="scsi_debug already has multiple hosts configured"
15+
return 1
16+
fi
17+
fi
18+
fi
19+
}
20+
21+
_have_loadable_scsi_debug() {
22+
_have_scsi_debug || return 1
23+
if [[ ! -f /sys/module/scsi_debug/initstate ]]; then
24+
SKIP_REASON="scsi_debug is built-in and cannot be reloaded"
25+
return 1
26+
fi
927
}
1028

1129
SD_PARAM_PATH=/sys/module/scsi_debug/parameters

tests/block/025

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
DESCRIPTION="do a huge discard with 4k sector size"
1313

1414
requires() {
15-
_have_module scsi_debug
15+
_have_loadable_scsi_debug
1616
}
1717

1818
test() {

tests/block/028

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DESCRIPTION="do I/O on scsi_debug with DIF/DIX enabled"
1212
DMESG_FILTER="sed -r 's/(guard tag error at sector|ref tag error at location)/blktests failure: \\1/'"
1313

1414
requires() {
15-
_have_module scsi_debug
15+
_have_loadable_scsi_debug
1616
}
1717

1818
test_pi() {

tests/block/032

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ QUICK=1
1414

1515
requires() {
1616
_have_xfs
17-
_have_module scsi_debug
17+
_have_loadable_scsi_debug
1818
}
1919

2020
test() {

tests/loop/004

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ QUICK=1
1212

1313
requires() {
1414
_have_program xfs_io
15-
_have_module scsi_debug
15+
_have_loadable_scsi_debug
1616
_have_src_program loblksize
1717
_have_loop_set_block_size
1818
}

tests/scsi/007

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DESCRIPTION="Trigger the SCSI error handler"
1212
QUICK=1
1313

1414
requires() {
15-
_have_module scsi_debug
15+
_have_loadable_scsi_debug
1616
}
1717

1818
start_tracing() {

tests/zbd/008

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ DESCRIPTION="check no stale page cache after BLKZONERESET and data read race"
1313
TIMED=1
1414

1515
requires() {
16-
_have_module scsi_debug
16+
_have_loadable_scsi_debug
1717
_have_module_param scsi_debug zbc
1818
_have_program xfs_io
1919
}

0 commit comments

Comments
 (0)