Skip to content

Commit fc93fb6

Browse files
committed
ioctl: Rearrange members in nvme_io_args
Avoid any holes in the struct by rearranging the members. Also add the attribute packed to struct definition to reduce ABI breakage. struct nvme_io_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u32 nsid; /* 20 4 */ void * data; /* 24 8 */ void * metadata; /* 32 8 */ __u64 slba; /* 40 8 */ __u16 nlb; /* 48 2 */ __u16 control; /* 50 2 */ __u16 apptag; /* 52 2 */ __u16 appmask; /* 54 2 */ __u32 reftag; /* 56 4 */ __u32 data_len; /* 60 4 */ /* --- cacheline 1 boundary (64 bytes) --- */ __u64 storage_tag; /* 64 8 */ __u32 metadata_len; /* 72 4 */ __u8 dsm; /* 76 1 */ __u8 dspec; /* 77 1 */ /* size: 80, cachelines: 2, members: 18 */ /* padding: 2 */ /* last cacheline: 16 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner <[email protected]>
1 parent 57af2be commit fc93fb6

1 file changed

Lines changed: 24 additions & 22 deletions

File tree

src/nvme/ioctl.h

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3565,49 +3565,51 @@ static inline int nvme_flush(int fd, __u32 nsid) {
35653565
/**
35663566
* nvme_io_args - Arguments for NVMe I/O commands
35673567
* @fd: File descriptor of nvme device
3568+
* @result: The command completion result from CQE dword0
3569+
* @timeout: Timeout in ms
35683570
* @nsid: Namespace ID
3571+
* @data: Pointer to user address of the data buffer
3572+
* @metadata: Pointer to user address of the metadata buffer
35693573
* @slba: Starting logical block
3570-
* @nblocks: Number of logical blocks to send (0's based value)
3574+
* @nbl: Number of logical blocks to send (0's based value)
35713575
* @control: Command control flags, see &enum nvme_io_control_flags.
3572-
* @dsm: Data set management attributes, see &enum nvme_io_dsm_flags
3573-
* @reftag: This field specifies the Initial Logical Block Reference Tag
3574-
* expected value. Used only if the namespace is formatted to use
3575-
* end-to-end protection information.
35763576
* @apptag: This field specifies the Application Tag Mask expected value.
3577-
* Used only if the namespace is formatted to use end-to-end
3578-
* protection information.
3577+
* Used only if the namespace is formatted to use end-to-end
3578+
* protection information.
35793579
* @appmask: This field specifies the Application Tag expected value. Used
3580-
* only if the namespace is formatted to use end-to-end protection
3581-
* information.
3580+
* only if the namespace is formatted to use end-to-end protection
3581+
* information.
3582+
* @reftag: This field specifies the Initial Logical Block Reference Tag
3583+
* expected value. Used only if the namespace is formatted to use
3584+
* end-to-end protection information.
3585+
* @data_len: Length of user buffer, @data, in bytes
35823586
* @storage_tag: This filed specifies Variable Sized Expected Logical Block
35833587
* Storage Tag (ELBST) and Expected Logical Block Reference
35843588
* Tag (ELBRT)
3585-
* @data_len: Length of user buffer, @data, in bytes
3586-
* @data: Pointer to user address of the data buffer
35873589
* @metadata_len:Length of user buffer, @metadata, in bytes
3588-
* @metadata: Pointer to user address of the metadata buffer
3589-
* @timeout: Timeout in ms
3590+
* @dsm: Data set management attributes, see &enum nvme_io_dsm_flags
3591+
* @dspec: Directive specific value
35903592
*/
35913593
struct nvme_io_args {
35923594
int args_size;
35933595
int fd;
3596+
__u32 *result;
3597+
__u32 timeout;
35943598
__u32 nsid;
3599+
void *data;
3600+
void *metadata;
35953601
__u64 slba;
35963602
__u16 nlb;
35973603
__u16 control;
3598-
__u8 dsm;
3599-
__u8 dspec;
3600-
__u32 reftag;
36013604
__u16 apptag;
36023605
__u16 appmask;
3603-
__u64 storage_tag;
3606+
__u32 reftag;
36043607
__u32 data_len;
3605-
void *data;
3608+
__u64 storage_tag;
36063609
__u32 metadata_len;
3607-
void *metadata;
3608-
__u32 timeout;
3609-
__u32 *result;
3610-
};
3610+
__u8 dsm;
3611+
__u8 dspec;
3612+
} __attribute__((__packed__, aligned(__alignof__(__u64))));
36113613

36123614
/**
36133615
* nvme_io() - Submit an nvme user I/O command

0 commit comments

Comments
 (0)