]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
ioctl: Rearrange members in nvme_io_args
authorDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 16:59:20 +0000 (17:59 +0100)
committerDaniel Wagner <dwagner@suse.de>
Thu, 13 Jan 2022 17:51:05 +0000 (18:51 +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_io_args {
        int                        args_size;            /*     0     4 */
        int                        fd;                   /*     4     4 */
        __u32 *                    result;               /*     8     8 */
        __u32                      timeout;              /*    16     4 */
        __u32                      nsid;                 /*    20     4 */
        void *                     data;                 /*    24     8 */
        void *                     metadata;             /*    32     8 */
        __u64                      slba;                 /*    40     8 */
        __u16                      nlb;                  /*    48     2 */
        __u16                      control;              /*    50     2 */
        __u16                      apptag;               /*    52     2 */
        __u16                      appmask;              /*    54     2 */
        __u32                      reftag;               /*    56     4 */
        __u32                      data_len;             /*    60     4 */
        /* --- cacheline 1 boundary (64 bytes) --- */
        __u64                      storage_tag;          /*    64     8 */
        __u32                      metadata_len;         /*    72     4 */
        __u8                       dsm;                  /*    76     1 */
        __u8                       dspec;                /*    77     1 */

        /* size: 80, cachelines: 2, members: 18 */
        /* padding: 2 */
        /* last cacheline: 16 bytes */
} __attribute__((__aligned__(8)));

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

index 7a28363d6723def0fe0fde69192f4ee2637dbb70..850cf8d6c820f8f08cd352e7b59e26d4414f5286 100644 (file)
@@ -3565,49 +3565,51 @@ static inline int nvme_flush(int fd, __u32 nsid) {
 /**
  * nvme_io_args - Arguments for NVMe I/O commands
  * @fd:                File descriptor of nvme device
+ * @result:    The command completion result from CQE dword0
+ * @timeout:   Timeout in ms
  * @nsid:      Namespace ID
+ * @data:      Pointer to user address of the data buffer
+ * @metadata:  Pointer to user address of the metadata buffer
  * @slba:      Starting logical block
- * @nblocks:   Number of logical blocks to send (0's based value)
+ * @nbl:       Number of logical blocks to send (0's based value)
  * @control:   Command control flags, see &enum nvme_io_control_flags.
- * @dsm:       Data set management attributes, see &enum nvme_io_dsm_flags
- * @reftag:    This field specifies the Initial Logical Block Reference Tag
- *             expected value. Used only if the namespace is formatted to use
- *             end-to-end protection information.
  * @apptag:    This field specifies the Application Tag Mask expected value.
- *             Used only if the namespace is formatted to use end-to-end
- *             protection information.
+ *             Used only if the namespace is formatted to use end-to-end
+ *             protection information.
  * @appmask:   This field specifies the Application Tag expected value. Used
- *             only if the namespace is formatted to use end-to-end protection
- *             information.
+ *             only if the namespace is formatted to use end-to-end protection
+ *             information.
+ * @reftag:    This field specifies the Initial Logical Block Reference Tag
+ *             expected value. Used only if the namespace is formatted to use
+ *             end-to-end protection information.
+ * @data_len:  Length of user buffer, @data, in bytes
  * @storage_tag: This filed specifies Variable Sized Expected Logical Block
  *             Storage Tag (ELBST) and Expected Logical Block Reference
  *             Tag (ELBRT)
- * @data_len:  Length of user buffer, @data, in bytes
- * @data:      Pointer to user address of the data buffer
  * @metadata_len:Length of user buffer, @metadata, in bytes
- * @metadata:  Pointer to user address of the metadata buffer
- * @timeout:   Timeout in ms
+ * @dsm:       Data set management attributes, see &enum nvme_io_dsm_flags
+ * @dspec:     Directive specific value
  */
 struct nvme_io_args {
        int args_size;
        int fd;
+       __u32 *result;
+       __u32 timeout;
        __u32 nsid;
+       void *data;
+       void *metadata;
        __u64 slba;
        __u16 nlb;
        __u16 control;
-       __u8 dsm;
-       __u8 dspec;
-       __u32 reftag;
        __u16 apptag;
        __u16 appmask;
-       __u64 storage_tag;
+       __u32 reftag;
        __u32 data_len;
-       void *data;
+       __u64 storage_tag;
        __u32 metadata_len;
-       void *metadata;
-       __u32 timeout;
-       __u32 *result;
-};
+       __u8 dsm;
+       __u8 dspec;
+} __attribute__((__packed__, aligned(__alignof__(__u64))));
 
 /**
  * nvme_io() - Submit an nvme user I/O command