Skip to content

Commit f283430

Browse files
committed
ioctl: Rearrange members in nvme_directive_recv_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_recv_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_receive_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: 11 */ /* padding: 6 */ /* last cacheline: 56 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner <[email protected]>
1 parent f824455 commit f283430

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

src/nvme/ioctl.h

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3068,7 +3068,7 @@ struct nvme_directive_send_args {
30683068
__u32 data_len;
30693069
void *data;
30703070
__u16 dspec;
3071-
} __attribute__((__packed__));
3071+
} __attribute__((packed, aligned(__alignof__(__u32*))));
30723072

30733073
/**
30743074
* nvme_directive_send() - Send directive command
@@ -3155,29 +3155,29 @@ static inline int nvme_directive_send_stream_release_resource(int fd, __u32 nsid
31553155
/**
31563156
* nvme_directive_recv_args - Arguments for the NVMe Directive Receive command
31573157
* @fd: File descriptor of nvme device
3158+
* @result: If successful, the CQE dword0 value
3159+
* @timeout: Timeout in ms
31583160
* @nsid: Namespace ID, if applicable
3159-
* @dspec: Directive specific field
31603161
* @doper: Directive send operation, see &enum nvme_directive_send_doper
31613162
* @dtype: Directive type, see &enum nvme_directive_dtype
31623163
* @dw12: Directive specific command dword12
31633164
* @data_len: Length of data payload in bytes
31643165
* @data: Usespace address of data payload
3165-
* @timeout: Timeout in ms
3166-
* @result: If successful, the CQE dword0 value
3166+
* @dspec: Directive specific field
31673167
*/
31683168
struct nvme_directive_recv_args {
31693169
int args_size;
31703170
int fd;
3171+
__u32 *result;
3172+
__u32 timeout;
31713173
__u32 nsid;
3172-
__u16 dspec;
31733174
enum nvme_directive_receive_doper doper;
31743175
enum nvme_directive_dtype dtype;
31753176
__u32 cdw12;
31763177
__u32 data_len;
31773178
void *data;
3178-
__u32 timeout;
3179-
__u32 *result;
3180-
};
3179+
__u16 dspec;
3180+
} __attribute__((__packed__));
31813181

31823182
/**
31833183
* nvme_directive_recv() - Receive directive specific data
@@ -3202,15 +3202,15 @@ static inline int nvme_directive_recv_identify_parameters(int fd, __u32 nsid,
32023202
struct nvme_directive_recv_args args = {
32033203
.args_size = sizeof(args),
32043204
.fd = fd,
3205+
.result = NULL,
3206+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
32053207
.nsid = nsid,
3206-
.dspec = 0,
32073208
.doper = NVME_DIRECTIVE_RECEIVE_IDENTIFY_DOPER_PARAM,
32083209
.dtype = NVME_DIRECTIVE_DTYPE_IDENTIFY,
32093210
.cdw12 = 0,
32103211
.data_len = sizeof(*id),
32113212
.data = id,
3212-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3213-
.result = NULL,
3213+
.dspec = 0,
32143214
};
32153215

32163216
return nvme_directive_recv(&args);
@@ -3230,21 +3230,20 @@ static inline int nvme_directive_recv_stream_parameters(int fd, __u32 nsid,
32303230
struct nvme_directive_recv_args args = {
32313231
.args_size = sizeof(args),
32323232
.fd = fd,
3233+
.result = NULL,
3234+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
32333235
.nsid = nsid,
3234-
.dspec = 0,
32353236
.doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_PARAM,
32363237
.dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
32373238
.cdw12 = 0,
32383239
.data_len = sizeof(*parms),
32393240
.data = parms,
3240-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3241-
.result = NULL,
3241+
.dspec = 0,
32423242
};
32433243

32443244
return nvme_directive_recv(&args);
32453245
}
32463246

3247-
32483247
/**
32493248
* nvme_directive_recv_stream_status() -
32503249
* @fd: File descriptor of nvme device
@@ -3260,21 +3259,20 @@ static inline int nvme_directive_recv_stream_status(int fd, __u32 nsid,
32603259
struct nvme_directive_recv_args args = {
32613260
.args_size = sizeof(args),
32623261
.fd = fd,
3262+
.result = NULL,
3263+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
32633264
.nsid = nsid,
3264-
.dspec = 0,
32653265
.doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_STATUS,
32663266
.dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
32673267
.cdw12 = 0,
32683268
.data_len = sizeof(*id),
32693269
.data = id,
3270-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3271-
.result = NULL,
3270+
.dspec = 0,
32723271
};
32733272

32743273
return nvme_directive_recv(&args);
32753274
}
32763275

3277-
32783276
/**
32793277
* nvme_directive_recv_stream_allocate() -
32803278
* @fd: File descriptor of nvme device
@@ -3289,15 +3287,15 @@ static inline int nvme_directive_recv_stream_allocate(int fd, __u32 nsid,
32893287
struct nvme_directive_recv_args args = {
32903288
.args_size = sizeof(args),
32913289
.fd = fd,
3290+
.result = result,
3291+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
32923292
.nsid = nsid,
3293-
.dspec = 0,
32943293
.doper = NVME_DIRECTIVE_RECEIVE_STREAMS_DOPER_RESOURCE,
32953294
.dtype = NVME_DIRECTIVE_DTYPE_STREAMS,
32963295
.cdw12 = nsr,
32973296
.data_len = 0,
32983297
.data = NULL,
3299-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
3300-
.result = result,
3298+
.dspec = 0,
33013299
};
33023300

33033301
return nvme_directive_recv(&args);

0 commit comments

Comments
 (0)