nvme: Eliminate identify errors to Discovery ctrlr

The nvme/identify cmd issued some cmds to a ctrlr irrespective
of its type, and when the target was a Discovery ctrlr which only
accepts a very limited cmd set, that would result in errors observable
both on the initiator side (from nvme/identify) and in the output on
the target (nvmf_tgt).  Introduce new API, spdk_nvme_ctrlr_is_discovery(),
and alter identify to make use of that in determining which commands
to send to the target.

Change-Id: I974a569843f1d2b9e1ece7bd3bf9ceee1bfae872
Signed-off-by: Lance Hartmann <lance.hartmann@oracle.com>
Reviewed-on: https://review.gerrithub.io/436225
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
Lance Hartmann 2018-12-05 16:57:53 -05:00 committed by Ben Walker
parent 37af0cc930
commit e865a52415
4 changed files with 54 additions and 16 deletions

View File

@ -18,6 +18,9 @@ Add a new TCP/IP transport(located in lib/nvme/nvme_tcp.c) in nvme driver. With
this new transport, it can be used to connect the NVMe-oF target with the
same TCP/IP support.
Added API, spdk_nvme_ctrlr_is_discovery(), to indicate whether the ctrlr
arg refers to a Discovery Controller or not.
### NVMe-oF Target
The `spdk_nvmf_tgt_opts` struct has been deprecated in favor of `spdk_nvmf_transport_opts`.

View File

@ -405,25 +405,34 @@ get_log_pages(struct spdk_nvme_ctrlr *ctrlr)
{
const struct spdk_nvme_ctrlr_data *cdata;
outstanding_commands = 0;
bool is_discovery = spdk_nvme_ctrlr_is_discovery(ctrlr);
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
if (get_error_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Error Log Page failed\n");
}
if (!is_discovery) {
/*
* Only attempt to retrieve the following log pages
* when the NVM subsystem that's being targeted is
* NOT the Discovery Controller which only fields
* a Discovery Log Page.
*/
if (get_error_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Error Log Page failed\n");
}
if (get_health_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Log Page (SMART/health) failed\n");
}
if (get_health_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Log Page (SMART/health) failed\n");
}
if (get_firmware_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Log Page (Firmware Slot Information) failed\n");
if (get_firmware_log_page(ctrlr) == 0) {
outstanding_commands++;
} else {
printf("Get Log Page (Firmware Slot Information) failed\n");
}
}
if (cdata->lpa.celp) {
@ -459,7 +468,7 @@ get_log_pages(struct spdk_nvme_ctrlr *ctrlr)
}
if (get_discovery_log_page(ctrlr) == 0) {
if (is_discovery && (get_discovery_log_page(ctrlr) == 0)) {
outstanding_commands++;
}
@ -867,7 +876,15 @@ print_controller(struct spdk_nvme_ctrlr *ctrlr, const struct spdk_nvme_transport
cap = spdk_nvme_ctrlr_get_regs_cap(ctrlr);
vs = spdk_nvme_ctrlr_get_regs_vs(ctrlr);
get_features(ctrlr);
if (!spdk_nvme_ctrlr_is_discovery(ctrlr)) {
/*
* Discovery Controller only supports the
* IDENTIFY and GET_LOG_PAGE cmd set, so only
* attempt GET_FEATURES when NOT targeting a
* Discovery Controller.
*/
get_features(ctrlr);
}
get_log_pages(ctrlr);
cdata = spdk_nvme_ctrlr_get_data(ctrlr);

View File

@ -183,6 +183,15 @@ struct spdk_nvme_ctrlr_opts {
bool data_digest;
};
/**
* Indicate whether a ctrlr handle is associated with a Discovery controller.
*
* \param ctrlr Opaque handle to NVMe controller.
*
* \return true if a discovery controller, else false.
*/
bool spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr);
/**
* Get the default options for the creation of a specific NVMe controller.
*

View File

@ -2733,3 +2733,12 @@ spdk_nvme_ctrlr_free_cmb_io_buffer(struct spdk_nvme_ctrlr *ctrlr, void *buf, siz
nvme_robust_mutex_unlock(&ctrlr->ctrlr_lock);
}
}
bool
spdk_nvme_ctrlr_is_discovery(struct spdk_nvme_ctrlr *ctrlr)
{
assert(ctrlr);
return !strncmp(ctrlr->trid.subnqn, SPDK_NVMF_DISCOVERY_NQN,
strlen(SPDK_NVMF_DISCOVERY_NQN));
}