nvme/perf: Free resources when abnormal exit.
There are anbormal cases, from callocated nvme qpairs until connect io qpairs successfully . We should free these resources when abnormal exit, and codes just return there. Signed-off-by: yidong0635 <dongx.yi@intel.com> Change-Id: I08de9c1fe1757a11a118ebedc326d81e2c68b077 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2985 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
4c156e6379
commit
c75dfb4201
@ -612,7 +612,7 @@ nvme_init_ns_worker_ctx(struct ns_worker_ctx *ns_ctx)
|
||||
|
||||
ns_ctx->u.nvme.group = spdk_nvme_poll_group_create(NULL);
|
||||
if (ns_ctx->u.nvme.group == NULL) {
|
||||
return -1;
|
||||
goto poll_group_failed;
|
||||
}
|
||||
|
||||
group = ns_ctx->u.nvme.group;
|
||||
@ -622,21 +622,35 @@ nvme_init_ns_worker_ctx(struct ns_worker_ctx *ns_ctx)
|
||||
qpair = ns_ctx->u.nvme.qpair[i];
|
||||
if (!qpair) {
|
||||
printf("ERROR: spdk_nvme_ctrlr_alloc_io_qpair failed\n");
|
||||
return -1;
|
||||
goto qpair_failed;
|
||||
}
|
||||
|
||||
if (spdk_nvme_poll_group_add(group, qpair)) {
|
||||
printf("ERROR: unable to add I/O qpair to poll group.\n");
|
||||
return -1;
|
||||
spdk_nvme_ctrlr_free_io_qpair(qpair);
|
||||
goto qpair_failed;
|
||||
}
|
||||
|
||||
if (spdk_nvme_ctrlr_connect_io_qpair(entry->u.nvme.ctrlr, qpair)) {
|
||||
printf("ERROR: unable to connect I/O qpair.\n");
|
||||
return -1;
|
||||
spdk_nvme_poll_group_remove(group, qpair);
|
||||
spdk_nvme_ctrlr_free_io_qpair(qpair);
|
||||
goto qpair_failed;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
qpair_failed:
|
||||
for (; i > 0; --i) {
|
||||
spdk_nvme_poll_group_remove(ns_ctx->u.nvme.group, ns_ctx->u.nvme.qpair[i - 1]);
|
||||
spdk_nvme_ctrlr_free_io_qpair(ns_ctx->u.nvme.qpair[i - 1]);
|
||||
}
|
||||
|
||||
spdk_nvme_poll_group_destroy(ns_ctx->u.nvme.group);
|
||||
poll_group_failed:
|
||||
free(ns_ctx->u.nvme.qpair);
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user