* [PATCH blktests 0/3] fix module unload failures
@ 2026-02-23 3:50 Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 1/3] check: call _unload_modules for each test run Shin'ichiro Kawasaki
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-02-23 3:50 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: Shin'ichiro Kawasaki
Since the recent commit 7c3ad92d3d8f ("check: check reference count for
modprobe --remove --wait success case"), the test case nvme/060 started
printing the error message below:
modprobe with --wait option succeeded but still nvmet has references
This error indicates that the nvmet modules failed to unload as
expected. While the root cause has existed for a long time, the trigger
commit exposed the problem. I took a look in the failure, and observed
the failure scenario as follows:
- The failure occurs when the test case is executed multiple times for
different transport types. At the first step, nvme/060 is executed for
the loop transport. Although nvme/060 was not designed to run for this
transport type, its requirement check leaves two modules loaded: nvmet
and nvme-loop.
- At the second step, when nvme/060 is executed for the rdma transport,
the helper function _setup_nvmet() loads the nvmet-rdma module for
testing. After the test completes, the helper function
_cleanup_nvmet() attempts to unload the nvmet-rdma and nvmet modules.
While it succeeds to unload the nvmet-rdma module, it fails to unload
the nvmet module because the nvme-loop module is still using the nvmet
module. Hence the error message.
From these observations, I identified two problems below.
1) The requirement check for the loop transport left the nvmet and nvme-
loop modules loaded and it affected the following test. In the
current implementation, the helper function _unload_modules() is
called once, only after nvme/060 has been executed for all specified
transport types. Instead, _unload_modules() should be called after
each run of test test case for every transport. This ensures that the
modules loaded for the requirement check are unloaded.
2) When _setup_nvmet() does not load the nvmet module, there is no need
for _cleanup_nvmet() to attempts to unload it. _cleanup_nvmet()
should unload a module only if it was loaded by _setup_nvmet().
This series addresses these two problems. The first patch fixes the
first problem. The other two patches fix the second problem.
Shin'ichiro Kawasaki (3):
check: call _unload_modules for each test run
common/rc: introduce _load_module()
common/nvme: unload nvme modules only when loaded
check | 15 ++++++++++++---
common/nvme | 14 ++++----------
common/rc | 12 ++++++++++++
3 files changed, 28 insertions(+), 13 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH blktests 1/3] check: call _unload_modules for each test run
2026-02-23 3:50 [PATCH blktests 0/3] fix module unload failures Shin'ichiro Kawasaki
@ 2026-02-23 3:50 ` Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 2/3] common/rc: introduce _load_module() Shin'ichiro Kawasaki
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-02-23 3:50 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: Shin'ichiro Kawasaki
Currently, the check script calls _unload_modules() once per test case.
However, when a test case has set_conditions(), the test case is
executed multiple times, once for each specified condition. Despite
these multiple execution, _unload_modules() is called only once after
all the runs for various conditions have been completed.
This behavior causes module unload problems. When a run leaves some
modules loaded, subsequent runs can be affected by the loaded modules.
To prevent such problems, call _unload_modules() for each test case run
for every condition.
Fixes: fb3ba926da7d ("check: support test case repeat by different conditions")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
check | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/check b/check
index a2c19a2..9622030 100755
--- a/check
+++ b/check
@@ -416,7 +416,7 @@ _cleanup() {
_exit_cgroup2
}
-_call_test() {
+__call_test() {
local test_func="$1"
local seqres="${RESULTS_DIR}/${TEST_NAME}"
# shellcheck disable=SC2034
@@ -536,6 +536,17 @@ _call_test() {
fi
}
+_call_test() {
+ local ret
+
+ __call_test "$@"
+ ret=$?
+
+ _unload_modules
+
+ return $ret
+}
+
_test_dev_is_zoned() {
[[ -e "${TEST_DEV_SYSFS}/queue/zoned" &&
$(cat "${TEST_DEV_SYSFS}/queue/zoned") != none ]]
@@ -887,8 +898,6 @@ _run_test() {
ret=$?
fi
- _unload_modules
-
return $ret
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH blktests 2/3] common/rc: introduce _load_module()
2026-02-23 3:50 [PATCH blktests 0/3] fix module unload failures Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 1/3] check: call _unload_modules for each test run Shin'ichiro Kawasaki
@ 2026-02-23 3:50 ` Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 3/3] common/nvme: unload nvme modules only when loaded Shin'ichiro Kawasaki
2026-02-24 16:40 ` [PATCH blktests 0/3] fix module unload failures Daniel Wagner
3 siblings, 0 replies; 6+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-02-23 3:50 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: Shin'ichiro Kawasaki
When a test case requires specific modules for testing, it loads and
uses the modules. To maintain a clean environment, it is desired that
the test case unloads after execution. The modules should be unloaded
only when the module was not loaded before the test case run. However,
writing logic to determine the module load status and unload accordingly
can be cumbersome.
To simplify and standardize such module unload control, introduce the
helper function _load_module(). It attempts to load the specified
module and records it to the global array MODULES_TO_UNLOAD only when
the module was not already loaded. Modules listed in MODULES_TO_UNLOAD
are unloaded by _unload_modules() after each test case run.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
common/rc | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/common/rc b/common/rc
index abf66a4..0a8caca 100644
--- a/common/rc
+++ b/common/rc
@@ -69,6 +69,18 @@ _have_driver()
return 0
}
+# Load the specified module. Record the module to MODULES_TO_UNLOAD so that they
+# will be unloaded by _unload_modules() after each test case run.
+_load_module() {
+ local modname="${1/-/_}"
+
+ if ! modprobe --quiet --first-time "${modname}"; then
+ return 1
+ fi
+
+ MODULES_TO_UNLOAD+=("${modname}")
+}
+
# Check that the specified crypto algorithm is present, regardless of whether
# it's built-in or as module.
_have_crypto_algorithm()
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH blktests 3/3] common/nvme: unload nvme modules only when loaded
2026-02-23 3:50 [PATCH blktests 0/3] fix module unload failures Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 1/3] check: call _unload_modules for each test run Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 2/3] common/rc: introduce _load_module() Shin'ichiro Kawasaki
@ 2026-02-23 3:50 ` Shin'ichiro Kawasaki
2026-02-24 16:40 ` [PATCH blktests 0/3] fix module unload failures Daniel Wagner
3 siblings, 0 replies; 6+ messages in thread
From: Shin'ichiro Kawasaki @ 2026-02-23 3:50 UTC (permalink / raw)
To: linux-block, linux-nvme; +Cc: Shin'ichiro Kawasaki
To test nvme target driver with various transports, _setup_nvmet() loads
the nvmet module along with other required modules based on the test
conditions. The loaded modules are unloaded by _cleanup_nvmet()
following the same logic as _setup_nvmet(). However, this module load by
_cleanup_nvmet() does not work as expected because it unloads the
modules regardless of module load status at test case start.
For example, when the nvmet and nvme-loop modules are already loaded at
the beginning of nvme/060 test case run for rdma transport. In this
case, _nvmet_setup() loads the nvmet-rdma module, which has a dependency
on the nvmet module. At the end of nvme/060, _cleanup_nvmet() attempts
to unload both the nvmet-rdma and nvmet modules. While the nvmet-rdma
module is successfully unloaded, the nvmet module fails to unload
because it is still used by the nvme-loop module. This results in the
following error message:
modprobe with --wait option succeeded but still nvmet has references
To prevent the module unload failures, unload modules only when the
modules were loaded during the test. For that purpose, replace
"modprobe" commands in _nvmet_setup() with calls to _load_module(). This
ensures that only modules not already loaded are recorded in the global
MODULES_TO_UNLOAD array. Afterward, the recorded modules will be
automatically unloaded after the test case completes. Also drop calls to
_patient_rmmod() in _nvmet_cleanup(), which are no longer necessary.
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
---
common/nvme | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
diff --git a/common/nvme b/common/nvme
index a419cd3..64f1828 100644
--- a/common/nvme
+++ b/common/nvme
@@ -213,13 +213,7 @@ _cleanup_nvmet() {
if [[ "${nvme_trtype}" == "fc" ]]; then
_nvme_fcloop_del_lport "${def_local_wwnn}" "${def_local_wwpn}"
- _patient_rmmod nvme-fcloop
fi
- _patient_rmmod nvme-"${nvme_trtype}"
- if [[ "${nvme_trtype}" != "loop" ]]; then
- _patient_rmmod nvmet-"${nvme_trtype}"
- fi
- _patient_rmmod nvmet
if [[ "${nvme_trtype}" == "rdma" ]]; then
stop_soft_rdma
fi
@@ -240,11 +234,11 @@ _setup_nvmet() {
return
fi
- modprobe -q nvmet
+ _load_module nvmet
if [[ "${nvme_trtype}" != "loop" ]]; then
- modprobe -q nvmet-"${nvme_trtype}"
+ _load_module nvmet-"${nvme_trtype}"
fi
- modprobe -q nvme-"${nvme_trtype}"
+ _load_module nvme-"${nvme_trtype}"
if [[ "${nvme_trtype}" == "rdma" ]]; then
start_soft_rdma
for i in $(rdma_network_interfaces)
@@ -263,7 +257,7 @@ _setup_nvmet() {
done
fi
if [[ "${nvme_trtype}" = "fc" ]]; then
- modprobe -q nvme-fcloop
+ _load_module nvme-fcloop
_nvme_fcloop_add_lport "${def_local_wwnn}" "${def_local_wwpn}"
fi
}
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH blktests 0/3] fix module unload failures
2026-02-23 3:50 [PATCH blktests 0/3] fix module unload failures Shin'ichiro Kawasaki
` (2 preceding siblings ...)
2026-02-23 3:50 ` [PATCH blktests 3/3] common/nvme: unload nvme modules only when loaded Shin'ichiro Kawasaki
@ 2026-02-24 16:40 ` Daniel Wagner
2026-03-02 0:30 ` Shinichiro Kawasaki
3 siblings, 1 reply; 6+ messages in thread
From: Daniel Wagner @ 2026-02-24 16:40 UTC (permalink / raw)
To: Shin'ichiro Kawasaki; +Cc: linux-block, linux-nvme
On Mon, Feb 23, 2026 at 12:50:20PM +0900, Shin'ichiro Kawasaki wrote:
> Since the recent commit 7c3ad92d3d8f ("check: check reference count for
> modprobe --remove --wait success case"), the test case nvme/060 started
> printing the error message below:
>
> modprobe with --wait option succeeded but still nvmet has references
>
> This error indicates that the nvmet modules failed to unload as
> expected. While the root cause has existed for a long time, the trigger
> commit exposed the problem. I took a look in the failure, and observed
> the failure scenario as follows:
>
> - The failure occurs when the test case is executed multiple times for
> different transport types. At the first step, nvme/060 is executed for
> the loop transport. Although nvme/060 was not designed to run for this
> transport type, its requirement check leaves two modules loaded: nvmet
> and nvme-loop.
>
> - At the second step, when nvme/060 is executed for the rdma transport,
> the helper function _setup_nvmet() loads the nvmet-rdma module for
> testing. After the test completes, the helper function
> _cleanup_nvmet() attempts to unload the nvmet-rdma and nvmet modules.
> While it succeeds to unload the nvmet-rdma module, it fails to unload
> the nvmet module because the nvme-loop module is still using the nvmet
> module. Hence the error message.
>
> From these observations, I identified two problems below.
>
> 1) The requirement check for the loop transport left the nvmet and nvme-
> loop modules loaded and it affected the following test. In the
> current implementation, the helper function _unload_modules() is
> called once, only after nvme/060 has been executed for all specified
> transport types. Instead, _unload_modules() should be called after
> each run of test test case for every transport. This ensures that the
> modules loaded for the requirement check are unloaded.
>
> 2) When _setup_nvmet() does not load the nvmet module, there is no need
> for _cleanup_nvmet() to attempts to unload it. _cleanup_nvmet()
> should unload a module only if it was loaded by _setup_nvmet().
>
> This series addresses these two problems. The first patch fixes the
> first problem. The other two patches fix the second problem.
Looks good to me.
Reviewed-by: Daniel Wagner <dwagner@suse.de>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH blktests 0/3] fix module unload failures
2026-02-24 16:40 ` [PATCH blktests 0/3] fix module unload failures Daniel Wagner
@ 2026-03-02 0:30 ` Shinichiro Kawasaki
0 siblings, 0 replies; 6+ messages in thread
From: Shinichiro Kawasaki @ 2026-03-02 0:30 UTC (permalink / raw)
To: Daniel Wagner; +Cc: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org
On Feb 24, 2026 / 17:40, Daniel Wagner wrote:
> On Mon, Feb 23, 2026 at 12:50:20PM +0900, Shin'ichiro Kawasaki wrote:
[...]
> > From these observations, I identified two problems below.
> >
> > 1) The requirement check for the loop transport left the nvmet and nvme-
> > loop modules loaded and it affected the following test. In the
> > current implementation, the helper function _unload_modules() is
> > called once, only after nvme/060 has been executed for all specified
> > transport types. Instead, _unload_modules() should be called after
> > each run of test test case for every transport. This ensures that the
> > modules loaded for the requirement check are unloaded.
> >
> > 2) When _setup_nvmet() does not load the nvmet module, there is no need
> > for _cleanup_nvmet() to attempts to unload it. _cleanup_nvmet()
> > should unload a module only if it was loaded by _setup_nvmet().
> >
> > This series addresses these two problems. The first patch fixes the
> > first problem. The other two patches fix the second problem.
>
> Looks good to me.
>
> Reviewed-by: Daniel Wagner <dwagner@suse.de>
Thanks for the review. FYI, I applied the patches.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-03-02 0:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-23 3:50 [PATCH blktests 0/3] fix module unload failures Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 1/3] check: call _unload_modules for each test run Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 2/3] common/rc: introduce _load_module() Shin'ichiro Kawasaki
2026-02-23 3:50 ` [PATCH blktests 3/3] common/nvme: unload nvme modules only when loaded Shin'ichiro Kawasaki
2026-02-24 16:40 ` [PATCH blktests 0/3] fix module unload failures Daniel Wagner
2026-03-02 0:30 ` Shinichiro Kawasaki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox