nvme: Limit spdk_nvme_poll_group_remove() to use only for disconnected qpairs

Signed-off-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: I3c06c41664ee757423641474141439f9c32fc0b6
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10671
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: Monica Kenguva <monica.kenguva@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Shuhei Matsumoto 2021-12-02 04:11:46 +09:00 committed by Tomasz Zawadzki
parent e021cc0147
commit 7ae79a38a5
4 changed files with 26 additions and 22 deletions

View File

@ -16,6 +16,9 @@ Many APIs are now vectored rather than scalar, meaning they take iovecs instead
API `spdk_nvme_trtype_is_fabrics` was added to return existing transport type
is fabric or not.
API `spdk_nvme_poll_group_remove` was limited to be available only for a
disconnected qpair in the group.
### bdev_nvme
Added `num_io_queues` to `bdev_nvme_attach_controller` RPC to allow specifying amount

View File

@ -3,7 +3,7 @@
*
* Copyright (c) Intel Corporation. All rights reserved.
* Copyright (c) 2019-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
@ -2634,12 +2634,13 @@ struct spdk_nvme_poll_group *spdk_nvme_qpair_get_optimal_poll_group(struct spdk_
int spdk_nvme_poll_group_add(struct spdk_nvme_poll_group *group, struct spdk_nvme_qpair *qpair);
/**
* Remove an spdk_nvme_qpair from a poll group.
* Remove a disconnected spdk_nvme_qpair from a poll group.
*
* \param group The group from which to remove the qpair.
* \param qpair The qpair to remove from the poll group.
*
* return 0 on success, -ENOENT if the qpair is not found in the group, or -EPROTO on a protocol (transport) specific failure.
* return 0 on success, -ENOENT if the qpair is not found in the group, -EINVAL if the qpair is not
* disconnected in the group, or -EPROTO on a protocol (transport) specific failure.
*/
int spdk_nvme_poll_group_remove(struct spdk_nvme_poll_group *group, struct spdk_nvme_qpair *qpair);

View File

@ -4,7 +4,7 @@
* Copyright (c) Intel Corporation.
* All rights reserved.
* Copyright (c) 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
@ -684,23 +684,23 @@ int
nvme_transport_poll_group_remove(struct spdk_nvme_transport_poll_group *tgroup,
struct spdk_nvme_qpair *qpair)
{
int rc;
int rc __attribute__((unused));
rc = tgroup->transport->ops.poll_group_remove(tgroup, qpair);
if (rc == 0) {
if (qpair->poll_group_tailq_head == &tgroup->connected_qpairs) {
STAILQ_REMOVE(&tgroup->connected_qpairs, qpair, spdk_nvme_qpair, poll_group_stailq);
} else if (qpair->poll_group_tailq_head == &tgroup->disconnected_qpairs) {
STAILQ_REMOVE(&tgroup->disconnected_qpairs, qpair, spdk_nvme_qpair, poll_group_stailq);
} else {
return -ENOENT;
}
qpair->poll_group = NULL;
qpair->poll_group_tailq_head = NULL;
if (qpair->poll_group_tailq_head == &tgroup->connected_qpairs) {
return -EINVAL;
} else if (qpair->poll_group_tailq_head != &tgroup->disconnected_qpairs) {
return -ENOENT;
}
return rc;
rc = tgroup->transport->ops.poll_group_remove(tgroup, qpair);
assert(rc == 0);
STAILQ_REMOVE(&tgroup->disconnected_qpairs, qpair, spdk_nvme_qpair, poll_group_stailq);
qpair->poll_group = NULL;
qpair->poll_group_tailq_head = NULL;
return 0;
}
int64_t

View File

@ -3,7 +3,7 @@
*
* Copyright (c) Intel Corporation.
* 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
@ -209,9 +209,9 @@ test_nvme_transport_poll_group_add_remove(void)
STAILQ_INSERT_TAIL(&tgroup.connected_qpairs, &qpair, poll_group_stailq);
rc = nvme_transport_poll_group_remove(&tgroup, &qpair);
CU_ASSERT(rc == 0);
CU_ASSERT(qpair.poll_group == NULL);
CU_ASSERT(qpair.poll_group_tailq_head == NULL);
CU_ASSERT(rc == -EINVAL);
STAILQ_REMOVE(&tgroup.connected_qpairs, &qpair, spdk_nvme_qpair, poll_group_stailq);
/* Invalid qpair */
qpair.poll_group_tailq_head = NULL;