Skip to content

Commit f824455

Browse files
committed
ioctl: Rearrange members in nvme_directive_send_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_directive_send_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u32 nsid; /* 20 4 */ enum nvme_directive_send_doper doper; /* 24 4 */ enum nvme_directive_dtype dtype; /* 28 4 */ __u32 cdw12; /* 32 4 */ __u32 data_len; /* 36 4 */ void * data; /* 40 8 */ __u16 dspec; /* 48 2 */ /* size: 56, cachelines: 1, members: 10 */ /* padding: 6 */ /* last cacheline: 56 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner <[email protected]>
1 parent 15a2a84 commit f824455

1 file changed

Lines changed: 14 additions & 15 deletions

File tree

src/nvme/ioctl.h

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3030,7 +3030,7 @@ struct nvme_get_lba_status_args {
30303030
__u64 slba;
30313031
struct nvme_lba_status *lbas;
30323032
__u16 rl;
3033-
} __attribute__((__packed__));
3033+
} __attribute__((packed, aligned(__alignof__(__u64))));
30343034

30353035
/**
30363036
* nvme_get_lba_status() - Retrieve information on possibly unrecoverable LBAs
@@ -3047,29 +3047,28 @@ int nvme_get_lba_status(struct nvme_get_lba_status_args *args);
30473047
/**
30483048
* nvme_directive_send_args - Arguments for the NVMe Directive Send command
30493049
* @fd: File descriptor of nvme device
3050+
* @result: If successful, the CQE dword0 value
3051+
* @timeout: Timeout in ms
30503052
* @nsid: Namespace ID, if applicable
3051-
* @dspec: Directive specific field
30523053
* @doper: Directive send operation, see &enum nvme_directive_send_doper
30533054
* @dtype: Directive type, see &enum nvme_directive_dtype
30543055
* @dw12: Directive specific command dword12
30553056
* @data_len: Length of data payload in bytes
3056-
* @data: Usespace address of data payload
3057-
* @timeout: Timeout in ms
3058-
* @result: If successful, the CQE dword0 value
3057+
* @dspec: Directive specific field
30593058
*/
30603059
struct nvme_directive_send_args {
30613060
int args_size;
30623061
int fd;
3062+
__u32 *result;
3063+
__u32 timeout;
30633064
__u32 nsid;
3064-
__u16 dspec;
30653065
enum nvme_directive_send_doper doper;
30663066
enum nvme_directive_dtype dtype;
30673067
__u32 cdw12;
30683068
__u32 data_len;
30693069
void *data;
3070-
__u32 timeout;
3071-
__u32 *result;
3072-
};
3070+
__u16 dspec;
3071+
} __attribute__((__packed__));
30733072

30743073
/**
30753074
* nvme_directive_send() - Send directive command
@@ -3112,15 +3111,15 @@ static inline int nvme_directive_send_stream_release_identifier(int fd,
31123111
struct nvme_directive_send_args args = {
31133112
.args_size = sizeof(args),
31143113
.fd = fd,
3114+
.result = NULL,
3115+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
31153116
.nsid = nsid,
3116-
.dspec = stream_id,
31173117
.doper = NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_IDENTIFIER,
31183118
.dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
31193119
.cdw12 = 0,
31203120
.data_len = 0,
31213121
.data = NULL,
3122-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3123-
.result = NULL,
3122+
.dspec = stream_id,
31243123
};
31253124

31263125
return nvme_directive_send(&args);
@@ -3139,15 +3138,15 @@ static inline int nvme_directive_send_stream_release_resource(int fd, __u32 nsid
31393138
struct nvme_directive_send_args args = {
31403139
.args_size = sizeof(args),
31413140
.fd = fd,
3141+
.result = NULL,
3142+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
31423143
.nsid = nsid,
3143-
.dspec = 0,
31443144
.doper = NVME_DIRECTIVE_SEND_STREAMS_DOPER_RELEASE_RESOURCE,
31453145
.dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
31463146
.cdw12 = 0,
31473147
.data_len = 0,
31483148
.data = NULL,
3149-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3150-
.result = NULL,
3149+
.dspec = 0,
31513150
};
31523151

31533152
return nvme_directive_send(&args);

0 commit comments

Comments
 (0)