struct lpfc_scsi_buf *lpfc_cmd = NULL; struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list; struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; struct lpfc_iocbq *iocbq, *iocbqrsp = NULL; 
struct lpfc_scsi_buf *lpfc_cmd; struct lpfc_iocbq *iocbq, *iocbqrsp; 
__lpfc_reset_lun_handler(struct scsi_cmnd *cmnd){	struct Scsi_Host *shost = cmnd->device->host;	struct lpfc_hba *phba = (struct lpfc_hba *)shost->hostdata[0];	struct lpfc_scsi_buf *lpfc_cmd = NULL;	struct list_head *scsi_buf_list = &phba->lpfc_scsi_buf_list;	struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list;	struct lpfc_iocbq *iocbq, *iocbqrsp = NULL;	struct lpfc_rport_data *rdata = cmnd->device->hostdata;	struct lpfc_nodelist *pnode = rdata->pnode;	int ret = FAILED;	int cnt, loopcnt;	/*	 * If target is not in a MAPPED state, delay the reset until	 * target is rediscovered or nodev timeout expires.	 */	while ( 1 ) {		if (!pnode)			break;		if (pnode->nlp_state != NLP_STE_MAPPED_NODE) {			spin_unlock_irq(phba->host->host_lock);			set_current_state(TASK_UNINTERRUPTIBLE);			schedule_timeout( HZ/2);			spin_lock_irq(phba->host->host_lock);		}		if ((pnode) && (pnode->nlp_state == NLP_STE_MAPPED_NODE))			break;	}	list_remove_head(scsi_buf_list, lpfc_cmd, struct lpfc_scsi_buf, list);	if (lpfc_cmd == NULL)		goto out;	lpfc_cmd->pCmd = cmnd;	lpfc_cmd->timeout = 60;	lpfc_cmd->scsi_hba = phba;	ret = lpfc_scsi_prep_task_mgmt_cmd(phba, lpfc_cmd, FCP_LUN_RESET);	if (!ret)		goto out_free_scsi_buf;	iocbq = &lpfc_cmd->cur_iocbq;	/* get a buffer for this IOCB command response */	list_remove_head(lpfc_iocb_list, iocbqrsp, struct lpfc_iocbq, list);	if (iocbqrsp == NULL)		goto out_free_scsi_buf;	ret = lpfc_sli_issue_iocb_wait(phba,				       &phba->sli.ring[phba->sli.fcp_ring],				       iocbq, iocbqrsp, lpfc_cmd->timeout);	if (ret == IOCB_SUCCESS)		ret = SUCCESS;	lpfc_cmd->result = iocbqrsp->iocb.un.ulpWord[4];	lpfc_cmd->status = iocbqrsp->iocb.ulpStatus;	if (lpfc_cmd->status == IOSTAT_LOCAL_REJECT)		if (lpfc_cmd->result & IOERR_DRVR_MASK)			lpfc_cmd->status = IOSTAT_DRIVER_REJECT;	/*	 * All outstanding txcmplq I/Os should have been aborted by the target.	 * Unfortunately, some targets do not abide by this forcing the driver	 * to double check.	 */	lpfc_sli_abort_iocb(phba, &phba->sli.ring[phba->sli.fcp_ring],			    cmnd->device->id, cmnd->device->lun, 0,			    LPFC_CTX_LUN);	loopcnt = 0;	while((cnt = lpfc_sli_sum_iocb(phba,				       &phba->sli.ring[phba->sli.fcp_ring],				       cmnd->device->id, cmnd->device->lun,				       LPFC_CTX_LUN))) {		spin_unlock_irq(phba->host->host_lock);		set_current_state(TASK_UNINTERRUPTIBLE);		schedule_timeout(LPFC_RESET_WAIT*HZ);		spin_lock_irq(phba->host->host_lock);		if (++loopcnt		    > (2 * phba->cfg_nodev_tmo)/LPFC_RESET_WAIT)			break;	}	if (cnt) {		lpfc_printf_log(phba, KERN_INFO, LOG_FCP,			"%d:0719 LUN Reset I/O flush failure: cnt x%x\n",			phba->brd_no, cnt);	}	lpfc_sli_release_iocbq(phba, iocbqrsp);out_free_scsi_buf:	lpfc_printf_log(phba, KERN_ERR, LOG_FCP,			"%d:0713 SCSI layer issued LUN reset (%d, %d) "			"Data: x%x x%x x%x\n",			phba->brd_no, lpfc_cmd->pCmd->device->id,			lpfc_cmd->pCmd->device->lun, ret, lpfc_cmd->status,			lpfc_cmd->result);	lpfc_free_scsi_buf(lpfc_cmd);out:	return ret;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0bd4ca25ad2ace4aa717c83dbd4ed21c53c953cb/lpfc_scsi.c/buggy/drivers/scsi/lpfc/lpfc_scsi.c