Commit 0d9279c5 authored by Changpeng Liu's avatar Changpeng Liu Committed by Ben Walker
Browse files

examples/nvme/identify: set features valid flag to false before getting new value



features are global variable and can be used for different controllers, e.g: there
are 2 controllers, the first one can support Arbitration feature, and the second
controller can't support Arbitration feature, the value from features[fid].valid
may contain the first drive's old value.

Change-Id: If020a0413a8a32e2be25ecccb5baf0a82d99371b
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/463480


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 5de38f95
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ struct feature {
	bool valid;
};

static struct feature features[256];
static struct feature features[256] = {};

static struct spdk_nvme_error_information_entry error_page[256];

@@ -180,11 +180,14 @@ static int
get_feature(struct spdk_nvme_ctrlr *ctrlr, uint8_t fid)
{
	struct spdk_nvme_cmd cmd = {};
	struct feature *feature = &features[fid];

	feature->valid = false;

	cmd.opc = SPDK_NVME_OPC_GET_FEATURES;
	cmd.cdw10 = fid;

	return spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, get_feature_completion, &features[fid]);
	return spdk_nvme_ctrlr_cmd_admin_raw(ctrlr, &cmd, NULL, 0, get_feature_completion, feature);
}

static void