From: Mike Christie Date: Sat, 27 Feb 2021 17:00:05 +0000 (-0600) Subject: scsi: target: core: Flush submission work during TMR processing X-Git-Tag: v5.15~1153^2~387 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3d75948b8320ac167ec2efe5a8ebf44bdcb3cc14;p=platform%2Fkernel%2Flinux-starfive.git scsi: target: core: Flush submission work during TMR processing If a cmd is on the submission workqueue then the TMR code will miss it, and end up returning task not found or success for LUN resets. The fabric driver might then tell the initiator that the running cmds have been handled when they are about to run. This adds a flush when we are processing TMRs to make sure queued cmds do not run after returning the TMR response. Link: https://lore.kernel.org/r/20210227170006.5077-25-michael.christie@oracle.com Tested-by: Laurence Oberman Reviewed-by: Bodo Stroesser Signed-off-by: Mike Christie Signed-off-by: Martin K. Petersen --- diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 7347285..e7fcbc0 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c @@ -124,6 +124,8 @@ void core_tmr_abort_task( int i; for (i = 0; i < dev->queue_cnt; i++) { + flush_work(&dev->queues[i].sq.work); + spin_lock_irqsave(&dev->queues[i].lock, flags); list_for_each_entry_safe(se_cmd, next, &dev->queues[i].state_list, state_list) { @@ -302,6 +304,8 @@ static void core_tmr_drain_state_list( * in the Control Mode Page. */ for (i = 0; i < dev->queue_cnt; i++) { + flush_work(&dev->queues[i].sq.work); + spin_lock_irqsave(&dev->queues[i].lock, flags); list_for_each_entry_safe(cmd, next, &dev->queues[i].state_list, state_list) {