[PATCH blktests 0/3] fix module unload failures

Shin'ichiro Kawasaki shinichiro.kawasaki at wdc.com
Sun Feb 22 19:50:20 PST 2026


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




More information about the Linux-nvme mailing list