From fc93fb68725d6bff59e99e735220f8d7d646c88f Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 13 Jan 2022 17:59:20 +0100 Subject: [PATCH] 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 --- src/nvme/ioctl.h | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index 7a28363d..850cf8d6 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -3565,49 +3565,51 @@ static inline int nvme_flush(int fd, __u32 nsid) { /** * nvme_io_args - Arguments for NVMe I/O commands * @fd: File descriptor of nvme device + * @result: The command completion result from CQE dword0 + * @timeout: Timeout in ms * @nsid: Namespace ID + * @data: Pointer to user address of the data buffer + * @metadata: Pointer to user address of the metadata buffer * @slba: Starting logical block - * @nblocks: Number of logical blocks to send (0's based value) + * @nbl: Number of logical blocks to send (0's based value) * @control: Command control flags, see &enum nvme_io_control_flags. - * @dsm: Data set management attributes, see &enum nvme_io_dsm_flags - * @reftag: This field specifies the Initial Logical Block Reference Tag - * expected value. Used only if the namespace is formatted to use - * end-to-end protection information. * @apptag: This field specifies the Application Tag Mask expected value. - * Used only if the namespace is formatted to use end-to-end - * protection information. + * Used only if the namespace is formatted to use end-to-end + * protection information. * @appmask: This field specifies the Application Tag expected value. Used - * only if the namespace is formatted to use end-to-end protection - * information. + * only if the namespace is formatted to use end-to-end protection + * information. + * @reftag: This field specifies the Initial Logical Block Reference Tag + * expected value. Used only if the namespace is formatted to use + * end-to-end protection information. + * @data_len: Length of user buffer, @data, in bytes * @storage_tag: This filed specifies Variable Sized Expected Logical Block * Storage Tag (ELBST) and Expected Logical Block Reference * Tag (ELBRT) - * @data_len: Length of user buffer, @data, in bytes - * @data: Pointer to user address of the data buffer * @metadata_len:Length of user buffer, @metadata, in bytes - * @metadata: Pointer to user address of the metadata buffer - * @timeout: Timeout in ms + * @dsm: Data set management attributes, see &enum nvme_io_dsm_flags + * @dspec: Directive specific value */ struct nvme_io_args { int args_size; int fd; + __u32 *result; + __u32 timeout; __u32 nsid; + void *data; + void *metadata; __u64 slba; __u16 nlb; __u16 control; - __u8 dsm; - __u8 dspec; - __u32 reftag; __u16 apptag; __u16 appmask; - __u64 storage_tag; + __u32 reftag; __u32 data_len; - void *data; + __u64 storage_tag; __u32 metadata_len; - void *metadata; - __u32 timeout; - __u32 *result; -}; + __u8 dsm; + __u8 dspec; +} __attribute__((__packed__, aligned(__alignof__(__u64)))); /** * nvme_io() - Submit an nvme user I/O command -- 2.50.1