From 301c99ee6cbafe65a0b024d3f97cb6fef1fd842e Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Thu, 13 Jan 2022 15:47:05 +0100 Subject: [PATCH] ioctl: Rearrange members in nvme_capacity_mgmt_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_capacity_mgmt_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u32 cdw11; /* 20 4 */ __u32 cdw12; /* 24 4 */ __u16 element_id; /* 28 2 */ __u8 op; /* 30 1 */ /* size: 56, cachelines: 1, members: 11 */ /* padding: 6 */ /* last cacheline: 56 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner --- src/nvme/ioctl.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/nvme/ioctl.h b/src/nvme/ioctl.h index e687db2c..c4481702 100644 --- a/src/nvme/ioctl.h +++ b/src/nvme/ioctl.h @@ -3177,7 +3177,7 @@ struct nvme_directive_recv_args { __u32 data_len; void *data; __u16 dspec; -} __attribute__((__packed__)); +} __attribute__((packed, aligned(__alignof__(__u32*)))); /** * nvme_directive_recv() - Receive directive specific data @@ -3305,25 +3305,25 @@ static inline int nvme_directive_recv_stream_allocate(int fd, __u32 nsid, /** * nvme_capacity_mgmt_args - Arguments for the NVMe Capacity Management command * @fd: File descriptor of nvme device - * @op: Operation to be performed by the controller - * @element_id: Value specific to the value of the Operation field * @dw11: Least significant 32 bits of the capacity in bytes of the * Endurance Group or NVM Set to be created * @dw12: Most significant 32 bits of the capacity in bytes of the * Endurance Group or NVM Set to be created - * @timeout: Timeout in ms * @result: If successful, the CQE dword0 value + * @timeout: Timeout in ms + * @element_id: Value specific to the value of the Operation field + * @op: Operation to be performed by the controller */ struct nvme_capacity_mgmt_args { int args_size; int fd; - __u8 op; - __u16 element_id; + __u32 *result; + __u32 timeout; __u32 cdw11; __u32 cdw12; - __u32 timeout; - __u32 *result; -}; + __u16 element_id; + __u8 op; +} __attribute__((__packed__)); /** * nvme_capacity_mgmt() - -- 2.50.1