Skip to content

Commit 7c3ad92

Browse files
committed
check: check reference count for modprobe --remove --wait success case
The commit "check,common/*: replace module removal with patient module removal" introduced the new helper function _patient_rmmod() which calls modprobe command with --wait option to do patient module removal. However, the modprobe command can return a zero exit status even when the module removal fails. In such cases, the failure remains unreported and hidden. This behavior was observed during the execution of blktests srp test group using rdma_rxe driver on a kernel affected by the rdma_rxe module unload failure bug, which was addressed by the recent patch [1]. To address this problem, check the reference count of the target module after calling the modprobe command in _patient_rmmod(). If the module's reference count indicates a removal failure, print an error message to stderr. While at it, change the print target stream from stdout to stderr for other error messages in _patient_rmmod() to ensure the messages are printed on failure. [1] https://lore.kernel.org/linux-rdma/[email protected]/ Reviewed-by: Bart Van Assche <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
1 parent 0819d1f commit 7c3ad92

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

check

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ _patient_rmmod()
530530
modprobe --remove --wait="${timeout_ms}" "$module"
531531
mod_ret=$?
532532
if [[ $mod_ret -ne 0 ]]; then
533-
echo "kmod patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max returned $mod_ret"
533+
echo "kmod patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max returned $mod_ret" >&2
534+
elif ! _patient_rmmod_check_refcnt "$module_sys"; then
535+
echo "modprobe with --wait option succeeded but still $module has references" >&2
536+
mod_ret=1
534537
fi
535538
return $mod_ret
536539
fi
@@ -544,7 +547,7 @@ _patient_rmmod()
544547
done
545548

546549
if [[ $refcnt_is_zero -ne 1 ]]; then
547-
echo "custom patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max"
550+
echo "custom patient module removal for $module timed out waiting for refcnt to become 0 using timeout of $max_tries_max" 2>&1
548551
return 1
549552
fi
550553

@@ -575,7 +578,7 @@ _patient_rmmod()
575578
done
576579

577580
if [[ $mod_ret -ne 0 ]]; then
578-
echo "custom patient module removal for $module timed out trying to remove using timeout of $max_tries_max last try returned $mod_ret"
581+
echo "custom patient module removal for $module timed out trying to remove using timeout of $max_tries_max last try returned $mod_ret" 2>&1
579582
fi
580583

581584
return $mod_ret

0 commit comments

Comments
 (0)