nvme/pcie: make nvme_pcie_ctrlr_delete_io_qpair call trace multi-process safe

When a secondary process exit without deleting allocated IO
queue pair, then a new secondary process will do cleanup for
previous allocated queue pair, then segment fault will happen
due to `stat` inside IO queue pair data strucutre can't be
accessed in this cleanup process.

Fix issue #2565.

Change-Id: I01a037642683901941b5268ac20d17b78b6c6350
Signed-off-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13537
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Changpeng Liu 2022-07-11 09:32:27 +08:00 committed by Konrad Sztyber
parent ee8167e3e1
commit dbecab8da0

View File

@ -1018,7 +1018,7 @@ nvme_pcie_qpair_destroy(struct spdk_nvme_qpair *qpair)
nvme_qpair_deinit(qpair);
if (!pqpair->shared_stats) {
if (!pqpair->shared_stats && (qpair->active_proc == nvme_ctrlr_get_current_process(qpair->ctrlr))) {
if (qpair->id) {
free(pqpair->stat);
} else {
@ -1125,7 +1125,9 @@ nvme_pcie_ctrlr_delete_io_qpair(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_
/* Now that the submission queue is deleted, the device is supposed to have
* completed any outstanding I/O. Try to complete them. If they don't complete,
* they'll be marked as aborted and completed below. */
nvme_pcie_qpair_process_completions(qpair, 0);
if (qpair->active_proc == nvme_ctrlr_get_current_process(ctrlr)) {
nvme_pcie_qpair_process_completions(qpair, 0);
}
memset(status, 0, sizeof(*status));
/* Delete the completion queue */