From 11ad02918acfadec728c82b0f79a048817fa46e8 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 2 Dec 2021 02:01:05 +0900 Subject: [PATCH] nvme: Swap ctrlr_disconnect_qpair() and poll_group_remove() in nvme_ctrlr_free_io_qpair() nvme_ctrlr_disconnect_qpair() calls nvme_poll_group_disconnect_qpair() if the qpair uses a poll group, and nvme_poll_group_disconnect_qpair() calls nvme_ctrlr_disconnect_qpair() if the state of the qpair is not DISCONNECTING. This relationship made the code very complex. A few patches starting from this patch simplifies disconnect and free qpair operations. This patch swaps the ordering of nvme_ctrlr_disconnect_qpair() and spdk_nvme_poll_group_remove() in spdk_nvme_ctrlr_free_io_qpair(). This ensures the qpair is disconnected when spdk_nvme_ctrlr_free_io_qpair() calls spdk_nvme_poll_group_remove(). This enables us to limit spdk_nvme_poll_group_remove() to be available only for disconnected qpairs. Signed-off-by: Shuhei Matsumoto Change-Id: I0601a74f953a2efc4f177a51a4450baea33533d4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10670 Community-CI: Mellanox Build Bot Community-CI: Broadcom CI Tested-by: SPDK CI Jenkins Reviewed-by: Aleksey Marchuk Reviewed-by: Jim Harris --- lib/nvme/nvme_ctrlr.c | 4 ++-- test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nvme/nvme_ctrlr.c b/lib/nvme/nvme_ctrlr.c index f3459e3f1..dd4601a1c 100644 --- a/lib/nvme/nvme_ctrlr.c +++ b/lib/nvme/nvme_ctrlr.c @@ -626,12 +626,12 @@ spdk_nvme_ctrlr_free_io_qpair(struct spdk_nvme_qpair *qpair) return 0; } + nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair); + if (qpair->poll_group) { spdk_nvme_poll_group_remove(qpair->poll_group->group, qpair); } - nvme_transport_ctrlr_disconnect_qpair(ctrlr, qpair); - /* Do not retry. */ nvme_qpair_set_state(qpair, NVME_QPAIR_DESTROYING); diff --git a/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c b/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c index 092b38d2e..56662614d 100644 --- a/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c +++ b/test/unit/lib/nvme/nvme_ctrlr.c/nvme_ctrlr_ut.c @@ -3,7 +3,7 @@ * * Copyright (c) Intel Corporation. All rights reserved. * Copyright (c) 2020, 2021 Mellanox Technologies LTD. All rights reserved. - * Copyright (c) 2021 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + * Copyright (c) 2021, 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions