1io_submit(2)                  System Calls Manual                 io_submit(2)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10
11       Alternatively, Asynchronous I/O library (libaio, -laio); see VERSIONS.
12

SYNOPSIS

14       #include <linux/aio_abi.h>          /* Defines needed types */
15
16       int io_submit(aio_context_t ctx_id, long nr, struct iocb **iocbpp);
17
18       Note: There is no glibc wrapper for this system call; see VERSIONS.
19

DESCRIPTION

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

RETURN VALUE

142       On success, io_submit() returns the number of  iocbs  submitted  (which
143       may  be less than nr, or 0 if nr is zero).  For the failure return, see
144       VERSIONS.
145

ERRORS

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

VERSIONS

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

STANDARDS

179       Linux.
180

HISTORY

182       Linux 2.5.
183

SEE ALSO

185       io_cancel(2), io_destroy(2), io_getevents(2), io_setup(2), aio(7)
186
187
188
189Linux man-pages 6.05              2023-05-03                      io_submit(2)
Impressum