Skip to content

Commit 9ba8091

Browse files
committed
Sanitize zns command arguments
With the recent up the calling convention has been sanitzed to always have the 'timeout' argument as second-to-last, and the 'result' as the laster argument. Modify the zns commands accordingly. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent c6d121a commit 9ba8091

3 files changed

Lines changed: 52 additions & 48 deletions

File tree

src/nvme/ioctl.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,9 +2033,10 @@ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len,
20332033
return nvme_submit_io_passthru(fd, &cmd, result);
20342034
}
20352035

2036-
int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba, bool select_all,
2037-
__u32 timeout, enum nvme_zns_send_action zsa,
2038-
__u32 data_len, void *data, __u32 *result)
2036+
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+
void *data, __u32 timeout, __u32 *result)
20392040
{
20402041
__u32 cdw10 = slba & 0xffffffff;
20412042
__u32 cdw11 = slba >> 32;
@@ -2056,10 +2057,10 @@ int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba, bool select_all,
20562057
return nvme_submit_io_passthru(fd, &cmd, result);
20572058
}
20582059

2059-
int nvme_zns_mgmt_recv(int fd, __u32 nsid, __u64 slba, __u32 timeout,
2060+
int nvme_zns_mgmt_recv(int fd, __u32 nsid, __u64 slba,
20602061
enum nvme_zns_recv_action zra, __u16 zrasf,
20612062
bool zras_feat, __u32 data_len, void *data,
2062-
__u32 *result)
2063+
__u32 timeout, __u32 *result)
20632064
{
20642065
__u32 cdw10 = slba & 0xffffffff;
20652066
__u32 cdw11 = slba >> 32;
@@ -2083,10 +2084,11 @@ int nvme_zns_mgmt_recv(int fd, __u32 nsid, __u64 slba, __u32 timeout,
20832084
return nvme_submit_io_passthru(fd, &cmd, result);
20842085
}
20852086

2086-
int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba, __u32 timeout,
2087-
bool extended, enum nvme_zns_report_options opts,
2088-
bool partial, __u32 data_len, void *data,
2089-
__u32 *result)
2087+
int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba,
2088+
enum nvme_zns_report_options opts,
2089+
bool extended, bool partial,
2090+
__u32 data_len, void *data,
2091+
__u32 timeout, __u32 *result)
20902092
{
20912093
BUILD_ASSERT(sizeof(struct nvme_zns_desc) == 64);
20922094
enum nvme_zns_recv_action zra;
@@ -2096,8 +2098,8 @@ int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba, __u32 timeout,
20962098
else
20972099
zra = NVME_ZNS_ZRA_REPORT_ZONES;
20982100

2099-
return nvme_zns_mgmt_recv(fd, nsid, slba, timeout, zra, opts, partial,
2100-
data_len, data, result);
2101+
return nvme_zns_mgmt_recv(fd, nsid, slba, zra, opts, partial,
2102+
data_len, data, timeout, result);
21012103
}
21022104

21032105
int nvme_zns_append(int fd, __u32 nsid, __u64 zslba, __u16 nlb, __u16 control,

src/nvme/ioctl.h

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,80 +2711,82 @@ int nvme_resv_report(int fd, __u32 nsid, bool eds, __u32 len,
27112711
* nvme_zns_mgmt_send() -
27122712
* @fd: File descriptor of nvme device
27132713
* @nsid: Namespace ID
2714-
* @slba:
2715-
* @select_all:
2714+
* @slba: Starting logical block address
2715+
* @zsa: Zone send action
2716+
* @select_all: Select all flag
2717+
* @data_len: Length of @data
2718+
* @data: Userspace address of the data
27162719
* @timeout: timeout in ms
2717-
* @zsa:
2718-
* @data_len:
2719-
* @data:
27202720
* @result: The command completion result from CQE dword0
27212721
*
27222722
* Return: The nvme command status if a response was received (see
27232723
* &enum nvme_status_field) or -1 with errno set otherwise.
27242724
*/
2725-
int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba, bool select_all,
2726-
__u32 timeout, enum nvme_zns_send_action zsa,
2727-
__u32 data_len, void *data, __u32 *result);
2725+
int nvme_zns_mgmt_send(int fd, __u32 nsid, __u64 slba,
2726+
enum nvme_zns_send_action zsa, bool select_all,
2727+
__u32 data_len, void *data,
2728+
__u32 timeout, __u32 *result);
27282729

27292730

27302731
/**
27312732
* nvme_zns_mgmt_recv() -
27322733
* @fd: File descriptor of nvme device
27332734
* @nsid: Namespace ID
2734-
* @slba:
2735+
* @slba: Starting logical block address
2736+
* @zra: zone receive action
2737+
* @zrasf: Zone receive action specific field
2738+
* @zras_feat: Zone receive action specific features
2739+
* @data_len: Length of @data
2740+
* @data: Userspace address of the data
27352741
* @timeout: timeout in ms
2736-
* @zra:
2737-
* @zrasf:
2738-
* @zras_feat:
2739-
* @data_len:
2740-
* @data:
27412742
* @result: The command completion result from CQE dword0
27422743
*
27432744
* Return: The nvme command status if a response was received (see
27442745
* &enum nvme_status_field) or -1 with errno set otherwise.
27452746
*/
2746-
int nvme_zns_mgmt_recv(int fd, __u32 nsid, __u64 slba, __u32 timeout,
2747+
int nvme_zns_mgmt_recv(int fd, __u32 nsid, __u64 slba,
27472748
enum nvme_zns_recv_action zra, __u16 zrasf,
27482749
bool zras_feat, __u32 data_len, void *data,
2749-
__u32 *result);
2750+
__u32 timeout, __u32 *result);
27502751

27512752
/**
27522753
* nvme_zns_report_zones() - Return the list of zones
27532754
* @fd: File descriptor of nvme device
27542755
* @nsid: Namespace ID
27552756
* @slba: Starting LBA
2756-
* @timeout: timeout in ms
2757-
* @extended: Extended report
27582757
* @opts: Reporting options
2758+
* @extended: Extended report
27592759
* @partial: Partial report requested
27602760
* @data_len: Length of the data buffer
2761-
* @data: Data buffer
2761+
* @data: Userspace address of the report zones data
2762+
* @timeout: timeout in ms
27622763
* @result: The command completion result from CQE dword0
27632764
*
27642765
* Return: The nvme command status if a response was received (see
27652766
* &enum nvme_status_field) or -1 with errno set otherwise.
27662767
*/
2767-
int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba, __u32 timeout,
2768-
bool extended, enum nvme_zns_report_options opts,
2769-
bool partial, __u32 data_len, void *data,
2770-
__u32 *result);
2768+
int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba,
2769+
enum nvme_zns_report_options opts,
2770+
bool extended, bool partial,
2771+
__u32 data_len, void *data,
2772+
__u32 timeout, __u32 *result);
27712773

27722774
/**
2773-
* nvme_zns_append() -
2775+
* nvme_zns_append() - Append data to a zone
27742776
* @fd: File descriptor of nvme device
27752777
* @nsid: Namespace ID
2776-
* @zslba:
2777-
* @nlb:
2778+
* @zslba: Zone start logical block address
2779+
* @nlb: Number of logical blocks
27782780
* @control:
2779-
* @ilbrt:
2780-
* @lbat:
2781-
* @lbam:
2782-
* @data_len:
2783-
* @data:
2784-
* @metadata_len:
2785-
* @metadata:
2786-
* @timeout:
2787-
* @result:
2781+
* @ilbrt: Initial logical block reference tag
2782+
* @lbat: Logical block application tag
2783+
* @lbatm: Logical block application tag mask
2784+
* @data_len: Length of @data
2785+
* @data: Userspace address of the data
2786+
* @metadata_len: Length of @metadata
2787+
* @metadata: Userspace address of the metadata
2788+
* @timeout: Timeout in ms
2789+
* @result: The command completion result from CQE dword0
27882790
*
27892791
* Return: The nvme command status if a response was received (see
27902792
* &enum nvme_status_field) or -1 with errno set otherwise.

test/zns.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ static void show_zns_properties(nvme_ns_t n)
4646
printf("zasl:%u\n", zns_ctrl.zasl);
4747

4848
if (nvme_zns_mgmt_recv(nvme_ns_get_fd(n), nvme_ns_get_nsid(n), 0,
49-
NVME_DEFAULT_IOCTL_TIMEOUT,
5049
NVME_ZNS_ZRA_REPORT_ZONES,
5150
NVME_ZNS_ZRAS_REPORT_ALL,
52-
0, 0x1000, (void *)zr, &result)) {
51+
true, 0x1000, (void *)zr,
52+
NVME_DEFAULT_IOCTL_TIMEOUT, &result)) {
5353
fprintf(stderr, "failed to report zones, result %x\n",
5454
le32_to_cpu(result));
5555
return;

0 commit comments

Comments
 (0)