From db69cad95c4d85220c7e06b323fe381605c84ea3 Mon Sep 17 00:00:00 2001 From: Ben Walker Date: Mon, 3 Oct 2016 10:52:17 -0700 Subject: [PATCH] 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 --- lib/nvme/nvme_ns.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/nvme/nvme_ns.c b/lib/nvme/nvme_ns.c index 7a8170f92..086758f44 100644 --- a/lib/nvme/nvme_ns.c +++ b/lib/nvme/nvme_ns.c @@ -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;