IB/iser: Move fastreg descriptor allocation to iser_create_fastreg_desc
Don't have the caller allocate the structure and worry about freeing it in case the routine failed. This patch does not change any functionality. 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:
parent
48afbff673
commit
eb6ea8c36c
1 changed files with 17 additions and 21 deletions
|
@ -341,17 +341,20 @@ iser_free_pi_ctx(struct iser_pi_context *pi_ctx)
|
||||||
kfree(pi_ctx);
|
kfree(pi_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static struct iser_fr_desc *
|
||||||
iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
|
iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
|
||||||
bool pi_enable, struct iser_fr_desc *desc)
|
bool pi_enable)
|
||||||
{
|
{
|
||||||
|
struct iser_fr_desc *desc;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
desc = kzalloc(sizeof(*desc), GFP_KERNEL);
|
||||||
|
if (!desc)
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc);
|
ret = iser_alloc_reg_res(ib_device, pd, &desc->rsc);
|
||||||
if (ret) {
|
if (ret)
|
||||||
iser_err("failed to allocate reg_resources\n");
|
goto reg_res_alloc_failure;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pi_enable) {
|
if (pi_enable) {
|
||||||
ret = iser_alloc_pi_ctx(ib_device, pd, desc);
|
ret = iser_alloc_pi_ctx(ib_device, pd, desc);
|
||||||
|
@ -359,12 +362,14 @@ iser_create_fastreg_desc(struct ib_device *ib_device, struct ib_pd *pd,
|
||||||
goto pi_ctx_alloc_failure;
|
goto pi_ctx_alloc_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return desc;
|
||||||
|
|
||||||
pi_ctx_alloc_failure:
|
pi_ctx_alloc_failure:
|
||||||
iser_free_reg_res(&desc->rsc);
|
iser_free_reg_res(&desc->rsc);
|
||||||
|
reg_res_alloc_failure:
|
||||||
|
kfree(desc);
|
||||||
|
|
||||||
return ret;
|
return ERR_PTR(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -381,19 +386,10 @@ int iser_alloc_fastreg_pool(struct ib_conn *ib_conn, unsigned cmds_max)
|
||||||
INIT_LIST_HEAD(&ib_conn->fastreg.pool);
|
INIT_LIST_HEAD(&ib_conn->fastreg.pool);
|
||||||
ib_conn->fastreg.pool_size = 0;
|
ib_conn->fastreg.pool_size = 0;
|
||||||
for (i = 0; i < cmds_max; i++) {
|
for (i = 0; i < cmds_max; i++) {
|
||||||
desc = kzalloc(sizeof(*desc), GFP_KERNEL);
|
desc = iser_create_fastreg_desc(device->ib_device, device->pd,
|
||||||
if (!desc) {
|
ib_conn->pi_support);
|
||||||
iser_err("Failed to allocate a new fast_reg descriptor\n");
|
if (IS_ERR(desc)) {
|
||||||
ret = -ENOMEM;
|
ret = PTR_ERR(desc);
|
||||||
goto err;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = iser_create_fastreg_desc(device->ib_device, device->pd,
|
|
||||||
ib_conn->pi_support, desc);
|
|
||||||
if (ret) {
|
|
||||||
iser_err("Failed to create fastreg descriptor err=%d\n",
|
|
||||||
ret);
|
|
||||||
kfree(desc);
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue