[34] | 1 | ./"/* sys_io_submit: |
---|
| 2 | ./" * Queue the nr iocbs pointed to by iocbpp for processing. Returns |
---|
| 3 | ./" * the number of iocbs queued. May return -EINVAL if the aio_context |
---|
| 4 | ./" * specified by ctx_id is invalid, if nr is < 0, if the iocb at |
---|
| 5 | ./" * *iocbpp[0] is not properly initialized, if the operation specified |
---|
| 6 | ./" * is invalid for the file descriptor in the iocb. May fail with |
---|
| 7 | ./" * -EFAULT if any of the data structures point to invalid data. May |
---|
| 8 | ./" * fail with -EBADF if the file descriptor specified in the first |
---|
| 9 | ./" * iocb is invalid. May fail with -EAGAIN if insufficient resources |
---|
| 10 | ./" * are available to queue any iocbs. Will return 0 if nr is 0. Will |
---|
| 11 | ./" * fail with -ENOSYS if not implemented. |
---|
| 12 | ./" */ |
---|
| 13 | .TH io_submit 2 2002-09-02 "Linux 2.4" "Linux AIO" |
---|
| 14 | .SH NAME |
---|
| 15 | io_submit \- Submit io requests |
---|
| 16 | .SH SYNOPSIS |
---|
| 17 | .nf |
---|
| 18 | .B #include <errno.h> |
---|
| 19 | .br |
---|
| 20 | .sp |
---|
| 21 | .B #include <libaio.h> |
---|
| 22 | .br |
---|
| 23 | .sp |
---|
| 24 | .BI "int io_submit(io_context_t " ctx ", long " nr ", struct iocb *" iocbs "[]);" |
---|
| 25 | .sp |
---|
| 26 | struct iocb { |
---|
| 27 | void *data; |
---|
| 28 | unsigned key; |
---|
| 29 | short aio_lio_opcode; |
---|
| 30 | short aio_reqprio; |
---|
| 31 | int aio_fildes; |
---|
| 32 | }; |
---|
| 33 | .fi |
---|
| 34 | .SH DESCRIPTION |
---|
| 35 | .B io_submit |
---|
| 36 | submits |
---|
| 37 | .I nr |
---|
| 38 | iocbs for processing for a given io context ctx. |
---|
| 39 | |
---|
| 40 | The |
---|
| 41 | .IR "io_submit" |
---|
| 42 | function can be used to enqueue an arbitrary |
---|
| 43 | number of read and write requests at one time. The requests can all be |
---|
| 44 | meant for the same file, all for different files or every solution in |
---|
| 45 | between. |
---|
| 46 | |
---|
| 47 | .IR "io_submit" |
---|
| 48 | gets the |
---|
| 49 | .IR "nr" |
---|
| 50 | requests from the array pointed to |
---|
| 51 | by |
---|
| 52 | .IR "iocbs" |
---|
| 53 | . The operation to be performed is determined by the |
---|
| 54 | .IR "aio_lio_opcode" |
---|
| 55 | member in each element of |
---|
| 56 | .IR "iocbs" |
---|
| 57 | . If this |
---|
| 58 | field is |
---|
| 59 | .B "IO_CMD_PREAD" |
---|
| 60 | a read operation is enqueued, similar to a call |
---|
| 61 | of |
---|
| 62 | .IR "io_prep_pread" |
---|
| 63 | for this element of the array (except that the way |
---|
| 64 | the termination is signalled is different, as we will see below). If |
---|
| 65 | the |
---|
| 66 | .IR "aio_lio_opcode" |
---|
| 67 | member is |
---|
| 68 | .B "IO_CMD_PWRITE" |
---|
| 69 | a write operation |
---|
| 70 | is enqueued. Otherwise the |
---|
| 71 | .IR "aio_lio_opcode" |
---|
| 72 | must be |
---|
| 73 | .B "IO_CMD_NOP" |
---|
| 74 | in which case this element of |
---|
| 75 | .IR "iocbs" |
---|
| 76 | is simply ignored. This |
---|
| 77 | ``operation'' is useful in situations where one has a fixed array of |
---|
| 78 | .IR "struct iocb" |
---|
| 79 | elements from which only a few need to be handled at |
---|
| 80 | a time. Another situation is where the |
---|
| 81 | .IR "io_submit" |
---|
| 82 | call was |
---|
| 83 | canceled before all requests are processed and the remaining requests have to be reissued. |
---|
| 84 | |
---|
| 85 | The other members of each element of the array pointed to by |
---|
| 86 | .IR "iocbs" |
---|
| 87 | must have values suitable for the operation as described in |
---|
| 88 | the documentation for |
---|
| 89 | .IR "io_prep_pread" |
---|
| 90 | and |
---|
| 91 | .IR "io_prep_pwrite" |
---|
| 92 | above. |
---|
| 93 | |
---|
| 94 | The function returns immediately after |
---|
| 95 | having enqueued all the requests. |
---|
| 96 | On success, |
---|
| 97 | .B io_submit |
---|
| 98 | returns the number of iocbs submitted successfully. Otherwise, -error is return, where |
---|
| 99 | error is one of the Exxx values defined in the Errors section. |
---|
| 100 | .PP |
---|
| 101 | If an error is detected, then the behavior is undefined. |
---|
| 102 | .PP |
---|
| 103 | Simultaneous asynchronous operations using the same iocb produce |
---|
| 104 | undefined results. |
---|
| 105 | .SH ERRORS |
---|
| 106 | .TP |
---|
| 107 | .B EFAULT |
---|
| 108 | .I iocbs |
---|
| 109 | referenced data outside of the program's accessible address space. |
---|
| 110 | .TP |
---|
| 111 | .B EINVAL |
---|
| 112 | .I ctx |
---|
| 113 | refers to an unitialized aio context, the iocb pointed to by |
---|
| 114 | .I iocbs |
---|
| 115 | contains an improperly initialized iocb, |
---|
| 116 | .TP |
---|
| 117 | .B EBADF |
---|
| 118 | The iocb contains a file descriptor that does not exist. |
---|
| 119 | .TP |
---|
| 120 | .B EINVAL |
---|
| 121 | The file specified in the iocb does not support the given io operation. |
---|
| 122 | .SH "SEE ALSO" |
---|
| 123 | .BR io(3), |
---|
| 124 | .BR io_cancel(3), |
---|
| 125 | .BR io_fsync(3), |
---|
| 126 | .BR io_getevents(3), |
---|
| 127 | .BR io_prep_fsync(3), |
---|
| 128 | .BR io_prep_pread(3), |
---|
| 129 | .BR io_prep_pwrite(3), |
---|
| 130 | .BR io_queue_init(3), |
---|
| 131 | .BR io_queue_release(3), |
---|
| 132 | .BR io_queue_run(3), |
---|
| 133 | .BR io_queue_wait(3), |
---|
| 134 | .BR io_set_callback(3), |
---|
| 135 | .BR errno(3) |
---|