Skip to content

Commit fe068c6

Browse files
committed
ioctl: Rearrange members in nvme_ns_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_ns_mgmt_args { int args_size; /* 0 4 */ int fd; /* 4 4 */ __u32 * result; /* 8 8 */ __u32 timeout; /* 16 4 */ __u32 nsid; /* 20 4 */ struct nvme_id_ns * ns; /* 24 8 */ enum nvme_ns_mgmt_sel sel; /* 32 4 */ __u8 csi; /* 36 1 */ /* size: 40, cachelines: 1, members: 8 */ /* padding: 3 */ /* last cacheline: 40 bytes */ } __attribute__((__aligned__(8))); Signed-off-by: Daniel Wagner <[email protected]>
1 parent 91eb974 commit fe068c6

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
@@ -2693,23 +2693,23 @@ int nvme_format_nvm(struct nvme_format_nvm_args *args);
26932693
/**
26942694
* nvme_ns_mgmt_args - Arguments for NVMe Namespace Management command
26952695
* @fd: File descriptor of nvme device
2696-
* @nsid: Namespace identifier
2697-
* @sel: Type of management operation to perform
2698-
* @ns: Namespace identication descriptors
26992696
* @result: NVMe command result
27002697
* @timeout: Timeout in ms
2698+
* @nsid: Namespace identifier
2699+
* @ns: Namespace identication descriptors
2700+
* @sel: Type of management operation to perform
27012701
* @csi: Command Set Identifier
27022702
*/
27032703
struct nvme_ns_mgmt_args {
27042704
int args_size;
27052705
int fd;
2706-
__u32 nsid;
2707-
enum nvme_ns_mgmt_sel sel;
2708-
struct nvme_id_ns *ns;
27092706
__u32 *result;
27102707
__u32 timeout;
2708+
__u32 nsid;
2709+
struct nvme_id_ns *ns;
2710+
enum nvme_ns_mgmt_sel sel;
27112711
__u8 csi;
2712-
};
2712+
} __attribute__((packed, aligned(__alignof__(__u32*))));
27132713

27142714
/**
27152715
* nvme_ns_mgmt() -
@@ -2739,11 +2739,11 @@ static inline int nvme_ns_mgmt_create(int fd, struct nvme_id_ns *ns,
27392739
struct nvme_ns_mgmt_args args = {
27402740
.args_size = sizeof(args),
27412741
.fd = fd,
2742-
.nsid = NVME_NSID_NONE,
2743-
.sel = NVME_NS_MGMT_SEL_CREATE,
2744-
.ns = ns,
27452742
.result = nsid,
27462743
.timeout = timeout,
2744+
.nsid = NVME_NSID_NONE,
2745+
.ns = ns,
2746+
.sel = NVME_NS_MGMT_SEL_CREATE,
27472747
.csi = csi,
27482748
};
27492749

@@ -2767,11 +2767,11 @@ static inline int nvme_ns_mgmt_delete(int fd, __u32 nsid)
27672767
struct nvme_ns_mgmt_args args = {
27682768
.args_size = sizeof(args),
27692769
.fd = fd,
2770-
.nsid = nsid,
2771-
.sel = NVME_NS_MGMT_SEL_DELETE,
2772-
.ns = NULL,
27732770
.result = NULL,
27742771
.timeout = 0,
2772+
.nsid = nsid,
2773+
.ns = NULL,
2774+
.sel = NVME_NS_MGMT_SEL_DELETE,
27752775
.csi = 0,
27762776
};
27772777

0 commit comments

Comments
 (0)