From: Luis Chamberlain Bart had put the remove_mpath_devs() call inside a loop because multipathd keeps running while the loop is ongoing and hence can modify paths while the loop is running. The races that multipathd can trigger with the module refcnt is precisely the sort of races which patient module removal is supposed to address. Suggested-by: Bart Van Assche Signed-off-by: Luis Chamberlain [Shin'ichiro: moved a hunk of srp/rc change from the previous patch] Signed-off-by: Shin'ichiro Kawasaki --- tests/srp/rc | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tests/srp/rc b/tests/srp/rc index 47b9546..2d3d615 100755 --- a/tests/srp/rc +++ b/tests/srp/rc @@ -331,19 +331,10 @@ start_srp_ini() { # Unload the SRP initiator driver. stop_srp_ini() { - local i - log_out - for ((i=40;i>=0;i--)); do - remove_mpath_devs || return $? - _unload_module ib_srp >/dev/null 2>&1 && break - sleep 1 - done - if [ -e /sys/module/ib_srp ]; then - echo "Error: unloading kernel module ib_srp failed" - return 1 - fi - _unload_module scsi_transport_srp || return $? + remove_mpath_devs || return $? + _patient_rmmod ib_srp || return 1 + _patient_rmmod scsi_transport_srp || return $? } # Associate the LIO device with name $1/$2 with file $3 and SCSI serial $4. @@ -502,7 +493,7 @@ start_lio_srpt() { if modinfo ib_srpt | grep -q '^parm:[[:blank:]]*rdma_cm_port:'; then opts+=("rdma_cm_port=${srp_rdma_cm_port}") fi - _unload_module ib_srpt + _patient_rmmod ib_srpt modprobe ib_srpt "${opts[@]}" || return $? i=0 for r in "${vdev_path[@]}"; do @@ -564,7 +555,7 @@ stop_lio_srpt() { target_core_file target_core_stgt target_core_user \ target_core_mod do - _unload_module $m 10 || return $? + _patient_rmmod $m || return $? done } -- 2.52.0