bdev/nvme: Factor out reset_io completion into a helper function

This will be helpful to simplify the following patches.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I66939f2953c66582bfcb79cfe187814280e89680
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7324
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2021-04-11 17:56:02 +09:00 committed by Tomasz Zawadzki
parent 73b4b9ad68
commit a0ea252399

View File

@ -481,18 +481,36 @@ bdev_nvme_abort_pending_resets(struct spdk_io_channel_iter *i)
spdk_for_each_channel_continue(i, 0);
}
static void
bdev_nvme_reset_io_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr,
struct nvme_bdev_io *bio, int rc)
{
enum spdk_bdev_io_status io_status = SPDK_BDEV_IO_STATUS_SUCCESS;
if (rc) {
io_status = SPDK_BDEV_IO_STATUS_FAILED;
}
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bio), io_status);
/* Make sure we clear any pending resets before returning. */
spdk_for_each_channel(nvme_bdev_ctrlr,
rc == 0 ? bdev_nvme_complete_pending_resets :
bdev_nvme_abort_pending_resets,
nvme_bdev_ctrlr,
_bdev_nvme_check_pending_destruct);
}
static void
_bdev_nvme_reset_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, int rc)
{
struct nvme_bdev_ctrlr_trid *curr_trid;
struct nvme_bdev_io *bio = nvme_bdev_ctrlr->reset_bio;
enum spdk_bdev_io_status io_status = SPDK_BDEV_IO_STATUS_SUCCESS;
nvme_bdev_ctrlr->reset_bio = NULL;
if (rc) {
SPDK_ERRLOG("Resetting controller failed.\n");
io_status = SPDK_BDEV_IO_STATUS_FAILED;
} else {
SPDK_NOTICELOG("Resetting controller successful.\n");
}
@ -515,15 +533,15 @@ _bdev_nvme_reset_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, int rc)
pthread_mutex_unlock(&nvme_bdev_ctrlr->mutex);
if (bio) {
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bio), io_status);
bdev_nvme_reset_io_complete(nvme_bdev_ctrlr, bio, rc);
} else {
/* Make sure we clear any pending resets before returning. */
spdk_for_each_channel(nvme_bdev_ctrlr,
rc == 0 ? bdev_nvme_complete_pending_resets :
bdev_nvme_abort_pending_resets,
nvme_bdev_ctrlr,
_bdev_nvme_check_pending_destruct);
}
/* Make sure we clear any pending resets before returning. */
spdk_for_each_channel(nvme_bdev_ctrlr,
rc == 0 ? bdev_nvme_complete_pending_resets :
bdev_nvme_abort_pending_resets,
nvme_bdev_ctrlr,
_bdev_nvme_check_pending_destruct);
}
static void