Skip to content

Commit 637f9a8

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 637f9a8

12 files changed

Lines changed: 33 additions & 13 deletions

File tree

common/scsi_debug

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,32 @@
44
#
55
# scsi_debug helper functions.
66

7+
SD_PARAM_PATH=/sys/module/scsi_debug/parameters
8+
SD_PSEUDO_PATH=/sys/bus/pseudo/drivers/scsi_debug
9+
710
_have_scsi_debug() {
811
_have_driver scsi_debug
12+
13+
if _module_file_exists scsi_debug; then
14+
_have_loadable_scsi_debug
15+
return $?
16+
fi
17+
18+
if [[ -e "$SD_PSEUDO_PATH/add_host" ]] && \
19+
[[ $(cat "$SD_PSEUDO_PATH/add_host") -gt 1 ]]; then
20+
SKIP_REASONS+=("scsi_debug already has multiple hosts configured")
21+
return 1
22+
fi
923
}
1024

11-
SD_PARAM_PATH=/sys/module/scsi_debug/parameters
12-
SD_PSEUDO_PATH=/sys/bus/pseudo/drivers/scsi_debug
25+
_have_loadable_scsi_debug() {
26+
_have_module scsi_debug || return 1
27+
28+
if ! _module_not_in_use scsi_debug; then
29+
SKIP_REASONS+=("scsi_debug is already loaded before test")
30+
return 1
31+
fi
32+
}
1333

1434
_scsi_debug_key_path() {
1535
local key=${1}

tests/block/009

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
DESCRIPTION="check page-cache coherency after BLKDISCARD"
1313

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

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/md/002

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DESCRIPTION="test md atomic writes"
1212
QUICK=1
1313

1414
requires() {
15-
_have_driver scsi_debug
15+
_have_scsi_debug
1616
_stacked_atomic_test_requires
1717
}
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/scsi/009

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ DESCRIPTION="test scsi atomic writes"
1212
QUICK=1
1313

1414
requires() {
15-
_have_driver scsi_debug
15+
_have_scsi_debug
1616
_have_xfs_io_atomic_write
1717
}
1818

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)