Commit db69cad9 authored by Ben Walker's avatar Ben Walker
Browse files

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: default avatarBen Walker <benjamin.walker@intel.com>
parent d31df704
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -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;