]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: Rearrange members in nvme_copy_args
authorDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 17:50:31 +0000 (18:50 +0100)
committerDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 17:52:24 +0000 (18:52 +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_copy_args {
        int                        args_size;            /*     0     4 */
        int                        fd;                   /*     4     4 */
        __u32 *                    result;               /*     8     8 */
        __u32                      timeout;              /*    16     4 */
        __u32                      nsid;                 /*    20     4 */
        struct nvme_copy_range *   copy;                 /*    24     8 */
        __u64                      sdlba;                /*    32     8 */
        __u16                      nr;                   /*    40     2 */
        __u16                      dspec;                /*    42     2 */
        __u8                       prinfor;              /*    44     1 */
        __u8                       prinfow;              /*    45     1 */
        __u8                       dtype;                /*    46     1 */
        __u8                       format;               /*    47     1 */
        int                        lr;                   /*    48     4 */
        int                        fua;                  /*    52     4 */
        __u32                      ilbrt;                /*    56     4 */
        __u16                      lbatm;                /*    60     2 */
        __u16                      lbat;                 /*    62     2 */

        /* size: 64, cachelines: 1, members: 18 */
} __attribute__((__aligned__(8)));

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

index 2a990105168e7e1f2a6523a99f829d9c173f94ed..81d1b1bb0a43f4ca63801f2d5a193d57f54e6bd2 100644 (file)
@@ -3745,43 +3745,43 @@ int nvme_dsm(struct nvme_dsm_args *args);
 /**
  * nvme_copy_args - Arguments for the NVMe Copy command
  * @fd:                File descriptor of the nvme device
+ * @result:    The command completion result from CQE dword0
+ * @timeout:   Timeout in ms
  * @nsid:      Namespace identifier
  * @copy:      Range descriptior
  * @sdlba:     Start destination LBA
  * @nr:                Number of ranges
+ * @dspec:     Directive specific value
  * @prinfor:   Protection information field for read
  * @prinfow:   Protection information field for write
  * @dtype:     Directive type
- * @dspec:     Directive specific value
  * @format:    Descriptor format
  * @lr:                Limited retry
  * @fua:       Force unit access
  * @ilbrt:     Initial logical block reference tag
  * @lbatm:     Logical block application tag mask
  * @lbat:      Logical block application tag
- * @timeout:   Timeout in ms
- * @result:    The command completion result from CQE dword0
  */
 struct nvme_copy_args {
        int args_size;
        int fd;
+       __u32 *result;
+       __u32 timeout;
        __u32 nsid;
        struct nvme_copy_range *copy;
        __u64 sdlba;
        __u16 nr;
+       __u16 dspec;
        __u8 prinfor;
        __u8 prinfow;
        __u8 dtype;
-       __u16 dspec;
        __u8 format;
        int lr;
        int fua;
        __u32 ilbrt;
        __u16 lbatm;
        __u16 lbat;
-       __u32 timeout;
-       __u32 *result;
-};
+} __attribute__((packed, aligned(__alignof__(__u64))));
 
 /**
  * nvme_copy() -