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: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
Changpeng Liu 2016-01-27 11:10:01 +08:00
parent 81f4046402
commit 82db40dbd5
4 changed files with 27 additions and 18 deletions

View File

@ -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);

View File

@ -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 */
};
/**

View File

@ -794,31 +794,33 @@ struct nvme_namespace_data {
} nmic;
/** reservation capabilities */
struct {
/** supports persist through power loss */
uint8_t persist : 1;
union {
struct {
/** supports persist through power loss */
uint8_t persist : 1;
/** supports write exclusive */
uint8_t write_exclusive : 1;
/** supports write exclusive */
uint8_t write_exclusive : 1;
/** supports exclusive access */
uint8_t exclusive_access : 1;
/** supports exclusive access */
uint8_t exclusive_access : 1;
/** supports write exclusive - registrants only */
uint8_t write_exclusive_reg_only : 1;
/** supports write exclusive - registrants only */
uint8_t write_exclusive_reg_only : 1;
/** supports exclusive access - registrants only */
uint8_t exclusive_access_reg_only : 1;
/** supports exclusive access - registrants only */
uint8_t exclusive_access_reg_only : 1;
/** supports write exclusive - all registrants */
uint8_t write_exclusive_all_reg : 1;
/** supports write exclusive - all registrants */
uint8_t write_exclusive_all_reg : 1;
/** supports exclusive access - all registrants */
uint8_t exclusive_access_all_reg : 1;
uint8_t reserved : 1;
} rescap;
/** supports exclusive access - all registrants */
uint8_t exclusive_access_all_reg : 1;
uint8_t reserved : 1;
} rescap;
uint8_t raw;
} nsrescap;
/** format progress indicator */
uint8_t fpi;

View File

@ -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;
}