Commit b14a95a
committed
common/nvme: unload nvme modules only when loaded
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.
Reviewed-by: Daniel Wagner <[email protected]>
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>1 parent 31a07ec commit b14a95a
1 file changed
Lines changed: 4 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
217 | 216 | | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | 217 | | |
224 | 218 | | |
225 | 219 | | |
| |||
240 | 234 | | |
241 | 235 | | |
242 | 236 | | |
243 | | - | |
| 237 | + | |
244 | 238 | | |
245 | | - | |
| 239 | + | |
246 | 240 | | |
247 | | - | |
| 241 | + | |
248 | 242 | | |
249 | 243 | | |
250 | 244 | | |
| |||
263 | 257 | | |
264 | 258 | | |
265 | 259 | | |
266 | | - | |
| 260 | + | |
267 | 261 | | |
268 | 262 | | |
269 | 263 | | |
| |||
0 commit comments