Skip to content

Commit 4a1fefa

Browse files
committed
ioctl: Rearrange members in nvme_get_features_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_get_features_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u32 nsid; /* 20 4 */ enum nvme_get_features_sel sel; /* 24 4 */ __u32 cdw11; /* 28 4 */ __u32 data_len; /* 32 4 */ void * data; /* 36 8 */ __u8 fid; /* 44 1 */ __u8 uuidx; /* 45 1 */ /* size: 48, cachelines: 1, members: 11 */ /* padding: 2 */ /* last cacheline: 48 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner <[email protected]>
1 parent 4cc907d commit 4a1fefa

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

src/nvme/ioctl.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2231,30 +2231,30 @@ int nvme_set_features_write_protect(int fd, enum nvme_feat_nswpcfg_state state,
22312231
/**
22322232
* nvme_get_features_args - Arguments for the NVMe Admin Get Feature command
22332233
* @fd: File descriptor of nvme device
2234-
* @fid: Feature identifier, see &enum nvme_features_id
2234+
* @result: The command completion result from CQE dword0
2235+
* @timeout: Timeout in ms
22352236
* @nsid: Namespace ID, if applicable
22362237
* @sel: Select which type of attribute to return,
22372238
* see &enum nvme_get_features_sel
22382239
* @cdw11: Feature specific command dword11 field
2239-
* @uuidx: UUID Index for differentiating vendor specific encoding
22402240
* @data_len: Length of feature data, if applicable, in bytes
22412241
* @data: User address of feature data, if applicable
2242-
* @timeout: Timeout in ms
2243-
* @result: The command completion result from CQE dword0
2242+
* @fid: Feature identifier, see &enum nvme_features_id
2243+
* @uuidx: UUID Index for differentiating vendor specific encoding
22442244
*/
22452245
struct nvme_get_features_args {
22462246
int args_size;
22472247
int fd;
2248-
__u8 fid;
2248+
__u32 *result;
2249+
__u32 timeout;
22492250
__u32 nsid;
22502251
enum nvme_get_features_sel sel;
22512252
__u32 cdw11;
2252-
__u8 uuidx;
22532253
__u32 data_len;
22542254
void *data;
2255-
__u32 timeout;
2256-
__u32 *result;
2257-
};
2255+
__u8 fid;
2256+
__u8 uuidx;
2257+
} __attribute__((packed, aligned(__alignof__(__u32*))));
22582258

22592259
/**
22602260
* nvme_get_features() - Retrieve a feature attribute
@@ -2271,15 +2271,15 @@ static inline int nvme_get_features_data(int fd, enum nvme_features_id fid,
22712271
struct nvme_get_features_args args = {
22722272
.args_size = sizeof(args),
22732273
.fd = fd,
2274-
.fid = fid,
2274+
.result = result,
2275+
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
22752276
.nsid = nsid,
22762277
.sel = NVME_GET_FEATURES_SEL_CURRENT,
22772278
.cdw11 = 0,
2278-
.uuidx = NVME_UUID_NONE,
22792279
.data_len = data_len,
22802280
.data = data,
2281-
.timeout = NVME_DEFAULT_IOCTL_TIMEOUT,
2282-
.result = result,
2281+
.fid = fid,
2282+
.uuidx = NVME_UUID_NONE,
22832283
};
22842284

22852285
return nvme_get_features(&args);

0 commit comments

Comments
 (0)