Skip to content

Commit f46d6a8

Browse files
author
Nicholas Bellinger
committed
iser-target: Match FRMR descriptors to available session tags
This patch changes isert_conn_create_fastreg_pool() to follow logic in iscsi_target_locate_portal() for determining how many FRMR descriptors to allocate based upon the number of possible per-session command slots that are available. This addresses an OOPs in isert_reg_rdma() where due to the use of ISCSI_DEF_XMIT_CMDS_MAX could end up returning a bogus fast_reg_descriptor when the number of active tags exceeded the original hardcoded max. Note this also includes moving isert_conn_create_fastreg_pool() from isert_connect_request() to isert_put_login_tx() before posting the final Login Response PDU in order to determine the se_nacl->queue_depth (eg: number of tags) per session the target will be enforcing. v2 changes: - Move isert_conn->conn_fr_pool list_head init into isert_conn_request() v3 changes: - Drop unnecessary list_empty() check in isert_reg_rdma() (Sagi) Cc: Sagi Grimberg <[email protected]> Cc: Or Gerlitz <[email protected]> Cc: <[email protected]> #3.12+ Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent 5bac4b1 commit f46d6a8

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

drivers/infiniband/ulp/isert/ib_isert.c

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -508,11 +508,18 @@ isert_conn_create_fastreg_pool(struct isert_conn *isert_conn, u8 pi_support)
508508
{
509509
struct fast_reg_descriptor *fr_desc;
510510
struct isert_device *device = isert_conn->conn_device;
511-
int i, ret;
511+
struct se_session *se_sess = isert_conn->conn->sess->se_sess;
512+
struct se_node_acl *se_nacl = se_sess->se_node_acl;
513+
int i, ret, tag_num;
514+
/*
515+
* Setup the number of FRMRs based upon the number of tags
516+
* available to session in iscsi_target_locate_portal().
517+
*/
518+
tag_num = max_t(u32, ISCSIT_MIN_TAGS, se_nacl->queue_depth);
519+
tag_num = (tag_num * 2) + ISCSIT_EXTRA_TAGS;
512520

513-
INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
514521
isert_conn->conn_fr_pool_size = 0;
515-
for (i = 0; i < ISCSI_DEF_XMIT_CMDS_MAX; i++) {
522+
for (i = 0; i < tag_num; i++) {
516523
fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL);
517524
if (!fr_desc) {
518525
pr_err("Failed to allocate fast_reg descriptor\n");
@@ -572,6 +579,7 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
572579
kref_get(&isert_conn->conn_kref);
573580
mutex_init(&isert_conn->conn_mutex);
574581
spin_lock_init(&isert_conn->conn_lock);
582+
INIT_LIST_HEAD(&isert_conn->conn_fr_pool);
575583

576584
cma_id->context = isert_conn;
577585
isert_conn->conn_cm_id = cma_id;
@@ -649,15 +657,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
649657
goto out_mr;
650658
}
651659

652-
if (device->use_fastreg) {
653-
ret = isert_conn_create_fastreg_pool(isert_conn, pi_support);
654-
if (ret) {
655-
pr_err("Conn: %p failed to create fastreg pool\n",
656-
isert_conn);
657-
goto out_fastreg;
658-
}
659-
}
660-
661660
ret = isert_conn_setup_qp(isert_conn, cma_id, pi_support);
662661
if (ret)
663662
goto out_conn_dev;
@@ -671,9 +670,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event)
671670
return 0;
672671

673672
out_conn_dev:
674-
if (device->use_fastreg)
675-
isert_conn_free_fastreg_pool(isert_conn);
676-
out_fastreg:
677673
ib_dereg_mr(isert_conn->conn_mr);
678674
out_mr:
679675
ib_dealloc_pd(isert_conn->conn_pd);
@@ -1047,6 +1043,18 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login,
10471043
}
10481044
if (!login->login_failed) {
10491045
if (login->login_complete) {
1046+
if (isert_conn->conn_device->use_fastreg) {
1047+
u8 pi_support = login->np->tpg_np->tpg->tpg_attrib.t10_pi;
1048+
1049+
ret = isert_conn_create_fastreg_pool(isert_conn,
1050+
pi_support);
1051+
if (ret) {
1052+
pr_err("Conn: %p failed to create"
1053+
" fastreg pool\n", isert_conn);
1054+
return ret;
1055+
}
1056+
}
1057+
10501058
ret = isert_alloc_rx_descriptors(isert_conn);
10511059
if (ret)
10521060
return ret;

0 commit comments

Comments
 (0)