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

RETURN VALUE

137       On success, io_submit() returns the number of  iocbs  submitted  (which
138       may  be less than nr, or 0 if nr is zero).  For the failure return, see
139       NOTES.
140

ERRORS

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

VERSIONS

160       The asynchronous I/O system calls first appeared in Linux 2.5.
161

CONFORMING TO

163       io_submit()  is  Linux-specific and should not be used in programs that
164       are intended to be portable.
165

NOTES

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

SEE ALSO

181       io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
182

COLOPHON

184       This  page  is  part of release 5.13 of the Linux man-pages project.  A
185       description of the project, information about reporting bugs,  and  the
186       latest     version     of     this    page,    can    be    found    at
187       https://www.kernel.org/doc/man-pages/.
188
189
190
191Linux                             2021-03-22                      IO_SUBMIT(2)
Impressum