nvme: Handle inactive but allocated namespaces

Namespaces can be allocated but inactive, which causes
the identify namespace command to fail. Handle this
case so that attaching to the controller does not fail.

Change-Id: I9d692f8e7841a9315a737b0a5e44d9b4e4484a13
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Ben Walker 2016-10-03 10:52:17 -07:00
parent d31df7042a
commit db69cad95c

View File

@ -60,8 +60,17 @@ int nvme_ns_identify_update(struct spdk_nvme_ns *ns)
pthread_mutex_unlock(&ns->ctrlr->ctrlr_lock);
}
if (spdk_nvme_cpl_is_error(&status.cpl)) {
SPDK_ERRLOG("nvme_identify_namespace failed\n");
return -ENXIO;
/* This can occur if the namespace is not active. Simply zero the
* namespace data and continue. */
memset(nsdata, 0, sizeof(*nsdata));
ns->stripe_size = 0;
ns->sector_size = 0;
ns->md_size = 0;
ns->pi_type = 0;
ns->sectors_per_max_io = 0;
ns->sectors_per_stripe = 0;
ns->flags = 0;
return 0;
}
ns->sector_size = 1 << nsdata->lbaf[nsdata->flbas.format].lbads;