bdev/nvme: Merge completing reset_io into _bdev_nvme_reset_complete()
reset_io is stored into nvme_bdev_ctrlr->reset_bio now. Hence we can merge completing reset_io into _bdev_nvme_reset_complete() easily. i As a few minor changes, to reduce the size of the following patches, clear reset_bio before calling spdk_bdev_io_complete(), and call spdk_bdev_io_complete() after completing ctrlr reset. The following patches will retry pending reset_ios if reset is internal, abort reset_ios if reset is external and fails, or succeed reset_ios if reset is external and succeeds. This clean-up will be helpful for such enhancement. Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Change-Id: I5e0b4e04b19f4f4f3b21b2db4dc6a2b948b29c67 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7241 Community-CI: Broadcom CI Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
888def105f
commit
42ae4267b6
@ -458,9 +458,14 @@ static void
|
|||||||
_bdev_nvme_reset_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, int rc)
|
_bdev_nvme_reset_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, int rc)
|
||||||
{
|
{
|
||||||
struct nvme_bdev_ctrlr_trid *curr_trid;
|
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) {
|
if (rc) {
|
||||||
SPDK_ERRLOG("Resetting controller failed.\n");
|
SPDK_ERRLOG("Resetting controller failed.\n");
|
||||||
|
io_status = SPDK_BDEV_IO_STATUS_FAILED;
|
||||||
} else {
|
} else {
|
||||||
SPDK_NOTICELOG("Resetting controller successful.\n");
|
SPDK_NOTICELOG("Resetting controller successful.\n");
|
||||||
}
|
}
|
||||||
@ -482,6 +487,10 @@ _bdev_nvme_reset_complete(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr, int rc)
|
|||||||
|
|
||||||
pthread_mutex_unlock(&nvme_bdev_ctrlr->mutex);
|
pthread_mutex_unlock(&nvme_bdev_ctrlr->mutex);
|
||||||
|
|
||||||
|
if (bio) {
|
||||||
|
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bio), io_status);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure we clear any pending resets before returning. */
|
/* Make sure we clear any pending resets before returning. */
|
||||||
spdk_for_each_channel(nvme_bdev_ctrlr,
|
spdk_for_each_channel(nvme_bdev_ctrlr,
|
||||||
rc == 0 ? bdev_nvme_complete_pending_resets :
|
rc == 0 ? bdev_nvme_complete_pending_resets :
|
||||||
@ -494,16 +503,7 @@ static void
|
|||||||
_bdev_nvme_reset_create_qpairs_done(struct spdk_io_channel_iter *i, int status)
|
_bdev_nvme_reset_create_qpairs_done(struct spdk_io_channel_iter *i, int status)
|
||||||
{
|
{
|
||||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = spdk_io_channel_iter_get_ctx(i);
|
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = spdk_io_channel_iter_get_ctx(i);
|
||||||
struct nvme_bdev_io *bio = nvme_bdev_ctrlr->reset_bio;
|
|
||||||
int rc = SPDK_BDEV_IO_STATUS_SUCCESS;
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
rc = SPDK_BDEV_IO_STATUS_FAILED;
|
|
||||||
}
|
|
||||||
if (bio) {
|
|
||||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bio), rc);
|
|
||||||
nvme_bdev_ctrlr->reset_bio = NULL;
|
|
||||||
}
|
|
||||||
_bdev_nvme_reset_complete(nvme_bdev_ctrlr, status);
|
_bdev_nvme_reset_complete(nvme_bdev_ctrlr, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -523,7 +523,6 @@ static void
|
|||||||
_bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
|
_bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
|
||||||
{
|
{
|
||||||
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = spdk_io_channel_iter_get_ctx(i);
|
struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = spdk_io_channel_iter_get_ctx(i);
|
||||||
struct nvme_bdev_io *bio = nvme_bdev_ctrlr->reset_bio;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
@ -544,10 +543,6 @@ _bdev_nvme_reset_ctrlr(struct spdk_io_channel_iter *i, int status)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
err:
|
err:
|
||||||
if (bio) {
|
|
||||||
spdk_bdev_io_complete(spdk_bdev_io_from_ctx(bio), SPDK_BDEV_IO_STATUS_FAILED);
|
|
||||||
nvme_bdev_ctrlr->reset_bio = NULL;
|
|
||||||
}
|
|
||||||
_bdev_nvme_reset_complete(nvme_bdev_ctrlr, rc);
|
_bdev_nvme_reset_complete(nvme_bdev_ctrlr, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user