Commit fe2043d1 authored by Saurav Kashyap's avatar Saurav Kashyap Committed by Martin K. Petersen

scsi: qedf: Correctly handle refcounting of rdata

 - Handle refcount of rdata during error conditions.
Signed-off-by: default avatarSaurav Kashyap <skashyap@marvell.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent faea5719
...@@ -2241,7 +2241,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2241,7 +2241,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
unsigned long flags; unsigned long flags;
struct fcoe_wqe *sqe; struct fcoe_wqe *sqe;
u16 sqe_idx; u16 sqe_idx;
struct fc_rport_priv *rdata = fcport->rdata;
if (!sc_cmd) { if (!sc_cmd) {
QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n"); QEDF_ERR(&(qedf->dbg_ctx), "invalid arg\n");
...@@ -2252,22 +2251,14 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2252,22 +2251,14 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) { if (!test_bit(QEDF_RPORT_SESSION_READY, &fcport->flags)) {
QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n"); QEDF_ERR(&(qedf->dbg_ctx), "fcport not offloaded\n");
rc = FAILED; rc = FAILED;
return FAILED; goto no_flush;
}
if (!rdata || !kref_get_unless_zero(&rdata->kref)) {
QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM, "stale rport\n");
return FAILED;
} }
QEDF_INFO(&qedf->dbg_ctx, QEDF_LOG_SCSI_TM,
"portid = 0x%x tm_flags = %d\n",
rdata->ids.port_id, tm_flags);
io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD); io_req = qedf_alloc_cmd(fcport, QEDF_TASK_MGMT_CMD);
if (!io_req) { if (!io_req) {
QEDF_ERR(&(qedf->dbg_ctx), "Failed TMF"); QEDF_ERR(&(qedf->dbg_ctx), "Failed TMF");
rc = -EAGAIN; rc = -EAGAIN;
goto reset_tmf_err; goto no_flush;
} }
if (tm_flags == FCP_TMF_LUN_RESET) if (tm_flags == FCP_TMF_LUN_RESET)
...@@ -2356,8 +2347,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd, ...@@ -2356,8 +2347,6 @@ static int qedf_execute_tmf(struct qedf_rport *fcport, struct scsi_cmnd *sc_cmd,
QEDF_ERR(&(qedf->dbg_ctx), "task mgmt command success...\n"); QEDF_ERR(&(qedf->dbg_ctx), "task mgmt command success...\n");
rc = SUCCESS; rc = SUCCESS;
} }
reset_tmf_err:
kref_put(&rdata->kref, fc_rport_destroy);
return rc; return rc;
} }
...@@ -2405,7 +2394,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -2405,7 +2394,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
rc = fc_block_scsi_eh(sc_cmd); rc = fc_block_scsi_eh(sc_cmd);
if (rc) if (rc)
return rc; goto tmf_err;
if (!fcport) { if (!fcport) {
QEDF_ERR(NULL, "device_reset: rport is NULL\n"); QEDF_ERR(NULL, "device_reset: rport is NULL\n");
...@@ -2442,7 +2431,13 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -2442,7 +2431,13 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
} }
if (test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) { if (test_bit(QEDF_RPORT_UPLOADING_CONNECTION, &fcport->flags)) {
QEDF_ERR(&qedf->dbg_ctx, "fcport is uploading.\n"); if (!fcport->rdata)
QEDF_ERR(&qedf->dbg_ctx, "fcport %p is uploading.\n",
fcport);
else
QEDF_ERR(&qedf->dbg_ctx,
"fcport %p port_id=%06x is uploading.\n",
fcport, fcport->rdata->ids.port_id);
rc = FAILED; rc = FAILED;
goto tmf_err; goto tmf_err;
} }
...@@ -2450,6 +2445,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags) ...@@ -2450,6 +2445,7 @@ int qedf_initiate_tmf(struct scsi_cmnd *sc_cmd, u8 tm_flags)
rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags); rc = qedf_execute_tmf(fcport, sc_cmd, tm_flags);
tmf_err: tmf_err:
kref_put(&rdata->kref, fc_rport_destroy);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment