diff --git a/include/spdk/nvmf.h b/include/spdk/nvmf.h index 026d889cc..491fc48d6 100644 --- a/include/spdk/nvmf.h +++ b/include/spdk/nvmf.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2016 Intel Corporation. All rights reserved. * Copyright (c) 2018-2021 Mellanox Technologies LTD. All rights reserved. - * Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * Copyright (c) 2021, 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ /** \file @@ -296,6 +296,7 @@ typedef void (*nvmf_qpair_disconnect_cb)(void *ctx); * * \return 0 upon success. * \return -ENOMEM if the function specific context could not be allocated. + * \return -EINPROGRESS if the qpair is already in the process of disconnect. */ int spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_cb cb_fn, void *ctx); diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index 01ed56f69..47640254f 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2017 Intel Corporation. All rights reserved. * Copyright (c) 2019, 2020 Mellanox Technologies LTD. All rights reserved. - * Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * Copyright (c) 2021, 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ #include "spdk/stdinc.h" @@ -131,8 +131,12 @@ _nvmf_ctrlr_disconnect_qpairs_on_pg(struct spdk_io_channel_iter *i, bool include if (qpair->ctrlr == ctrlr && (include_admin || !nvmf_qpair_is_admin_queue(qpair))) { rc = spdk_nvmf_qpair_disconnect(qpair, NULL, NULL); if (rc) { - SPDK_ERRLOG("Qpair disconnect failed\n"); - return rc; + if (rc == -EINPROGRESS) { + rc = 0; + } else { + SPDK_ERRLOG("Qpair disconnect failed\n"); + return rc; + } } } } @@ -1001,7 +1005,7 @@ nvmf_ctrlr_association_remove(void *ctx) if (ctrlr->admin_qpair) { rc = spdk_nvmf_qpair_disconnect(ctrlr->admin_qpair, NULL, NULL); - if (rc < 0) { + if (rc < 0 && rc != -EINPROGRESS) { SPDK_ERRLOG("Fail to disconnect admin ctrlr qpair\n"); assert(false); } diff --git a/lib/nvmf/nvmf.c b/lib/nvmf/nvmf.c index cb13e65b1..5895276b1 100644 --- a/lib/nvmf/nvmf.c +++ b/lib/nvmf/nvmf.c @@ -231,7 +231,7 @@ _nvmf_tgt_disconnect_qpairs(void *ctx) TAILQ_FOREACH_SAFE(qpair, &group->qpairs, link, qpair_tmp) { rc = spdk_nvmf_qpair_disconnect(qpair, NULL, NULL); - if (rc) { + if (rc && rc != -EINPROGRESS) { break; } } @@ -1249,10 +1249,7 @@ spdk_nvmf_qpair_disconnect(struct spdk_nvmf_qpair *qpair, nvmf_qpair_disconnect_ struct nvmf_qpair_disconnect_ctx *qpair_ctx; if (__atomic_test_and_set(&qpair->disconnect_started, __ATOMIC_RELAXED)) { - if (cb_fn) { - cb_fn(ctx); - } - return 0; + return -EINPROGRESS; } /* If we get a qpair in the uninitialized state, we can just destroy it immediately */ @@ -1595,7 +1592,7 @@ nvmf_poll_group_remove_subsystem_msg(void *ctx) if ((qpair->ctrlr != NULL) && (qpair->ctrlr->subsys == subsystem)) { qpairs_found = true; rc = spdk_nvmf_qpair_disconnect(qpair, NULL, NULL); - if (rc) { + if (rc && rc != -EINPROGRESS) { break; } }