@@ -1267,10 +1267,7 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
1267
1267
1268
1268
/*
1269
1269
* 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.
1274
1271
*/
1275
1272
1276
1273
spin_lock_irqsave (& ioctx -> spinlock , flags );
@@ -1279,64 +1276,51 @@ static int srpt_abort_cmd(struct srpt_send_ioctx *ioctx)
1279
1276
case SRPT_STATE_NEED_DATA :
1280
1277
ioctx -> state = SRPT_STATE_DATA_IN ;
1281
1278
break ;
1282
- case SRPT_STATE_DATA_IN :
1283
1279
case SRPT_STATE_CMD_RSP_SENT :
1284
1280
case SRPT_STATE_MGMT_RSP_SENT :
1285
1281
ioctx -> state = SRPT_STATE_DONE ;
1286
1282
break ;
1287
1283
default :
1284
+ WARN_ONCE (true, "%s: unexpected I/O context state %d\n" ,
1285
+ __func__ , state );
1288
1286
break ;
1289
1287
}
1290
1288
spin_unlock_irqrestore (& ioctx -> spinlock , flags );
1291
1289
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
-
1301
1290
pr_debug ("Aborting cmd with state %d and tag %lld\n" , state ,
1302
1291
ioctx -> cmd .tag );
1303
1292
1304
1293
switch (state ) {
1305
1294
case SRPT_STATE_NEW :
1306
1295
case SRPT_STATE_DATA_IN :
1307
1296
case SRPT_STATE_MGMT :
1297
+ case SRPT_STATE_DONE :
1308
1298
/*
1309
1299
* Do nothing - defer abort processing until
1310
1300
* srpt_queue_response() is invoked.
1311
1301
*/
1312
- WARN_ON (!transport_check_aborted_status (& ioctx -> cmd , false));
1313
1302
break ;
1314
1303
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 );
1321
1307
break ;
1322
1308
case SRPT_STATE_CMD_RSP_SENT :
1323
1309
/*
1324
1310
* SRP_RSP sending failed or the SRP_RSP send completion has
1325
1311
* not been received in time.
1326
1312
*/
1327
1313
srpt_unmap_sg_to_ib_sge (ioctx -> ch , ioctx );
1328
- target_put_sess_cmd (& ioctx -> cmd );
1314
+ transport_generic_free_cmd (& ioctx -> cmd , 0 );
1329
1315
break ;
1330
1316
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 );
1333
1318
break ;
1334
1319
default :
1335
1320
WARN (1 , "Unexpected command state (%d)" , state );
1336
1321
break ;
1337
1322
}
1338
1323
1339
- out :
1340
1324
return state ;
1341
1325
}
1342
1326
@@ -1376,9 +1360,14 @@ static void srpt_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)
1376
1360
container_of (wc -> wr_cqe , struct srpt_send_ioctx , rdma_cqe );
1377
1361
1378
1362
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
+ */
1379
1369
pr_info ("RDMA_WRITE for ioctx 0x%p failed with status %d\n" ,
1380
1370
ioctx , wc -> status );
1381
- srpt_abort_cmd (ioctx );
1382
1371
}
1383
1372
}
1384
1373
@@ -1721,15 +1710,10 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)
1721
1710
1722
1711
atomic_inc (& ch -> sq_wr_avail );
1723
1712
1724
- if (wc -> status != IB_WC_SUCCESS ) {
1713
+ if (wc -> status != IB_WC_SUCCESS )
1725
1714
pr_info ("sending response for ioctx 0x%p failed"
1726
1715
" with status %d\n" , ioctx , wc -> status );
1727
1716
1728
- atomic_dec (& ch -> req_lim );
1729
- srpt_abort_cmd (ioctx );
1730
- goto out ;
1731
- }
1732
-
1733
1717
if (state != SRPT_STATE_DONE ) {
1734
1718
srpt_unmap_sg_to_ib_sge (ch , ioctx );
1735
1719
transport_generic_free_cmd (& ioctx -> cmd , 0 );
@@ -1738,7 +1722,6 @@ static void srpt_send_done(struct ib_cq *cq, struct ib_wc *wc)
1738
1722
" wr_id = %u.\n" , ioctx -> ioctx .index );
1739
1723
}
1740
1724
1741
- out :
1742
1725
while (!list_empty (& ch -> cmd_wait_list ) &&
1743
1726
ch -> state == CH_LIVE &&
1744
1727
(ioctx = srpt_get_send_ioctx (ch )) != NULL ) {
0 commit comments