examples/nvme/identify: remove exit_and_free_qpair()

Currently, error handling code in examples/nvme/identify frees the qpair
before calling exit().
However, since every SPDK process starts off by triggering a reset
(in state NVME_CTRLR_STATE_INIT), which causes all the qpairs to be
deleted, there is not really a reason to do a nice cleanup on error.

Additionally, other examples, e.g. examples/nvme/hello_world does not
do a nice cleanup on error, so it is inconsistent if identify does so.

Proper freeing of the qpairs is still done in the normal case where
we don't get any errors (in this example, and in other examples).

Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
Change-Id: I0db612934464e6e84eaf466c12eb35eaa396e511
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4838
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Niklas Cassel 2020-10-21 18:49:08 +00:00 committed by Tomasz Zawadzki
parent 6915ad7c34
commit 6e231f59af

View File

@ -155,15 +155,6 @@ hex_dump(const void *data, size_t size)
}
}
static void
exit_and_free_qpair(struct spdk_nvme_qpair *qpair)
{
if (qpair) {
spdk_nvme_ctrlr_free_io_qpair(qpair);
}
exit(1);
}
static void
get_feature_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
{
@ -200,8 +191,6 @@ get_ocssd_geometry_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
static void
get_zns_zone_report_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
{
struct spdk_nvme_qpair *qpair = cb_arg;
if (spdk_nvme_cpl_is_error(cpl)) {
printf("get zns zone report failed\n");
}
@ -213,7 +202,7 @@ get_zns_zone_report_completion(void *cb_arg, const struct spdk_nvme_cpl *cpl)
if (g_zone_report->nr_zones != g_nr_zones_requested) {
printf("Invalid number of zones returned: %"PRIu64" (expected: %"PRIu64")\n",
g_zone_report->nr_zones, g_nr_zones_requested);
exit_and_free_qpair(qpair);
exit(1);
}
outstanding_commands--;
}
@ -617,14 +606,14 @@ get_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *qpair)
g_zone_report = calloc(1, g_zone_report_size);
if (g_zone_report == NULL) {
printf("Zone report allocation failed!\n");
exit_and_free_qpair(qpair);
exit(1);
}
if (spdk_nvme_zns_report_zones(ns, qpair, g_zone_report, g_zone_report_size,
0, SPDK_NVME_ZRA_LIST_ALL, true,
get_zns_zone_report_completion, qpair)) {
get_zns_zone_report_completion, NULL)) {
printf("spdk_nvme_zns_report_zones() failed\n");
exit_and_free_qpair(qpair);
exit(1);
} else {
outstanding_commands++;
}