-# LNet may have an internal ref which can prevent LND modules from
-# unloading. Try to drop it before unloading modules.
-# NB: we squelch stderr because lnetctl/lctl may complain about
-# LNet being "busy", but this is normal. We're making a best effort
-# here.
-if lsmod | grep -q lnet; then
+if $unload_all; then
+ unload_dep_modules_inclusive 'ptlrpc' || exit 1
+ # LNet may have an internal ref which can prevent LND modules from
+ # unloading. Try to drop it before unloading modules.
+ # NB: we squelch stderr because lnetctl/lctl may complain about
+ # LNet being "busy", but this is normal. We're making a best effort
+ # here.