Skip to content

Commit f2e6b75

Browse files
BStroessermartinkpetersen
authored andcommitted
scsi: target: Put lun_ref at end of tmr processing
Testing with Loopback I found that, after a Loopback LUN has executed a TMR, I can no longer unlink the LUN. The rm command hangs in transport_clear_lun_ref() at wait_for_completion(&lun->lun_shutdown_comp) The reason is, that transport_lun_remove_cmd() is not called at the end of target_tmr_work(). It seems, that in other fabrics this call happens implicitly when the fabric drivers call transport_generic_free_cmd() during their ->queue_tm_rsp(). Unfortunately Loopback seems to not comply to the common way of calling transport_generic_free_cmd() from ->queue_*(). Instead it calls transport_generic_free_cmd() from its ->check_stop_free() only. But the ->check_stop_free() is called by transport_cmd_check_stop_to_fabric() after it has reset the se_cmd->se_lun pointer. Therefore the following transport_generic_free_cmd() skips the transport_lun_remove_cmd(). So this patch re-adds the transport_lun_remove_cmd() at the end of target_tmr_work(), which was removed during commit 2c9fa49 ("scsi: target/core: Make ABORT and LUN RESET handling synchronous"). For fabrics using transport_generic_free_cmd() in the usual way the double call to transport_lun_remove_cmd() doesn't harm, as transport_lun_remove_cmd() checks for this situation and does not release lun_ref twice. Link: https://lore.kernel.org/r/[email protected] Fixes: 2c9fa49 ("scsi: target/core: Make ABORT and LUN RESET handling synchronous") Cc: [email protected] Tested-by: Bryant G. Ly <[email protected]> Reviewed-by: Bart van Assche <[email protected]> Signed-off-by: Bodo Stroesser <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 05d18ae commit f2e6b75

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/target/target_core_transport.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3350,6 +3350,7 @@ static void target_tmr_work(struct work_struct *work)
33503350

33513351
cmd->se_tfo->queue_tm_rsp(cmd);
33523352

3353+
transport_lun_remove_cmd(cmd);
33533354
transport_cmd_check_stop_to_fabric(cmd);
33543355
return;
33553356

0 commit comments

Comments
 (0)