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

[SCSI] qla2xxx: Drop srb reference before waiting for completion.

This patch fixes a regression introduced by commit
083a469db4ecf3b286a96b5b722c37fc1affe0be

qla2xxx_eh_wait_on_command() is waiting for an srb to
complete, which will never happen as the routine took
a reference to the srb previously and will only drop it
after this function. So every command abort will fail.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: Madhuranath Iyengar <Madhu.Iyengar@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>

authored by

Mike Christie and committed by
James Bottomley
170babc3 e30d1756

+21 -42
+21 -42
drivers/scsi/qla2xxx/qla_os.c
··· 830 830 { 831 831 scsi_qla_host_t *vha = shost_priv(cmd->device->host); 832 832 srb_t *sp; 833 - int ret, i; 833 + int ret; 834 834 unsigned int id, lun; 835 835 unsigned long flags; 836 836 int wait = 0; 837 837 struct qla_hw_data *ha = vha->hw; 838 - struct req_que *req = vha->req; 839 - srb_t *spt; 840 - int got_ref = 0; 841 838 842 839 fc_block_scsi_eh(cmd); 843 840 844 841 if (!CMD_SP(cmd)) 845 842 return SUCCESS; 846 843 847 - ret = SUCCESS; 848 - 849 844 id = cmd->device->id; 850 845 lun = cmd->device->lun; 851 - spt = (srb_t *) CMD_SP(cmd); 852 - if (!spt) 853 - return SUCCESS; 854 846 855 - /* Check active list for command command. */ 856 847 spin_lock_irqsave(&ha->hardware_lock, flags); 857 - for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { 858 - sp = req->outstanding_cmds[i]; 859 - 860 - if (sp == NULL) 861 - continue; 862 - if ((sp->ctx) && !(sp->flags & SRB_FCP_CMND_DMA_VALID) && 863 - !IS_PROT_IO(sp)) 864 - continue; 865 - if (sp->cmd != cmd) 866 - continue; 867 - 868 - DEBUG2(printk("%s(%ld): aborting sp %p from RISC.", 869 - __func__, vha->host_no, sp)); 870 - 871 - /* Get a reference to the sp and drop the lock.*/ 872 - sp_get(sp); 873 - got_ref++; 874 - 848 + sp = (srb_t *) CMD_SP(cmd); 849 + if (!sp) { 875 850 spin_unlock_irqrestore(&ha->hardware_lock, flags); 876 - if (ha->isp_ops->abort_command(sp)) { 877 - DEBUG2(printk("%s(%ld): abort_command " 878 - "mbx failed.\n", __func__, vha->host_no)); 879 - ret = FAILED; 880 - } else { 881 - DEBUG3(printk("%s(%ld): abort_command " 882 - "mbx success.\n", __func__, vha->host_no)); 883 - wait = 1; 884 - } 885 - spin_lock_irqsave(&ha->hardware_lock, flags); 886 - break; 851 + return SUCCESS; 887 852 } 853 + 854 + DEBUG2(printk("%s(%ld): aborting sp %p from RISC.", 855 + __func__, vha->host_no, sp)); 856 + 857 + /* Get a reference to the sp and drop the lock.*/ 858 + sp_get(sp); 859 + 888 860 spin_unlock_irqrestore(&ha->hardware_lock, flags); 861 + if (ha->isp_ops->abort_command(sp)) { 862 + DEBUG2(printk("%s(%ld): abort_command " 863 + "mbx failed.\n", __func__, vha->host_no)); 864 + ret = FAILED; 865 + } else { 866 + DEBUG3(printk("%s(%ld): abort_command " 867 + "mbx success.\n", __func__, vha->host_no)); 868 + wait = 1; 869 + } 870 + qla2x00_sp_compl(ha, sp); 889 871 890 872 /* Wait for the command to be returned. */ 891 873 if (wait) { ··· 878 896 ret = FAILED; 879 897 } 880 898 } 881 - 882 - if (got_ref) 883 - qla2x00_sp_compl(ha, sp); 884 899 885 900 qla_printk(KERN_INFO, ha, 886 901 "scsi(%ld:%d:%d): Abort command issued -- %d %x.\n",