From 90f434b9a0263afdecddbed05317986c5cc1f018 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 24 Mar 2021 19:42:42 +0900 Subject: [PATCH] bdev/nvme: Factor out destroy qpair operation into a helper function Factor out the operation to destroy qpair into a helper function bdev_nvme_destroy_qpair(). Signed-off-by: Shuhei Matsumoto Change-Id: I5ac9215407e0b4f4368a68bc58d8e3daac029393 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6783 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Paul Luse Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris Tested-by: SPDK CI Jenkins --- module/bdev/nvme/bdev_nvme.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 7ac51c9e0..1fbb19ff9 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -378,6 +378,22 @@ err: return rc; } +static int +bdev_nvme_destroy_qpair(struct nvme_io_channel *nvme_ch) +{ + int rc; + + if (nvme_ch->qpair == NULL) { + return 0; + } + + rc = spdk_nvme_ctrlr_free_io_qpair(nvme_ch->qpair); + if (!rc) { + nvme_ch->qpair = NULL; + } + return rc; +} + static void _bdev_nvme_check_pending_destruct(struct spdk_io_channel_iter *i, int status) { @@ -534,10 +550,7 @@ _bdev_nvme_reset_destroy_qpair(struct spdk_io_channel_iter *i) struct nvme_io_channel *nvme_ch = spdk_io_channel_get_ctx(ch); int rc; - rc = spdk_nvme_ctrlr_free_io_qpair(nvme_ch->qpair); - if (!rc) { - nvme_ch->qpair = NULL; - } + rc = bdev_nvme_destroy_qpair(nvme_ch); spdk_for_each_channel_continue(i, rc); } @@ -1038,9 +1051,7 @@ bdev_nvme_destroy_cb(void *io_device, void *ctx_buf) bdev_ocssd_destroy_io_channel(nvme_ch); } - if (nvme_ch->qpair != NULL) { - spdk_nvme_ctrlr_free_io_qpair(nvme_ch->qpair); - } + bdev_nvme_destroy_qpair(nvme_ch); spdk_put_io_channel(spdk_io_channel_from_ctx(nvme_ch->group)); }