Skip to content

Commit 726d75a

Browse files
authored
Merge pull request #143 from sc108-lee/tp4076
zns: Add support for zone random write area (zrwa)
2 parents a219a9f + fe906ff commit 726d75a

4 files changed

Lines changed: 47 additions & 21 deletions

File tree

src/nvme/ioctl.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,8 @@ enum nvme_cmd_dword_fields {
294294
NVME_GET_LBA_STATUS_CDW13_ATYPE_SHIFT = 24,
295295
NVME_GET_LBA_STATUS_CDW13_RL_MASK = 0xffff,
296296
NVME_GET_LBA_STATUS_CDW13_ATYPE_MASK = 0xff,
297+
NVME_ZNS_MGMT_SEND_ZSASO_SHIFT = 9,
298+
NVME_ZNS_MGMT_SEND_ZSASO_MASK = 0x1,
297299
NVME_ZNS_MGMT_SEND_SEL_SHIFT = 8,
298300
NVME_ZNS_MGMT_SEND_SEL_MASK = 0x1,
299301
NVME_ZNS_MGMT_SEND_ZSA_SHIFT = 0,
@@ -2034,13 +2036,14 @@ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len,
20342036
}
20352037

20362038
int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba,
2037-
enum nvme_zns_send_action zsa,
2038-
bool select_all, __u32 data_len,
2039+
enum nvme_zns_send_action zsa, bool select_all,
2040+
__u8 zsaso, __u32 data_len,
20392041
void *data, __u32 timeout, __u32 *result)
20402042
{
20412043
__u32 cdw10 = slba & 0xffffffff;
20422044
__u32 cdw11 = slba >> 32;
2043-
__u32 cdw13 = NVME_SET(!!select_all, ZNS_MGMT_SEND_SEL) |
2045+
__u32 cdw13 = NVME_SET(zsaso, ZNS_MGMT_SEND_ZSASO) |
2046+
NVME_SET(!!select_all, ZNS_MGMT_SEND_SEL) |
20442047
NVME_SET(zsa, ZNS_MGMT_SEND_ZSA);
20452048

20462049
struct nvme_passthru_cmd cmd = {

src/nvme/ioctl.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2714,6 +2714,7 @@ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len,
27142714
* @slba: Starting logical block address
27152715
* @zsa: Zone send action
27162716
* @select_all: Select all flag
2717+
* @zsaso: Zone Send Action Specific Option
27172718
* @data_len: Length of @data
27182719
* @data: Userspace address of the data
27192720
* @timeout: timeout in ms
@@ -2723,7 +2724,7 @@ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len,
27232724
* &enum nvme_status_field) or -1 with errno set otherwise.
27242725
*/
27252726
int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba,
2726-
enum nvme_zns_send_action zsa, bool select_all,
2727+
enum nvme_zns_send_action zsa, bool select_all, __u8 zsaso,
27272728
__u32 data_len, void *data,
27282729
__u32 timeout, __u32 *result);
27292730

src/nvme/types.h

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2071,14 +2071,18 @@ struct nvme_zns_lbafe {
20712071
/**
20722072
* struct nvme_zns_id_ns - Zoned Namespace Command Set Specific
20732073
* Identify Namespace Data Structure
2074-
* @zoc: Zone Operation Characteristics
2075-
* @ozcs: Optional Zoned Command Support
2076-
* @mar: Maximum Active Resources
2077-
* @mor: Maximum Open Resources
2078-
* @rrl: Reset Recommended Limit
2079-
* @frl: Finish Recommended Limit
2080-
* @lbafe: LBA Format Extension
2081-
* @vs: Vendor Specific * struct nvme_zns_id_ns -
2074+
* @zoc: Zone Operation Characteristics
2075+
* @ozcs: Optional Zoned Command Support
2076+
* @mar: Maximum Active Resources
2077+
* @mor: Maximum Open Resources
2078+
* @rrl: Reset Recommended Limit
2079+
* @frl: Finish Recommended Limit
2080+
* @numzrwa: Number of ZRWA Resources
2081+
* @zrwafg: ZRWA Flush Granularity
2082+
* @zrwasz: ZRWA Size
2083+
* @zrwacap: ZRWA Capability
2084+
* @lbafe: LBA Format Extension
2085+
* @vs: Vendor Specific
20822086
*/
20832087
struct nvme_zns_id_ns {
20842088
__le16 zoc;
@@ -2093,7 +2097,11 @@ struct nvme_zns_id_ns {
20932097
__le32 frl1;
20942098
__le32 frl2;
20952099
__le32 frl3;
2096-
__u8 rsvd44[2772];
2100+
__le32 numzrwa;
2101+
__le16 zrwafg;
2102+
__le16 zrwasz;
2103+
__u8 zrwacap;
2104+
__u8 rsvd53[2763];
20972105
struct nvme_zns_lbafe lbafe[64];
20982106
__u8 vs[256];
20992107
};
@@ -3444,6 +3452,7 @@ enum nvme_zns_za {
34443452
NVME_ZNS_ZA_ZFC = 1 << 0,
34453453
NVME_ZNS_ZA_FZR = 1 << 1,
34463454
NVME_ZNS_ZA_RZR = 1 << 2,
3455+
NVME_ZNS_ZA_ZRWAV = 1 << 3,
34473456
NVME_ZNS_ZA_ZDEV = 1 << 7,
34483457
};
34493458

@@ -4830,6 +4839,14 @@ struct nvme_mi_vpd_hdr {
48304839
* command is re-submitted to any controller
48314840
* in the NVM subsystem, then that
48324841
* re-submitted command is expected to fail.
4842+
* @NVME_SC_ZNS_INVALID_OP_REQUEST: Invalid Zone Operation Request:
4843+
* The operation requested is invalid. This may be due to
4844+
* various conditions, including: attempting to allocate a
4845+
* ZRWA when a zone is not in the ZSE:Empty state; or
4846+
* invalid Flush Explicit ZRWA Range Send Zone Action
4847+
* operation.
4848+
* @NVME_SC_ZNS_ZRWA_RESOURCES_UNAVAILABLE: ZRWA Resources Unavailable:
4849+
* No ZRWAs are available.
48334850
* @NVME_SC_ZNS_BOUNDARY_ERROR: Zone Boundary Error: The command specifies
48344851
* logical blocks in more than one zone.
48354852
* @NVME_SC_ZNS_FULL: Zone Is Full: The accessed zone is in the
@@ -4984,14 +5001,16 @@ enum nvme_status_field {
49845001
/*
49855002
* I/O Command Set Specific - ZNS commands:
49865003
*/
4987-
NVME_SC_ZNS_BOUNDARY_ERROR = 0xb8,
4988-
NVME_SC_ZNS_FULL = 0xb9,
4989-
NVME_SC_ZNS_READ_ONLY = 0xba,
4990-
NVME_SC_ZNS_OFFLINE = 0xbb,
4991-
NVME_SC_ZNS_INVALID_WRITE = 0xbc,
4992-
NVME_SC_ZNS_TOO_MANY_ACTIVE = 0xbd,
4993-
NVME_SC_ZNS_TOO_MANY_OPENS = 0xbe,
4994-
NVME_SC_ZNS_INVAL_TRANSITION = 0xbf,
5004+
NVME_SC_ZNS_INVALID_OP_REQUEST = 0xb6,
5005+
NVME_SC_ZNS_ZRWA_RESOURCES_UNAVAILABLE = 0xb7,
5006+
NVME_SC_ZNS_BOUNDARY_ERROR = 0xb8,
5007+
NVME_SC_ZNS_FULL = 0xb9,
5008+
NVME_SC_ZNS_READ_ONLY = 0xba,
5009+
NVME_SC_ZNS_OFFLINE = 0xbb,
5010+
NVME_SC_ZNS_INVALID_WRITE = 0xbc,
5011+
NVME_SC_ZNS_TOO_MANY_ACTIVE = 0xbd,
5012+
NVME_SC_ZNS_TOO_MANY_OPENS = 0xbe,
5013+
NVME_SC_ZNS_INVAL_TRANSITION = 0xbf,
49955014

49965015
/*
49975016
* Media and Data Integrity Errors:
@@ -5877,6 +5896,7 @@ enum nvme_zns_send_action {
58775896
NVME_ZNS_ZSA_RESET = 0x4,
58785897
NVME_ZNS_ZSA_OFFLINE = 0x5,
58795898
NVME_ZNS_ZSA_SET_DESC_EXT = 0x10,
5899+
NVME_ZNS_ZSA_ZRWA_FLUSH = 0x11,
58805900
};
58815901

58825902
/**

src/nvme/util.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ static const char * const nvm_status[] = {
243243
[NVME_SC_INVALID_PI] = "Invalid Protection Information: The command's Protection Information Field settings are invalid for the namespace's Protection Information format",
244244
[NVME_SC_READ_ONLY] = "Attempted Write to Read Only Range: The LBA range specified contains read-only blocks",
245245
[NVME_SC_CMD_SIZE_LIMIT_EXCEEDED] = "Command Size Limit Exceeded",
246+
[NVME_SC_ZNS_INVALID_OP_REQUEST] = "Invalid Zone Operation Request: The operation requested is invalid",
247+
[NVME_SC_ZNS_ZRWA_RESOURCES_UNAVAILABLE] = "ZRWA Resources Unavailable: No ZRWAs are available",
246248
[NVME_SC_ZNS_BOUNDARY_ERROR] = "Zoned Boundary Error: Invalid Zone Boundary crossing",
247249
[NVME_SC_ZNS_FULL] = "Zone Is Full: The accessed zone is in ZSF:Full state",
248250
[NVME_SC_ZNS_READ_ONLY] = "Zone Is Read Only: The accessed zone is in ZSRO:Read Only state",

0 commit comments

Comments
 (0)