bdev/iscsi: properly free pending connections on module fini
Besides the obvious memory leaks, we also need to call the async completion callback, which may also free some resources. Change-Id: Ia80799be4b220053b82dfb4ee2453181c90136a1 Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/420571 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
9668121208
commit
dbd4e57994
@ -103,6 +103,25 @@ struct bdev_iscsi_conn_req {
|
|||||||
TAILQ_ENTRY(bdev_iscsi_conn_req) link;
|
TAILQ_ENTRY(bdev_iscsi_conn_req) link;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
complete_conn_req(struct bdev_iscsi_conn_req *req, struct spdk_bdev *bdev,
|
||||||
|
int status)
|
||||||
|
{
|
||||||
|
TAILQ_REMOVE(&g_iscsi_conn_req, req, link);
|
||||||
|
req->create_cb(req->create_cb_arg, bdev, status);
|
||||||
|
if (status) {
|
||||||
|
/* if the request failed and no iscsi lun was
|
||||||
|
* created then we could not hand over this
|
||||||
|
* memory and have to free it manually now.
|
||||||
|
*/
|
||||||
|
iscsi_destroy_context(req->context);
|
||||||
|
free(req->initiator_iqn);
|
||||||
|
free(req->bdev_name);
|
||||||
|
free(req->url);
|
||||||
|
}
|
||||||
|
free(req);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
bdev_iscsi_get_ctx_size(void)
|
bdev_iscsi_get_ctx_size(void)
|
||||||
{
|
{
|
||||||
@ -133,8 +152,7 @@ bdev_iscsi_finish(void)
|
|||||||
|
|
||||||
while (!TAILQ_EMPTY(&g_iscsi_conn_req)) {
|
while (!TAILQ_EMPTY(&g_iscsi_conn_req)) {
|
||||||
req = TAILQ_FIRST(&g_iscsi_conn_req);
|
req = TAILQ_FIRST(&g_iscsi_conn_req);
|
||||||
TAILQ_REMOVE(&g_iscsi_conn_req, req, link);
|
complete_conn_req(req, NULL, -EINTR);
|
||||||
free(req);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_conn_poller) {
|
if (g_conn_poller) {
|
||||||
@ -567,25 +585,6 @@ static const struct spdk_bdev_fn_table iscsi_fn_table = {
|
|||||||
.write_config_json = bdev_iscsi_write_config_json,
|
.write_config_json = bdev_iscsi_write_config_json,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
|
||||||
complete_conn_req(struct bdev_iscsi_conn_req *req, struct spdk_bdev *bdev,
|
|
||||||
int status)
|
|
||||||
{
|
|
||||||
TAILQ_REMOVE(&g_iscsi_conn_req, req, link);
|
|
||||||
req->create_cb(req->create_cb_arg, bdev, status);
|
|
||||||
if (status) {
|
|
||||||
/* if the request failed and no iscsi lun was
|
|
||||||
* created then we could not hand over this
|
|
||||||
* memory and have to free it manually now.
|
|
||||||
*/
|
|
||||||
iscsi_destroy_context(req->context);
|
|
||||||
free(req->initiator_iqn);
|
|
||||||
free(req->bdev_name);
|
|
||||||
free(req->url);
|
|
||||||
}
|
|
||||||
free(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
create_iscsi_lun(struct iscsi_context *context, char *url, char *initiator_iqn, char *name,
|
create_iscsi_lun(struct iscsi_context *context, char *url, char *initiator_iqn, char *name,
|
||||||
uint64_t num_blocks, uint32_t block_size, struct spdk_bdev **bdev, bool unmap_supported)
|
uint64_t num_blocks, uint32_t block_size, struct spdk_bdev **bdev, bool unmap_supported)
|
||||||
|
Loading…
Reference in New Issue
Block a user