1IO_SUBMIT(2)               Linux Programmer's Manual              IO_SUBMIT(2)
2
3
4

NAME

6       io_submit - submit asynchronous I/O blocks for processing
7

SYNOPSIS

9       #include <linux/aio_abi.h>          /* Defines needed types */
10
11       int io_submit(aio_context_t ctx_id, long nr, struct iocb **iocbpp);
12
13       Note: There is no glibc wrapper for this system call; see NOTES.
14

DESCRIPTION

16       The io_submit() system call queues nr I/O request blocks for processing
17       in the AIO context ctx_id.  The iocbpp argument should be an  array  of
18       nr AIO control blocks, which will be submitted to context ctx_id.
19
20       The  iocb  (I/O  control  block)  structure  defined in linux/aio_abi.h
21       defines the parameters that control the I/O operation.
22
23           #include <linux/aio_abi.h>
24
25           struct iocb {
26               __u64   aio_data;
27               __u32   PADDED(aio_key, aio_rw_flags);
28               __u16   aio_lio_opcode;
29               __s16   aio_reqprio;
30               __u32   aio_fildes;
31               __u64   aio_buf;
32               __u64   aio_nbytes;
33               __s64   aio_offset;
34               __u64   aio_reserved2;
35               __u32   aio_flags;
36               __u32   aio_resfd;
37           };
38
39       The fields of this structure are as follows:
40
41       aio_data
42              This data is copied into the data field of the  io_event  struc‐
43              ture upon I/O completion (see io_getevents(2)).
44
45       aio_key
46              This  is  an  internal  field used by the kernel.  Do not modify
47              this field after an io_submit(2) call.
48
49       aio_rw_flags
50              This defines the R/W flags passed  with  structure.   The  valid
51              values are:
52
53              RWF_APPEND (since Linux 4.16)
54                     Append  data to the end of the file.  See the description
55                     of the flag of the same name in pwritev2(2)  as  well  as
56                     the  description  of O_APPEND in open(2).  The aio_offset
57                     field is ignored.  The file offset is not changed.
58
59              RWF_DSYNC (since Linux 4.7)
60                     Write operation complete according to requirement of syn‐
61                     chronized I/O data integrity.  See the description of the
62                     flag of the same name in pwritev2(2) as well the descrip‐
63                     tion of O_DSYNC in open(2).
64
65              RWF_HIPRI (since Linux 4.6)
66                     High priority request, poll if possible
67
68              RWF_NOWAIT (since Linux 4.14)
69                     Don't  wait  if the I/O will block for operations such as
70                     file block allocations, dirty page flush, mutex locks, or
71                     a  congested  block  device inside the kernel.  If any of
72                     these conditions are met, the control block  is  returned
73                     immediately  with  a  return  value of -EAGAIN in the res
74                     field of the io_event structure (see io_getevents(2)).
75
76              RWF_SYNC (since Linux 4.7)
77                     Write operation complete according to requirement of syn‐
78                     chronized I/O file integrity.  See the description of the
79                     flag of the same name in pwritev2(2) as well the descrip‐
80                     tion of O_SYNC in open(2).
81
82       aio_lio_opcode
83              This  defines the type of I/O to be performed by the iocb struc‐
84              ture.  The valid values are  defined  by  the  enum  defined  in
85              linux/aio_abi.h:
86
87                  enum {
88                      IOCB_CMD_PREAD = 0,
89                      IOCB_CMD_PWRITE = 1,
90                      IOCB_CMD_FSYNC = 2,
91                      IOCB_CMD_FDSYNC = 3,
92                      IOCB_CMD_NOOP = 6,
93                      IOCB_CMD_PREADV = 7,
94                      IOCB_CMD_PWRITEV = 8,
95                  };
96
97       aio_reqprio
98              This defines the requests priority.
99
100       aio_fildes
101              The  file  descriptor  on  which the I/O operation is to be per‐
102              formed.
103
104       aio_buf
105              This is the buffer used to transfer data for  a  read  or  write
106              operation.
107
108       aio_nbytes
109              This is the size of the buffer pointed to by aio_buf.
110
111       aio_offset
112              This is the file offset at which the I/O operation is to be per‐
113              formed.
114
115       aio_flags
116              This is the set of flags associated  with  the  iocb  structure.
117              The valid values are:
118
119              IOCB_FLAG_RESFD
120                     Asynchronous  I/O control must signal the file descriptor
121                     mentioned in aio_resfd upon completion.
122
123              IOCB_FLAG_IOPRIO (since Linux 4.18)
124                     Interpret the aio_reqprio field  as  an  IOPRIO_VALUE  as
125                     defined by linux/ioprio.h.
126
127       aio_resfd
128              The  file  descriptor to signal in the event of asynchronous I/O
129              completion.
130

RETURN VALUE

132       On success, io_submit() returns the number of  iocbs  submitted  (which
133       may  be less than nr, or 0 if nr is zero).  For the failure return, see
134       NOTES.
135

ERRORS

137       EAGAIN Insufficient resources are available to queue any iocbs.
138
139       EBADF  The file descriptor specified in the first iocb is invalid.
140
141       EFAULT One of the data structures points to invalid data.
142
143       EINVAL The AIO context specified by ctx_id is invalid.  nr is less than
144              0.   The  iocb  at  *iocbpp[0]  is not properly initialized, the
145              operation specified is invalid for the file  descriptor  in  the
146              iocb, or the value in the aio_reqprio field is invalid.
147
148       ENOSYS io_submit() is not implemented on this architecture.
149
150       EPERM  The aio_reqprio field is set with the class IOPRIO_CLASS_RT, but
151              the submitting context does not have the CAP_SYS_ADMIN  capabil‐
152              ity.
153

VERSIONS

155       The asynchronous I/O system calls first appeared in Linux 2.5.
156

CONFORMING TO

158       io_submit()  is  Linux-specific and should not be used in programs that
159       are intended to be portable.
160

NOTES

162       Glibc does not provide a wrapper function for this  system  call.   You
163       could  invoke  it  using syscall(2).  But instead, you probably want to
164       use the io_submit() wrapper function provided by libaio.
165
166       Note that the libaio wrapper function uses a  different  type  (io_con‐
167       text_t)  for  the  ctx_id  argument.  Note also that the libaio wrapper
168       does not follow the usual C library conventions for indicating  errors:
169       on  error it returns a negated error number (the negative of one of the
170       values  listed  in  ERRORS).   If  the  system  call  is  invoked   via
171       syscall(2),  then  the  return  value follows the usual conventions for
172       indicating an error: -1, with errno set  to  a  (positive)  value  that
173       indicates the error.
174

SEE ALSO

176       io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
177

COLOPHON

179       This  page  is  part of release 5.02 of the Linux man-pages project.  A
180       description of the project, information about reporting bugs,  and  the
181       latest     version     of     this    page,    can    be    found    at
182       https://www.kernel.org/doc/man-pages/.
183
184
185
186Linux                             2018-04-30                      IO_SUBMIT(2)
Impressum