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

scsi: lpfc: Match lock ordering of lpfc_cmd->buf_lock and hbalock for abort paths

The SCSI version of the abort handler routine, lpfc_abort_handler(), takes
the lpfc_cmd->buf_lock and then phba->hbalock.

Make the same change for the NVMe abort path, lpfc_nvme_fcp_abort(), to
have consistent lock ordering logic between the two abort paths.

Signed-off-by: Justin Tee <justin.tee@broadcom.com>
Link: https://lore.kernel.org/r/20230417191558.83100-4-justintee8345@gmail.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Justin Tee and committed by
Martin K. Petersen
78e9e350 97f97582

+23 -23
+23 -23
drivers/scsi/lpfc/lpfc_nvme.c
··· 1893 1893 pnvme_rport->port_id, 1894 1894 pnvme_fcreq); 1895 1895 1896 + lpfc_nbuf = freqpriv->nvme_buf; 1897 + if (!lpfc_nbuf) { 1898 + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1899 + "6140 NVME IO req has no matching lpfc nvme " 1900 + "io buffer. Skipping abort req.\n"); 1901 + return; 1902 + } else if (!lpfc_nbuf->nvmeCmd) { 1903 + lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1904 + "6141 lpfc NVME IO req has no nvme_fcreq " 1905 + "io buffer. Skipping abort req.\n"); 1906 + return; 1907 + } 1908 + 1909 + /* Guard against IO completion being called at same time */ 1910 + spin_lock_irqsave(&lpfc_nbuf->buf_lock, flags); 1911 + 1896 1912 /* If the hba is getting reset, this flag is set. It is 1897 1913 * cleared when the reset is complete and rings reestablished. 1898 1914 */ 1899 - spin_lock_irqsave(&phba->hbalock, flags); 1915 + spin_lock(&phba->hbalock); 1900 1916 /* driver queued commands are in process of being flushed */ 1901 1917 if (phba->hba_flag & HBA_IOQ_FLUSH) { 1902 - spin_unlock_irqrestore(&phba->hbalock, flags); 1918 + spin_unlock(&phba->hbalock); 1919 + spin_unlock_irqrestore(&lpfc_nbuf->buf_lock, flags); 1903 1920 lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1904 1921 "6139 Driver in reset cleanup - flushing " 1905 1922 "NVME Req now. hba_flag x%x\n", ··· 1924 1907 return; 1925 1908 } 1926 1909 1927 - lpfc_nbuf = freqpriv->nvme_buf; 1928 - if (!lpfc_nbuf) { 1929 - spin_unlock_irqrestore(&phba->hbalock, flags); 1930 - lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1931 - "6140 NVME IO req has no matching lpfc nvme " 1932 - "io buffer. Skipping abort req.\n"); 1933 - return; 1934 - } else if (!lpfc_nbuf->nvmeCmd) { 1935 - spin_unlock_irqrestore(&phba->hbalock, flags); 1936 - lpfc_printf_vlog(vport, KERN_ERR, LOG_TRACE_EVENT, 1937 - "6141 lpfc NVME IO req has no nvme_fcreq " 1938 - "io buffer. Skipping abort req.\n"); 1939 - return; 1940 - } 1941 1910 nvmereq_wqe = &lpfc_nbuf->cur_iocbq; 1942 - 1943 - /* Guard against IO completion being called at same time */ 1944 - spin_lock(&lpfc_nbuf->buf_lock); 1945 1911 1946 1912 /* 1947 1913 * The lpfc_nbuf and the mapped nvme_fcreq in the driver's ··· 1971 1971 ret_val = lpfc_sli4_issue_abort_iotag(phba, nvmereq_wqe, 1972 1972 lpfc_nvme_abort_fcreq_cmpl); 1973 1973 1974 - spin_unlock(&lpfc_nbuf->buf_lock); 1975 - spin_unlock_irqrestore(&phba->hbalock, flags); 1974 + spin_unlock(&phba->hbalock); 1975 + spin_unlock_irqrestore(&lpfc_nbuf->buf_lock, flags); 1976 1976 1977 1977 /* Make sure HBA is alive */ 1978 1978 lpfc_issue_hb_tmo(phba); ··· 1998 1998 return; 1999 1999 2000 2000 out_unlock: 2001 - spin_unlock(&lpfc_nbuf->buf_lock); 2002 - spin_unlock_irqrestore(&phba->hbalock, flags); 2001 + spin_unlock(&phba->hbalock); 2002 + spin_unlock_irqrestore(&lpfc_nbuf->buf_lock, flags); 2003 2003 return; 2004 2004 } 2005 2005