]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: Rearrange members in nvme_zns_append_args
authorDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 18:09:35 +0000 (19:09 +0100)
committerDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 18:09:35 +0000 (19:09 +0100)
Avoid any holes in the struct by rearranging the members. Also add the
attribute packed to struct definition to reduce ABI breakage.

struct nvme_zns_append_args {
        int                        args_size;            /*     0     4 */
        int                        fd;                   /*     4     4 */
        __u64 *                    result;               /*     8     8 */
        __u32                      timeout;              /*    16     4 */
        __u32                      nsid;                 /*    20     4 */
        __u64                      zslba;                /*    24     8 */
        __u16                      nlb;                  /*    32     2 */
        __u16                      control;              /*    34     2 */
        __u32                      ilbrt;                /*    36     4 */
        __u16                      lbat;                 /*    40     2 */
        __u16                      lbatm;                /*    42     2 */
        __u32                      data_len;             /*    44     4 */
        void *                     data;                 /*    48     8 */
        void *                     metadata;             /*    56     8 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        __u32                      metadata_len;         /*    64     4 */

        /* size: 72, cachelines: 2, members: 15 */
        /* padding: 4 */
        /* last cacheline: 8 bytes */
} __attribute__((__aligned__(8)));

Signed-off-by: Daniel Wagner <dwagner@suse.de>
src/nvme/ioctl.h

index 73628e17fba0aafa49a69af75521f07f241e8ff1..84e7e3c42a7ed46156efb013d83b8912d63ad5a4 100644 (file)
@@ -4052,6 +4052,8 @@ static inline int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba,
 /**
  * nvme_zns_append_args - Arguments for the NVMe ZNS Append command
  * @fd:                File descriptor of nvme device
+ * @result:    The command completion result from CQE dword0
+ * @timeout:   Timeout in ms
  * @nsid:      Namespace ID
  * @zslba:     Zone start logical block address
  * @nlb:       Number of logical blocks
@@ -4061,14 +4063,14 @@ static inline int nvme_zns_report_zones(int fd, __u32 nsid, __u64 slba,
  * @lbatm:     Logical block application tag mask
  * @data_len:  Length of @data
  * @data:      Userspace address of the data
- * @metadata_len: Length of @metadata
  * @metadata:  Userspace address of the metadata
- * @timeout:   Timeout in ms
- * @result:    The command completion result from CQE dword0
+ * @metadata_len: Length of @metadata
  */
 struct nvme_zns_append_args {
        int args_size;
        int fd;
+       __u64 *result;
+       __u32 timeout;
        __u32 nsid;
        __u64 zslba;
        __u16 nlb;
@@ -4078,11 +4080,9 @@ struct nvme_zns_append_args {
        __u16 lbatm;
        __u32 data_len;
        void *data;
-       __u32 metadata_len;
        void *metadata;
-       __u32 timeout;
-       __u64 *result;
-};
+       __u32 metadata_len;
+} __attribute__((packed, aligned(__alignof__(__u64))));
 
 /**
  * nvme_zns_append() - Append data to a zone