Skip to content

Commit 0e0d3a4

Browse files
Bart Van Asschedledford
authored andcommitted
IB/srp: Remove the memory registration backtracking code
Mapping a discontiguous sg-list requires multiple memory regions and hence can exhaust the memory region pool. The SRP initiator already handles this by temporarily reducing the queue depth. This means that it is safe to remove the memory registration backtracking code. This patch has been tested with direct I/O sizes up to 256 MB. Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent f731ed6 commit 0e0d3a4

File tree

2 files changed

+13
-55
lines changed

2 files changed

+13
-55
lines changed

drivers/infiniband/ulp/srp/ib_srp.c

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,15 +1364,6 @@ static int srp_finish_mapping(struct srp_map_state *state,
13641364
return ret;
13651365
}
13661366

1367-
static void srp_map_update_start(struct srp_map_state *state,
1368-
struct scatterlist *sg, int sg_index,
1369-
dma_addr_t dma_addr)
1370-
{
1371-
state->unmapped_sg = sg;
1372-
state->unmapped_index = sg_index;
1373-
state->unmapped_addr = dma_addr;
1374-
}
1375-
13761367
static int srp_map_sg_entry(struct srp_map_state *state,
13771368
struct srp_rdma_ch *ch,
13781369
struct scatterlist *sg, int sg_index,
@@ -1399,23 +1390,12 @@ static int srp_map_sg_entry(struct srp_map_state *state,
13991390
return 0;
14001391
}
14011392

1402-
/*
1403-
* If this is the first sg that will be mapped via FMR or via FR, save
1404-
* our position. We need to know the first unmapped entry, its index,
1405-
* and the first unmapped address within that entry to be able to
1406-
* restart mapping after an error.
1407-
*/
1408-
if (!state->unmapped_sg)
1409-
srp_map_update_start(state, sg, sg_index, dma_addr);
1410-
14111393
while (dma_len) {
14121394
unsigned offset = dma_addr & ~dev->mr_page_mask;
14131395
if (state->npages == dev->max_pages_per_mr || offset != 0) {
14141396
ret = srp_finish_mapping(state, ch);
14151397
if (ret)
14161398
return ret;
1417-
1418-
srp_map_update_start(state, sg, sg_index, dma_addr);
14191399
}
14201400

14211401
len = min_t(unsigned int, dma_len, dev->mr_page_size - offset);
@@ -1434,11 +1414,8 @@ static int srp_map_sg_entry(struct srp_map_state *state,
14341414
* boundries.
14351415
*/
14361416
ret = 0;
1437-
if (len != dev->mr_page_size) {
1417+
if (len != dev->mr_page_size)
14381418
ret = srp_finish_mapping(state, ch);
1439-
if (!ret)
1440-
srp_map_update_start(state, NULL, 0, 0);
1441-
}
14421419
return ret;
14431420
}
14441421

@@ -1448,9 +1425,8 @@ static int srp_map_sg(struct srp_map_state *state, struct srp_rdma_ch *ch,
14481425
{
14491426
struct srp_target_port *target = ch->target;
14501427
struct srp_device *dev = target->srp_host->srp_dev;
1451-
struct ib_device *ibdev = dev->dev;
14521428
struct scatterlist *sg;
1453-
int i;
1429+
int i, ret;
14541430
bool use_mr;
14551431

14561432
state->desc = req->indirect_desc;
@@ -1466,34 +1442,22 @@ static int srp_map_sg(struct srp_map_state *state, struct srp_rdma_ch *ch,
14661442
}
14671443

14681444
for_each_sg(scat, sg, count, i) {
1469-
if (srp_map_sg_entry(state, ch, sg, i, use_mr)) {
1470-
/*
1471-
* Memory registration failed, so backtrack to the
1472-
* first unmapped entry and continue on without using
1473-
* memory registration.
1474-
*/
1475-
dma_addr_t dma_addr;
1476-
unsigned int dma_len;
1477-
1478-
backtrack:
1479-
sg = state->unmapped_sg;
1480-
i = state->unmapped_index;
1481-
1482-
dma_addr = ib_sg_dma_address(ibdev, sg);
1483-
dma_len = ib_sg_dma_len(ibdev, sg);
1484-
dma_len -= (state->unmapped_addr - dma_addr);
1485-
dma_addr = state->unmapped_addr;
1486-
use_mr = false;
1487-
srp_map_desc(state, dma_addr, dma_len, target->rkey);
1488-
}
1445+
ret = srp_map_sg_entry(state, ch, sg, i, use_mr);
1446+
if (ret)
1447+
goto out;
14891448
}
14901449

1491-
if (use_mr && srp_finish_mapping(state, ch))
1492-
goto backtrack;
1450+
if (use_mr) {
1451+
ret = srp_finish_mapping(state, ch);
1452+
if (ret)
1453+
goto out;
1454+
}
14931455

14941456
req->nmdesc = state->nmdesc;
1457+
ret = 0;
14951458

1496-
return 0;
1459+
out:
1460+
return ret;
14971461
}
14981462

14991463
static int srp_map_data(struct scsi_cmnd *scmnd, struct srp_rdma_ch *ch,

drivers/infiniband/ulp/srp/ib_srp.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ struct srp_fr_pool {
276276
* @npages: Number of page addresses in the pages[] array.
277277
* @nmdesc: Number of FMR or FR memory descriptors used for mapping.
278278
* @ndesc: Number of SRP buffer descriptors that have been filled in.
279-
* @unmapped_sg: First element of the sg-list that is mapped via FMR or FR.
280-
* @unmapped_index: Index of the first element mapped via FMR or FR.
281-
* @unmapped_addr: DMA address of the first element mapped via FMR or FR.
282279
*/
283280
struct srp_map_state {
284281
union {
@@ -299,9 +296,6 @@ struct srp_map_state {
299296
unsigned int npages;
300297
unsigned int nmdesc;
301298
unsigned int ndesc;
302-
struct scatterlist *unmapped_sg;
303-
int unmapped_index;
304-
dma_addr_t unmapped_addr;
305299
};
306300

307301
#endif /* IB_SRP_H */

0 commit comments

Comments
 (0)