nvme: add spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page()

Commit a119799b ("test/nvme/aer: remove duplicated changed NS list log")
changed the nvme driver to read the CHANGED_NS_LIST log page before
calling the application's AER callback (previously it would read it
after).

Commit b801af090 ("nvme: add disable_read_changed_ns_list_log_page")
added a new ctrlr_opts member to allow the application to tell the
driver to not read this log page, and will read the log page itself
instead to clear the AEN.  But we cannot add this option to the 22.01
LTS branch since it breaks the ABI.  So adding this API here, which
can then be backported manually to the 22.01 branch for LTS users
that require it.

Restoring the old behavior is not correct for applications that
want to consume the CHANGED_NS_LIST log page contents itself to
know which namespaces have changed.  Even if the driver reads the
log page after the application, that read could happen during a
small window between when a namespace change event has occurred and
the AEN has been sent to the host.  The only safe way for the
application to consume ChANGED_NS_LIST log page contents itself
is to make sure the driver never issues such a log page request
itself.

Fixes issue #2647.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Iaeffe23dc7817c0c94441a36ed4d6f64a1f15a4e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14134
Reviewed-by: Michael Haeuptle <michaelhaeuptle@gmail.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Dong Yi <dongx.yi@intel.com>
Reviewed-by: Shuhei Matsumoto <smatsumoto@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Jim Harris 2022-08-19 14:19:24 +00:00 committed by Tomasz Zawadzki
parent 60e1beb77f
commit 4300c62167
4 changed files with 28 additions and 0 deletions

View File

@ -53,6 +53,11 @@ fabric transport. SPDK_NVME_TRANSPORT_CUSTOM was intended to be non-fabric custo
Added a new function `spdk_nvme_ns_cmd_verify` to submit a Verify Command to a Namespace.
Added `spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page` to allow an application to
tell the driver to not read the CHANGED_NS_LIST log page in response to a NS_ATTR_CHANGED
AEN. When called the application is required to read this log page instead to clear the
AEN.
## v22.05
### sock

View File

@ -1397,6 +1397,22 @@ void spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
spdk_nvme_aer_cb aer_cb_fn,
void *aer_cb_arg);
/**
* Disable reading the CHANGED_NS_LIST log page for the specified controller.
*
* Applications that register an AER callback may wish to read the CHANGED_NS_LIST
* log page itself, rather than relying on the driver to do it. Calling this
* function will ensure that the driver does not read this log page if the
* controller returns a NS_ATTR_CHANGED AEN.
*
* Reading of this log page can alternatively be disabled by setting the
* disable_read_changed_ns_list_log_page flag in the spdk_nvme_ctrlr_opts
* when attaching the controller.
*
* \param ctrlr NVMe controller on which to disable the log page read.
*/
void spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page(struct spdk_nvme_ctrlr *ctrlr);
/**
* Opaque handle to a queue pair.
*

View File

@ -4522,6 +4522,12 @@ spdk_nvme_ctrlr_register_aer_callback(struct spdk_nvme_ctrlr *ctrlr,
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
}
void
spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page(struct spdk_nvme_ctrlr *ctrlr)
{
ctrlr->opts.disable_read_changed_ns_list_log_page = true;
}
void
spdk_nvme_ctrlr_register_timeout_callback(struct spdk_nvme_ctrlr *ctrlr,
uint64_t timeout_io_us, uint64_t timeout_admin_us,

View File

@ -63,6 +63,7 @@
spdk_nvme_ctrlr_is_log_page_supported;
spdk_nvme_ctrlr_is_feature_supported;
spdk_nvme_ctrlr_register_aer_callback;
spdk_nvme_ctrlr_disable_read_changed_ns_list_log_page;
spdk_nvme_ctrlr_register_timeout_callback;
spdk_nvme_ctrlr_get_default_io_qpair_opts;
spdk_nvme_ctrlr_alloc_io_qpair;