IB/iser: Introduce iser registration pool struct
Instead of having it a part of the connection structure, have it be under a dedicated (embedded) structure in the connection. A logical separation of the registration pool and the connection structure. Signed-off-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Adir Lev <adirl@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:

committed by
Doug Ledford

parent
eb6ea8c36c
commit
385ad87d4b
@@ -202,16 +202,21 @@ static void iser_free_device_ib_res(struct iser_device *device)
|
||||
int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
|
||||
{
|
||||
struct iser_device *device = ib_conn->device;
|
||||
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
|
||||
struct iser_page_vec *page_vec;
|
||||
struct ib_fmr_pool *fmr_pool;
|
||||
struct ib_fmr_pool_param params;
|
||||
int ret = -ENOMEM;
|
||||
|
||||
ib_conn->fmr.page_vec = kmalloc(sizeof(*ib_conn->fmr.page_vec) +
|
||||
(sizeof(u64)*(ISCSI_ISER_SG_TABLESIZE + 1)),
|
||||
GFP_KERNEL);
|
||||
if (!ib_conn->fmr.page_vec)
|
||||
spin_lock_init(&fr_pool->lock);
|
||||
|
||||
page_vec = kmalloc(sizeof(*page_vec) +
|
||||
(sizeof(u64) * (ISCSI_ISER_SG_TABLESIZE + 1)),
|
||||
GFP_KERNEL);
|
||||
if (!page_vec)
|
||||
return ret;
|
||||
|
||||
ib_conn->fmr.page_vec->pages = (u64 *)(ib_conn->fmr.page_vec + 1);
|
||||
page_vec->pages = (u64 *)(page_vec + 1);
|
||||
|
||||
params.page_shift = SHIFT_4K;
|
||||
/* when the first/last SG element are not start/end *
|
||||
@@ -227,18 +232,20 @@ int iser_alloc_fmr_pool(struct ib_conn *ib_conn, unsigned cmds_max)
|
||||
IB_ACCESS_REMOTE_WRITE |
|
||||
IB_ACCESS_REMOTE_READ);
|
||||
|
||||
ib_conn->fmr.pool = ib_create_fmr_pool(device->pd, ¶ms);
|
||||
if (IS_ERR(ib_conn->fmr.pool)) {
|
||||
ret = PTR_ERR(ib_conn->fmr.pool);
|
||||
fmr_pool = ib_create_fmr_pool(device->pd, ¶ms);
|
||||
if (IS_ERR(fmr_pool)) {
|
||||
ret = PTR_ERR(fmr_pool);
|
||||
iser_err("FMR allocation failed, err %d\n", ret);
|
||||
goto err;
|
||||
}
|
||||
|
||||
fr_pool->fmr.page_vec = page_vec;
|
||||
fr_pool->fmr.pool = fmr_pool;
|
||||
|
||||
return 0;
|
||||
|
||||
err:
|
||||
kfree(ib_conn->fmr.page_vec);
|
||||
ib_conn->fmr.page_vec = NULL;
|
||||
kfree(page_vec);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -247,14 +254,15 @@ err:
|
||||
*/
|
||||
void iser_free_fmr_pool(struct ib_conn *ib_conn)
|
||||
{
|
||||
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
|
||||
|
||||
iser_info("freeing conn %p fmr pool %p\n",
|
||||
ib_conn, ib_conn->fmr.pool);
|
||||
ib_conn, fr_pool->fmr.pool);
|
||||
|
||||
ib_destroy_fmr_pool(ib_conn->fmr.pool);
|
||||
ib_conn->fmr.pool = NULL;
|
||||
|
||||
kfree(ib_conn->fmr.page_vec);
|
||||
ib_conn->fmr.page_vec = NULL;
|
||||
ib_destroy_fmr_pool(fr_pool->fmr.pool);
|
||||
fr_pool->fmr.pool = NULL;
|
||||
kfree(fr_pool->fmr.page_vec);
|
||||
fr_pool->fmr.page_vec = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
@@ -380,11 +388,13 @@ reg_res_alloc_failure:
|
||||
int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
|
||||
{
|
||||
struct iser_device *device = ib_conn->device;
|
||||
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
|
||||
struct iser_fr_desc *desc;
|
||||
int i, ret;
|
||||
|
||||
INIT_LIST_HEAD(&ib_conn->fastreg.pool);
|
||||
ib_conn->fastreg.pool_size = 0;
|
||||
INIT_LIST_HEAD(&fr_pool->fastreg.pool);
|
||||
spin_lock_init(&fr_pool->lock);
|
||||
fr_pool->fastreg.pool_size = 0;
|
||||
for (i = 0; i < cmds_max; i++) {
|
||||
desc = iser_create_fastreg_desc(device->ib_device, device->pd,
|
||||
ib_conn->pi_support);
|
||||
@@ -393,8 +403,8 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
|
||||
goto err;
|
||||
}
|
||||
|
||||
list_add_tail(&desc->list, &ib_conn->fastreg.pool);
|
||||
ib_conn->fastreg.pool_size++;
|
||||
list_add_tail(&desc->list, &fr_pool->fastreg.pool);
|
||||
fr_pool->fastreg.pool_size++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -409,15 +419,16 @@ err:
|
||||
*/
|
||||
void iser_free_fastreg_pool(struct ib_conn *ib_conn)
|
||||
{
|
||||
struct iser_fr_pool *fr_pool = &ib_conn->fr_pool;
|
||||
struct iser_fr_desc *desc, *tmp;
|
||||
int i = 0;
|
||||
|
||||
if (list_empty(&ib_conn->fastreg.pool))
|
||||
if (list_empty(&fr_pool->fastreg.pool))
|
||||
return;
|
||||
|
||||
iser_info("freeing conn %p fr pool\n", ib_conn);
|
||||
|
||||
list_for_each_entry_safe(desc, tmp, &ib_conn->fastreg.pool, list) {
|
||||
list_for_each_entry_safe(desc, tmp, &fr_pool->fastreg.pool, list) {
|
||||
list_del(&desc->list);
|
||||
iser_free_reg_res(&desc->rsc);
|
||||
if (desc->pi_ctx)
|
||||
@@ -426,9 +437,9 @@ void iser_free_fastreg_pool(struct ib_conn *ib_conn)
|
||||
++i;
|
||||
}
|
||||
|
||||
if (i < ib_conn->fastreg.pool_size)
|
||||
if (i < fr_pool->fastreg.pool_size)
|
||||
iser_warn("pool still has %d regions registered\n",
|
||||
ib_conn->fastreg.pool_size - i);
|
||||
fr_pool->fastreg.pool_size - i);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -924,7 +935,6 @@ void iser_conn_init(struct iser_conn *iser_conn)
|
||||
init_completion(&iser_conn->ib_completion);
|
||||
init_completion(&iser_conn->up_completion);
|
||||
INIT_LIST_HEAD(&iser_conn->conn_list);
|
||||
spin_lock_init(&iser_conn->ib_conn.lock);
|
||||
mutex_init(&iser_conn->state_mutex);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user