Skip to content

Commit b743eeb

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 loadable and 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 To prevent these failures, this patch introduces a new helper function _have_loadable_scsi_debug(). It verifies if the module is already loaded by checking the ${MODULES_TO_UNLOAD[*]} array. If the module exists but is not in the array, it indicates the module was loaded before the test started, and the test is skipped. Additionally, for cases where scsi_debug is built-in, the environment may have already created additional hosts. To prevent the tests from disrupting these hosts, _have_scsi_debug() now checks the add_host attribute. If the number of hosts is greater than 1, the test is skipped. Signed-off-by: Disha Goel <[email protected]>
1 parent f14914d commit b743eeb

13 files changed

Lines changed: 35 additions & 14 deletions

File tree

common/scsi_debug

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,33 @@
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 [[ -d /sys/module/scsi_debug ]] && \
29+
[[ ! ${MODULES_TO_UNLOAD[*]} =~ scsi_debug ]]; then
30+
SKIP_REASONS+=("scsi_debug is already loaded before test")
31+
return 1
32+
fi
33+
}
1334

1435
_scsi_debug_key_path() {
1536
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/srp/rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ group_requires() {
5858
_have_kver 5 5
5959
_have_iproute2 190404
6060
fi
61-
_have_module scsi_debug
61+
_have_loadable_scsi_debug
6262
_have_module target_core_iblock
6363
_have_module target_core_mod
6464
_module_not_in_use scsi_transport_srp

0 commit comments

Comments
 (0)