Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: ibmvfc: Fix up duplicate response detection

Commit a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale
response detection") introduced a regression in detecting duplicate
responses. This was observed in test where a command was sent to the VIOS
and completed before ibmvfc_send_event() set the active flag to 1, which
resulted in the atomic_dec_if_positive() call in ibmvfc_handle_crq()
thinking this was a duplicate response, which resulted in scsi_done() not
getting called, so we then hit a SCSI command timeout for this command once
the timeout expires. This simply ensures the active flag gets set prior to
making the hcall to send the command to the VIOS, in order to close this
window.

Link: https://lore.kernel.org/r/20211019152129.16558-1-brking@linux.vnet.ibm.com
Fixes: a264cf5e81c7 ("scsi: ibmvfc: Fix command state accounting and stale response detection")
Cc: stable@vger.kernel.org
Acked-by: Tyrel Datwyler <tyreld@linux.ibm.com>
Signed-off-by: Brian King <brking@linux.vnet.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Brian King and committed by
Martin K. Petersen
e20f80b9 4e5483b8

+2 -1
+2 -1
drivers/scsi/ibmvscsi/ibmvfc.c
··· 1696 1696 1697 1697 spin_lock_irqsave(&evt->queue->l_lock, flags); 1698 1698 list_add_tail(&evt->queue_list, &evt->queue->sent); 1699 + atomic_set(&evt->active, 1); 1699 1700 1700 1701 mb(); 1701 1702 ··· 1711 1710 be64_to_cpu(crq_as_u64[1])); 1712 1711 1713 1712 if (rc) { 1713 + atomic_set(&evt->active, 0); 1714 1714 list_del(&evt->queue_list); 1715 1715 spin_unlock_irqrestore(&evt->queue->l_lock, flags); 1716 1716 del_timer(&evt->timer); ··· 1739 1737 1740 1738 evt->done(evt); 1741 1739 } else { 1742 - atomic_set(&evt->active, 1); 1743 1740 spin_unlock_irqrestore(&evt->queue->l_lock, flags); 1744 1741 ibmvfc_trc_start(evt); 1745 1742 }