NAME
io_submit - Submit io requests
SYNOPSIS
#include <errno.h>
#include <libaio.h>
int io_submit(io_context_t ctx, long nr, struct iocb *iocbs[]);
struct iocb {
void |
*data; |
||||
unsigned |
key; |
||||
short |
aio_lio_opcode; | ||||
short |
aio_reqprio; | ||||
int |
aio_fildes; |
};
DESCRIPTION
io_submit() submits nr iocbs for processing for a given io context ctx.
The io_submit() function can be used to enqueue an arbitrary number of read and write requests at one time. The requests can all be meant for the same file, all for different files or every solution in between.
io_submit() gets the nr requests from the array pointed to by iocbs. The operation to be performed is determined by the aio_lio_opcode member in each element of iocbs. If this field is IO_CMD_PREAD a read operation is enqueued, similar to a call of io_prep_pread for this element of the array (except that the way the termination is signalled is different, as we will see below). If the aio_lio_opcode member is IO_CMD_PWRITE a write operation is enqueued. Otherwise the aio_lio_opcode must be IO_CMD_NOP in which case this element of iocbs is simply ignored. This ’’operation’’ is useful in situations where one has a fixed array of struct iocb elements from which only a few need to be handled at a time. Another situation is where the io_submit(3) call was canceled before all requests are processed and the remaining requests have to be reissued.
The other members of each element of the array pointed to by iocbs must have values suitable for the operation as described in the documentation for io_prep_pread(3) and io_prep_pwrite(3) above.
The function returns immediately after having enqueued all the requests. On success, io_submit() returns the number of iocbs submitted successfully. Otherwise, -error is return, where error is one of the Exxx values defined in the Errors section.
If an error is detected, then the behavior is undefined.
Simultaneous asynchronous operations using the same iocb produce undefined results.
ERRORS
EFAULT |
iocbs referenced data outside of the program’s accessible address space. | ||
EINVAL |
ctx refers to an uninitialized aio context, the iocb pointed to by iocbs contains an improperly initialized iocb, | ||
EBADF |
The iocb contains a file descriptor that does not exist. | ||
EINVAL |
The file specified in the iocb does not support the given io operation. |
SEE ALSO
io(3), io_cancel(3), io_fsync(3), io_getevents(3), io_prep_fsync(3), io_prep_pread(3), io_prep_pwrite(3), io_queue_init(3), io_queue_release(3), io_queue_run(3), io_queue_wait(3), io_set_callback(3), errno(3).