Skip to content

Commit 49f4016

Browse files
Bart Van Asschedledford
authored andcommitted
IB/srpt: Fix how aborted commands are processed
srpt_abort_cmd() must not be called in state SRPT_STATE_DATA_IN. Issue a warning if this occurs. srpt_abort_cmd() must not invoke target_put_sess_cmd() for commands in state SRPT_STATE_DONE because the srpt_abort_cmd() callers already do this when necessary. Hence remove this call. If an RDMA read fails the corresponding SCSI command must fail. Hence add a transport_generic_request_failure() call. Remove an incorrect srpt_abort_cmd() call from srpt_rdma_write_done(). Avoid that srpt_send_done() calls srpt_abort_cmd() for finished SCSI commands. Signed-off-by: Bart Van Assche <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Reviewed-by: Alex Estrin <[email protected]> Cc: Sagi Grimberg <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 2c7f37f commit 49f4016

File tree

1 file changed

+16
-33
lines changed

1 file changed

+16
-33
lines changed

drivers/infiniband/ulp/srpt/ib_srpt.c

Lines changed: 16 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,10 +1267,7 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
12671267

12681268
/*
12691269
* If the command is in a state where the target core is waiting for
1270-
* the ib_srpt driver, change the state to the next state. Changing
1271-
* the state of the command from SRPT_STATE_NEED_DATA to
1272-
* SRPT_STATE_DATA_IN ensures that srpt_xmit_response() will call this
1273-
* function a second time.
1270+
* the ib_srpt driver, change the state to the next state.
12741271
*/
12751272

12761273
spin_lock_irqsave(&ioctx->spinlock, flags);
@@ -1279,64 +1276,51 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
12791276
case SRPT_STATE_NEED_DATA:
12801277
ioctx->state = SRPT_STATE_DATA_IN;
12811278
break;
1282-
case SRPT_STATE_DATA_IN:
12831279
case SRPT_STATE_CMD_RSP_SENT:
12841280
case SRPT_STATE_MGMT_RSP_SENT:
12851281
ioctx->state = SRPT_STATE_DONE;
12861282
break;
12871283
default:
1284+
WARN_ONCE(true, "%s: unexpected I/O context state %d\n",
1285+
__func__, state);
12881286
break;
12891287
}
12901288
spin_unlock_irqrestore(&ioctx->spinlock, flags);
12911289

1292-
if (state == SRPT_STATE_DONE) {
1293-
struct srpt_rdma_ch *ch = ioctx->ch;
1294-
1295-
BUG_ON(ch->sess == NULL);
1296-
1297-
target_put_sess_cmd(&ioctx->cmd);
1298-
goto out;
1299-
}
1300-
13011290
pr_debug("Aborting cmd with state %d and tag %lld\n", state,
13021291
ioctx->cmd.tag);
13031292

13041293
switch (state) {
13051294
case SRPT_STATE_NEW:
13061295
case SRPT_STATE_DATA_IN:
13071296
case SRPT_STATE_MGMT:
1297+
case SRPT_STATE_DONE:
13081298
/*
13091299
* Do nothing - defer abort processing until
13101300
* srpt_queue_response() is invoked.
13111301
*/
1312-
WARN_ON(!transport_check_aborted_status(&ioctx->cmd, false));
13131302
break;
13141303
case SRPT_STATE_NEED_DATA:
1315-
/* DMA_TO_DEVICE (write) - RDMA read error. */
1316-
1317-
/* XXX(hch): this is a horrible layering violation.. */
1318-
spin_lock_irqsave(&ioctx->cmd.t_state_lock, flags);
1319-
ioctx->cmd.transport_state &= ~CMD_T_ACTIVE;
1320-
spin_unlock_irqrestore(&ioctx->cmd.t_state_lock, flags);
1304+
pr_debug("tag %#llx: RDMA read error\n", ioctx->cmd.tag);
1305+
transport_generic_request_failure(&ioctx->cmd,
1306+
TCM_CHECK_CONDITION_ABORT_CMD);
13211307
break;
13221308
case SRPT_STATE_CMD_RSP_SENT:
13231309
/*
13241310
* SRP_RSP sending failed or the SRP_RSP send completion has
13251311
* not been received in time.
13261312
*/
13271313
srpt_unmap_sg_to_ib_sge(ioctx->ch, ioctx);
1328-
target_put_sess_cmd(&ioctx->cmd);
1314+
transport_generic_free_cmd(&ioctx->cmd, 0);
13291315
break;
13301316
case SRPT_STATE_MGMT_RSP_SENT:
1331-
srpt_set_cmd_state(ioctx, SRPT_STATE_DONE);
1332-
target_put_sess_cmd(&ioctx->cmd);
1317+
transport_generic_free_cmd(&ioctx->cmd, 0);
13331318
break;
13341319
default:
13351320
WARN(1, "Unexpected command state (%d)", state);
13361321
break;
13371322
}
13381323

1339-
out:
13401324
return state;
13411325
}
13421326

@@ -1376,9 +1360,14 @@ static void srpt_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)
13761360
container_of(wc->wr_cqe, struct srpt_send_ioctx, rdma_cqe);
13771361

13781362
if (unlikely(wc->status != IB_WC_SUCCESS)) {
1363+
/*
1364+
* Note: if an RDMA write error completion is received that
1365+
* means that a SEND also has been posted. Defer further
1366+
* processing of the associated command until the send error
1367+
* completion has been received.
1368+
*/
13791369
pr_info("RDMA_WRITE for ioctx 0x%p failed with status %d\n",
13801370
ioctx, wc->status);
1381-
srpt_abort_cmd(ioctx);
13821371
}
13831372
}
13841373

@@ -1721,15 +1710,10 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)
17211710

17221711
atomic_inc(&ch->sq_wr_avail);
17231712

1724-
if (wc->status != IB_WC_SUCCESS) {
1713+
if (wc->status != IB_WC_SUCCESS)
17251714
pr_info("sending response for ioctx 0x%p failed"
17261715
" with status %d\n", ioctx, wc->status);
17271716

1728-
atomic_dec(&ch->req_lim);
1729-
srpt_abort_cmd(ioctx);
1730-
goto out;
1731-
}
1732-
17331717
if (state != SRPT_STATE_DONE) {
17341718
srpt_unmap_sg_to_ib_sge(ch, ioctx);
17351719
transport_generic_free_cmd(&ioctx->cmd, 0);
@@ -1738,7 +1722,6 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)
17381722
" wr_id = %u.\n", ioctx->ioctx.index);
17391723
}
17401724

1741-
out:
17421725
while (!list_empty(&ch->cmd_wait_list) &&
17431726
ch->state == CH_LIVE &&
17441727
(ioctx = srpt_get_send_ioctx(ch)) != NULL) {

0 commit comments

Comments
 (0)