Skip to content

Conversation

jstancek
Copy link

In a scenario like following:

lsmod | grep -e bnx2i -e cnic

bnx2i 94208 0
libiscsi 94208 1 bnx2i
cnic 90112 1 bnx2i
uio 32768 1 cnic
scsi_transport_iscsi 196608 2 bnx2i,libiscsi

modprobe -v --remove --remove-holders cnic

rmmod bnx2i
rmmod cnic
rmmod libiscsi
rmmod cnic
modprobe: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module()
could not remove 'cnic': No such file or directory

modprobe attempts to remove cnic module twice and propagates that error to the user with a message as well as an exit code.

Add a check to avoid attempts to remove modules that are already gone.

Signed-off-by: Jan Stancek [email protected]

In a scenario like following:
  # lsmod | grep -e bnx2i -e cnic
  bnx2i                  94208  0
  libiscsi               94208  1 bnx2i
  cnic                   90112  1 bnx2i
  uio                    32768  1 cnic
  scsi_transport_iscsi   196608  2 bnx2i,libiscsi

  # modprobe -v --remove --remove-holders cnic
  rmmod bnx2i
  rmmod cnic
  rmmod libiscsi
  rmmod cnic
  modprobe: ERROR: libkmod/libkmod-module.c:856 kmod_module_remove_module()
  could not remove 'cnic': No such file or directory

modprobe attempts to remove cnic module twice and propagates that error
to the user with a message as well as an exit code.

Add a check to avoid attempts to remove modules that are already gone.

Signed-off-by: Jan Stancek <[email protected]>
@evelikov
Copy link
Collaborator

evelikov commented Oct 5, 2025

Thanks for the patch Jan, at a glance the patch looks great.

Some tests would be appreciated - sadly we don't have any modprobe --remove for reference, but the infra is there. See modules_loaded and modules_not_loaded.

@lucasdemarchi the help/manual for remove-holders does not imply a recursive operation, as seen in the above log. Namely: I don't think modprobe --remove-holders cnic should be removing libiscsi. It makes sense to have the recursion, but it should be a separate --recursive toggle IMHO.

@jstancek
Copy link
Author

jstancek commented Oct 5, 2025

Thanks for pointer, I'll have a look if I can add some test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants