diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-03-21 21:10:25 -0400 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2014-04-07 04:48:50 -0400 |
commit | f46d6a8a01d6bbd83a97140f30a72a89b038807b (patch) | |
tree | 99dce8c9899aabd3f849120b4fc406e5d710b4b6 /drivers/infiniband | |
parent | 5bac4b1a1fd84769df941eefb8bdbe010df6b876 (diff) |
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 <sagig@mellanox.com>
Cc: Or Gerlitz <ogerlitz@mellanox.com>
Cc: <stable@vger.kernel.org> #3.12+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/ulp/isert/ib_isert.c | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index 09bde9fe6b8d..529d2cbfe45a 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
@@ -508,11 +508,18 @@ isert_conn_create_fastreg_pool(struct isert_conn *isert_conn, u8 pi_support) | |||
508 | { | 508 | { |
509 | struct fast_reg_descriptor *fr_desc; | 509 | struct fast_reg_descriptor *fr_desc; |
510 | struct isert_device *device = isert_conn->conn_device; | 510 | 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; | ||
512 | 520 | ||
513 | INIT_LIST_HEAD(&isert_conn->conn_fr_pool); | ||
514 | isert_conn->conn_fr_pool_size = 0; | 521 | 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++) { |
516 | fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL); | 523 | fr_desc = kzalloc(sizeof(*fr_desc), GFP_KERNEL); |
517 | if (!fr_desc) { | 524 | if (!fr_desc) { |
518 | pr_err("Failed to allocate fast_reg descriptor\n"); | 525 | 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) | |||
572 | kref_get(&isert_conn->conn_kref); | 579 | kref_get(&isert_conn->conn_kref); |
573 | mutex_init(&isert_conn->conn_mutex); | 580 | mutex_init(&isert_conn->conn_mutex); |
574 | spin_lock_init(&isert_conn->conn_lock); | 581 | spin_lock_init(&isert_conn->conn_lock); |
582 | INIT_LIST_HEAD(&isert_conn->conn_fr_pool); | ||
575 | 583 | ||
576 | cma_id->context = isert_conn; | 584 | cma_id->context = isert_conn; |
577 | isert_conn->conn_cm_id = cma_id; | 585 | 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) | |||
649 | goto out_mr; | 657 | goto out_mr; |
650 | } | 658 | } |
651 | 659 | ||
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 | |||
661 | ret = isert_conn_setup_qp(isert_conn, cma_id, pi_support); | 660 | ret = isert_conn_setup_qp(isert_conn, cma_id, pi_support); |
662 | if (ret) | 661 | if (ret) |
663 | goto out_conn_dev; | 662 | goto out_conn_dev; |
@@ -671,9 +670,6 @@ isert_connect_request(struct rdma_cm_id *cma_id, struct rdma_cm_event *event) | |||
671 | return 0; | 670 | return 0; |
672 | 671 | ||
673 | out_conn_dev: | 672 | out_conn_dev: |
674 | if (device->use_fastreg) | ||
675 | isert_conn_free_fastreg_pool(isert_conn); | ||
676 | out_fastreg: | ||
677 | ib_dereg_mr(isert_conn->conn_mr); | 673 | ib_dereg_mr(isert_conn->conn_mr); |
678 | out_mr: | 674 | out_mr: |
679 | ib_dealloc_pd(isert_conn->conn_pd); | 675 | ib_dealloc_pd(isert_conn->conn_pd); |
@@ -1047,6 +1043,18 @@ isert_put_login_tx(struct iscsi_conn *conn, struct iscsi_login *login, | |||
1047 | } | 1043 | } |
1048 | if (!login->login_failed) { | 1044 | if (!login->login_failed) { |
1049 | if (login->login_complete) { | 1045 | 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 | |||
1050 | ret = isert_alloc_rx_descriptors(isert_conn); | 1058 | ret = isert_alloc_rx_descriptors(isert_conn); |
1051 | if (ret) | 1059 | if (ret) |
1052 | return ret; | 1060 | return ret; |