Bug 236138

Summary: Unloading a Kernel module dependent on other kernel module does not return device busy first time
Product: Base System Reporter: Prateek <prateekmittal.ec>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Some People    
Priority: ---    
Version: 11.2-RELEASE   
Hardware: Any   
OS: Any   

Description Prateek 2019-03-01 19:15:18 UTC

1. I have a kernel moduleA that is dependent on other kernel moduleB and if I try to unload moduleA, it returns no error 
2. And if I repeat step 1 it returns device busy error message.
3. Now unload moduleB and it removed successfully
4. Now by default module A is unloaded without giving user any clue.
Comment 1 Conrad Meyer freebsd_committer 2019-03-01 19:48:12 UTC
This is how module refcounts work.  kldunload just decrements the administrative refcount.  But a module isn't unloaded until all refs drop to zero.

What would you prefer happen?  EBUSY and do not drop the administrative ref if a module has dependencies?
Comment 2 Prateek 2019-03-01 19:53:51 UTC
Thanks for the comment.
Yes, I expect EBUSY and do not drop the administrative ref if a module has dependencies.

Also the error message EBUSY doe snot coem for teh first time and reruuning the same will return EBUSY with dependencies.
Comment 3 Andriy Gapon freebsd_committer 2019-03-02 17:21:35 UTC
Could you please give an example using real modules, commands and output?