Commit 82db40db authored by Changpeng Liu's avatar Changpeng Liu
Browse files

spdk: add reservation support flag to NVMe namespace



A namespace indicates support for reservations by reporting a non-zero
value in the Reservation Capabilities field in the Identify Namespace
data structure, and controller indicates support for reservation in the
Identify Controller data structure, Here we used namespace field as the
support flag.

Change-Id: I0e1e29548aa3fc8b6d3bbeb4149ec4864316f092
Signed-off-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 81f40464
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -342,6 +342,8 @@ print_namespace(struct nvme_namespace *ns)
	       (flags & NVME_NS_DEALLOCATE_SUPPORTED) ? "Supported" : "Not Supported");
	printf("Flush:                       %s\n",
	       (flags & NVME_NS_FLUSH_SUPPORTED) ? "Supported" : "Not Supported");
	printf("Reservation:                 %s\n",
	       (flags & NVME_NS_RESERVATION_SUPPORTED) ? "Supported" : "Not Supported");
	printf("Size (in LBAs):              %lld (%lldM)\n",
	       (long long)nsdata->nsze,
	       (long long)nsdata->nsze / 1024 / 1024);
+1 −0
Original line number Diff line number Diff line
@@ -355,6 +355,7 @@ uint64_t nvme_ns_get_size(struct nvme_namespace *ns);
enum nvme_namespace_flags {
	NVME_NS_DEALLOCATE_SUPPORTED	= 0x1, /**< The deallocate command is supported */
	NVME_NS_FLUSH_SUPPORTED		= 0x2, /**< The flush command is supported */
	NVME_NS_RESERVATION_SUPPORTED	= 0x4, /**< The reservation command is supported */
};

/**
+20 −18
Original line number Diff line number Diff line
@@ -794,6 +794,7 @@ struct nvme_namespace_data {
	} nmic;

	/** reservation capabilities */
	union {
		struct {
			/** supports persist through power loss */
			uint8_t		persist : 1;
@@ -818,7 +819,8 @@ struct nvme_namespace_data {

			uint8_t		reserved : 1;
		} rescap;

		uint8_t		raw;
	} nsrescap;
	/** format progress indicator */
	uint8_t			fpi;

+4 −0
Original line number Diff line number Diff line
@@ -126,6 +126,10 @@ nvme_ns_construct(struct nvme_namespace *ns, uint16_t id,
		ns->flags |= NVME_NS_FLUSH_SUPPORTED;
	}

	if (nsdata->nsrescap.raw) {
		ns->flags |= NVME_NS_RESERVATION_SUPPORTED;
	}

	return 0;
}