Skip to content
Permalink
Browse files
Change the return type of fc_remote_port_chkready() into union scsi_s…
…tatus

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
  • Loading branch information
bvanassche committed Apr 14, 2021
1 parent 96c909d commit d8044d773ae9d9e70f9c61f98296c6c8391447ad
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 83 deletions.
@@ -192,35 +192,35 @@ mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
struct Scsi_Host *shost = sdev->host;
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
unsigned long flags;
int ready;
union scsi_status ready;
MPT_ADAPTER *ioc;
int loops = 40; /* seconds */

hd = shost_priv(SCpnt->device->host);
ioc = hd->ioc;
spin_lock_irqsave(shost->host_lock, flags);
while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY
while ((ready = fc_remote_port_chkready(rport)).b.host == DID_IMM_RETRY
|| (loops > 0 && ioc->active == 0)) {
spin_unlock_irqrestore(shost->host_lock, flags);
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"mptfc_block_error_handler.%d: %d:%llu, port status is "
"%x, active flag %d, deferring %s recovery.\n",
ioc->name, ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun,
ready, ioc->active, caller));
ready.combined, ioc->active, caller));
msleep(1000);
spin_lock_irqsave(shost->host_lock, flags);
loops --;
}
spin_unlock_irqrestore(shost->host_lock, flags);

if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata
if (ready.b.host == DID_NO_CONNECT || !SCpnt->device->hostdata
|| ioc->active == 0) {
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%llu, failing recovery, "
"port state %x, active %d, vdevice %p.\n", caller,
ioc->name, ioc->sh->host_no,
SCpnt->device->id, SCpnt->device->lun, ready,
SCpnt->device->id, SCpnt->device->lun, ready.combined,
ioc->active, SCpnt->device->hostdata));
return FAILED;
}
@@ -606,7 +606,7 @@ mptfc_slave_alloc(struct scsi_device *sdev)
starget = scsi_target(sdev);
rport = starget_to_rport(starget);

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

hd = shost_priv(sdev->host);
@@ -644,7 +644,7 @@ mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt)
{
struct mptfc_rport_info *ri;
struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
int err;
union scsi_status err;
VirtDevice *vdevice = SCpnt->device->hostdata;

if (!vdevice || !vdevice->vtarget) {
@@ -654,8 +654,8 @@ mptfc_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *SCpnt)
}

err = fc_remote_port_chkready(rport);
if (unlikely(err)) {
SCpnt->result.combined = err;
if (unlikely(err.combined)) {
SCpnt->result = err;
SCpnt->scsi_done(SCpnt);
return 0;
}
@@ -68,15 +68,16 @@ int zfcp_scsi_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scpnt)
{
struct zfcp_scsi_dev *zfcp_sdev = sdev_to_zfcp(scpnt->device);
struct fc_rport *rport = starget_to_rport(scsi_target(scpnt->device));
int status, scsi_result, ret;
int status, ret;
union scsi_status port_ready;

/* reset the status for this request */
scpnt->result.combined = 0;
scpnt->host_scribble = NULL;

scsi_result = fc_remote_port_chkready(rport);
if (unlikely(scsi_result)) {
scpnt->result.combined = scsi_result;
port_ready = fc_remote_port_chkready(rport);
if (unlikely(port_ready.combined)) {
scpnt->result = port_ready;
zfcp_dbf_scsi_fail_send(scpnt);
scpnt->scsi_done(scpnt);
return 0;
@@ -956,7 +956,7 @@ bfad_im_slave_alloc(struct scsi_device *sdev)
struct bfad_itnim_data_s *itnim_data;
struct bfa_s *bfa;

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

itnim_data = (struct bfad_itnim_data_s *) rport->dd_data;
@@ -1209,13 +1209,13 @@ bfad_im_queuecommand_lck(struct scsi_cmnd *cmnd, void (*done) (struct scsi_cmnd
struct bfad_itnim_s *itnim;
struct bfa_ioim_s *hal_io;
unsigned long flags;
int rc;
union scsi_status port_ready;
int sg_cnt = 0;
struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));

rc = fc_remote_port_chkready(rport);
if (rc) {
cmnd->result.combined = rc;
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
cmnd->result = port_ready;
done(cmnd);
return 0;
}
@@ -682,12 +682,13 @@ static int bnx2fc_initiate_els(struct bnx2fc_rport *tgt, unsigned int op,
struct fcoe_task_ctx_entry *task;
struct fcoe_task_ctx_entry *task_page;
int rc = 0;
union scsi_status port_ready;
int task_idx, index;
u32 did, sid;
u16 xid;

rc = fc_remote_port_chkready(rport);
if (rc) {
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
printk(KERN_ERR PFX "els 0x%x: rport not ready\n", op);
rc = -EINVAL;
goto els_err;
@@ -1847,11 +1847,11 @@ int bnx2fc_queuecommand(struct Scsi_Host *host,
struct bnx2fc_rport *tgt;
struct bnx2fc_cmd *io_req;
int rc = 0;
int rval;
union scsi_status port_ready;

rval = fc_remote_port_chkready(rport);
if (rval) {
sc_cmd->result.combined = rval;
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
sc_cmd->result = port_ready;
sc_cmd->scsi_done(sc_cmd);
return 0;
}
@@ -1781,16 +1781,17 @@ csio_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmnd)
struct csio_ioreq *ioreq = NULL;
unsigned long flags;
int nsge = 0;
int rv = SCSI_MLQUEUE_HOST_BUSY, nr;
int rv = SCSI_MLQUEUE_HOST_BUSY;
union scsi_status port_ready;
int retval;
struct csio_scsi_qset *sqset;
struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));

sqset = &hw->sqset[ln->portid][blk_mq_rq_cpu(cmnd->request)];

nr = fc_remote_port_chkready(rport);
if (nr) {
cmnd->result.combined = nr;
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
cmnd->result = port_ready;
CSIO_INC_STATS(scsim, n_rn_nr_error);
goto err_done;
}
@@ -2095,7 +2096,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
* the former case, since LUN reset is a TMF I/O on the wire, and we
* need a valid session to issue it.
*/
if (fc_remote_port_chkready(rn->rport)) {
if (fc_remote_port_chkready(rn->rport).combined) {
csio_err(hw,
"LUN reset cannot be issued on non-ready"
" remote node ssni:0x%x (LUN:%llu)\n",
@@ -2223,7 +2224,7 @@ csio_slave_alloc(struct scsi_device *sdev)
{
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

sdev->hostdata = *((struct csio_lnode **)(rport->dd_data));
@@ -100,7 +100,7 @@ static int fnic_slave_alloc(struct scsi_device *sdev)
{
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

scsi_change_queue_depth(sdev, fnic_max_qdepth);
@@ -428,7 +428,7 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
struct fnic *fnic = lport_priv(lp);
struct fnic_stats *fnic_stats = &fnic->fnic_stats;
struct vnic_wq_copy *wq;
int ret;
union scsi_status port_ready;
u64 cmd_trace;
int sg_count = 0;
unsigned long flags = 0;
@@ -452,12 +452,12 @@ static int fnic_queuecommand_lck(struct scsi_cmnd *sc, void (*done)(struct scsi_
return 0;
}

ret = fc_remote_port_chkready(rport);
if (ret) {
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
"rport is not ready\n");
atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
sc->result.combined = ret;
sc->result = port_ready;
done(sc);
return 0;
}
@@ -1938,7 +1938,7 @@ int fnic_abort_cmd(struct scsi_cmnd *sc)
* port is up, then send abts to the remote port to terminate
* the IO. Else, just locally terminate the IO in the firmware
*/
if (fc_remote_port_chkready(rport) == 0)
if (fc_remote_port_chkready(rport).combined == 0)
task_req = FCPIO_ITMF_ABT_TASK;
else {
atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
@@ -2364,7 +2364,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
goto fnic_device_reset_end;

/* Check if remote port up */
if (fc_remote_port_chkready(rport)) {
if (fc_remote_port_chkready(rport).combined) {
atomic64_inc(&fnic_stats->misc_stats.rport_not_ready);
goto fnic_device_reset_end;
}
@@ -1841,25 +1841,25 @@ static void ibmvfc_scsi_done(struct ibmvfc_event *evt)
* @vhost: struct ibmvfc host
*
* Returns:
* 1 if host can accept command / 0 if not
* 0 if host can accept command; a value != 0 if not
**/
static inline int ibmvfc_host_chkready(struct ibmvfc_host *vhost)
static inline union scsi_status ibmvfc_host_chkready(struct ibmvfc_host *vhost)
{
int result = 0;
union scsi_status result = { };

switch (vhost->state) {
case IBMVFC_LINK_DEAD:
case IBMVFC_HOST_OFFLINE:
result = DID_NO_CONNECT << 16;
result.combined = DID_NO_CONNECT << 16;
break;
case IBMVFC_NO_CRQ:
case IBMVFC_INITIALIZING:
case IBMVFC_HALTED:
case IBMVFC_LINK_DOWN:
result = DID_REQUEUE << 16;
result.combined = DID_REQUEUE << 16;
break;
case IBMVFC_ACTIVE:
result = 0;
result.combined = 0;
break;
}

@@ -1911,11 +1911,11 @@ static int ibmvfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
u32 tag_and_hwq = blk_mq_unique_tag(cmnd->request);
u16 hwq = blk_mq_unique_tag_to_hwq(tag_and_hwq);
u16 scsi_channel;
int rc;
union scsi_status rc;

if (unlikely((rc = fc_remote_port_chkready(rport))) ||
unlikely((rc = ibmvfc_host_chkready(vhost)))) {
cmnd->result.combined = rc;
cmnd->result = rc;
cmnd->scsi_done(cmnd);
return 0;
}
@@ -2183,8 +2183,10 @@ static int ibmvfc_bsg_request(struct bsg_job *job)

spin_lock_irqsave(vhost->host->host_lock, flags);

if (unlikely(rc || (rport && (rc = fc_remote_port_chkready(rport)))) ||
unlikely((rc = ibmvfc_host_chkready(vhost)))) {
if (unlikely(rc ||
(rport &&
(rc = fc_remote_port_chkready(rport).combined))) ||
unlikely((rc = ibmvfc_host_chkready(vhost).combined))) {
spin_unlock_irqrestore(vhost->host->host_lock, flags);
goto out;
}
@@ -1863,13 +1863,13 @@ int fc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *sc_cmd)
struct fc_lport *lport = shost_priv(shost);
struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
struct fc_fcp_pkt *fsp;
int rval;
int rc = 0;
union scsi_status port_ready;
int rval, rc = 0;
struct fc_stats *stats;

rval = fc_remote_port_chkready(rport);
if (rval) {
sc_cmd->result.combined = rval;
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
sc_cmd->result = port_ready;
sc_cmd->scsi_done(sc_cmd);
return 0;
}
@@ -2239,7 +2239,7 @@ int fc_slave_alloc(struct scsi_device *sdev)
{
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

scsi_change_queue_depth(sdev, FC_FCP_DFLT_QUEUE_DEPTH);
@@ -5167,7 +5167,8 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
struct lpfc_nodelist *ndlp;
struct lpfc_io_buf *lpfc_cmd;
struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
int err, idx;
union scsi_status port_ready;
int idx;
#ifdef CONFIG_SCSI_LPFC_DEBUG_FS
uint64_t start = 0L;

@@ -5181,9 +5182,9 @@ lpfc_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *cmnd)
if (unlikely(!rdata) || unlikely(!rport))
goto out_fail_command;

err = fc_remote_port_chkready(rport);
if (err) {
cmnd->result.combined = err;
port_ready = fc_remote_port_chkready(rport);
if (port_ready.combined) {
cmnd->result = port_ready;
goto out_fail_command;
}
ndlp = rdata->pnode;
@@ -6196,7 +6197,7 @@ lpfc_slave_alloc(struct scsi_device *sdev)
unsigned long flags;
struct lpfc_name target_wwpn;

if (!rport || fc_remote_port_chkready(rport))
if (!rport || fc_remote_port_chkready(rport).combined)
return -ENXIO;

if (phba->cfg_fof) {
@@ -35,7 +35,7 @@ static int qedf_initiate_els(struct qedf_rport *fcport, unsigned int op,

QEDF_INFO(&(qedf->dbg_ctx), QEDF_LOG_ELS, "Sending ELS\n");

rc = fc_remote_port_chkready(fcport->rport);
rc = fc_remote_port_chkready(fcport->rport).combined;
if (rc) {
QEDF_ERR(&(qedf->dbg_ctx), "els 0x%x: rport not ready\n", op);
rc = -EAGAIN;

0 comments on commit d8044d7

Please sign in to comment.