VE AIO is a asynchronous I/O feature for VE programs.
More...
|
struct ve_aio_ctx * | ve_aio_init (void) |
| This function returns a new ve_aio_ctx managing a read/write request. More...
|
|
int | ve_aio_fini (struct ve_aio_ctx *ctx) |
| This function releases context managing a read/write request. More...
|
|
int | ve_aio_read (struct ve_aio_ctx *ctx, int fd, ssize_t count, void *buf, off_t offset) |
| This function starts asynchronous read. More...
|
|
int | ve_aio_write (struct ve_aio_ctx *ctx, int fd, ssize_t count, void *buf, off_t offset) |
| This function starts asynchronous write. More...
|
|
int | ve_aio_query (struct ve_aio_ctx *ctx, ssize_t *retval, int *errnoval) |
| This function gets state of read/write operation for the context. More...
|
|
int | ve_aio_wait (struct ve_aio_ctx *ctx, ssize_t *retval, int *errnoval) |
| This function waits read/write request for the context. More...
|
|
VE AIO is a asynchronous I/O feature for VE programs.
VE programs can do their own tasks while data transfer between VE and VH and actual I/O are done asynchronously.
Please include "veaio.h". Please specify "-lveio -pthread" option to the compiler driver to link libveio.
- Note
- VE AIO expects an ordinary file opened without O_DIRECT flag. Socket, pipe or fifo can't be used.
-
Calling fork() or vfork() when read/write operation status is in progress, invoking AIO API results in undefined behavior. Check read/write operation status by using ve_aio_query() or synchronize read/write operation by using ve_aio_wait().
-
Pseudo process(ve_exec) creates IO worker threads on VH and each thread allocates IO buffer and opens two files to communicate with VEOS. IO request is divided and processed non-atomically under multithreading by default. Following environment variables can be set to change from default.
- VE_ASYNC_IO_THREAD To specify the number of VEAIO worker threads per VE process. This is valid only when VE_ASYNC_IO_ATOMIC is 0. Default is 4.
- VE_ASYNC_IO_BUFSIZE To specify IO buffer size(Byte) per worker thread. This is valid only when VE_ASYNC_IO_ATOMIC is 0. Default is 8MB.
- VE_ASYNC_IO_ATOMIC Set this to 1 and VEAIO worker threads process IO operation atomically. Default is 0. The number of bytes read or written at once is restricted to 2147479552Byte(2GB - 4KB) same as pread64/pwrite64.
-
If VE thread which has submitted read/write request terminates before completion of read/write operation, then VE process gets abnormal termination.
struct ve_aio_ctx* ve_aio_init |
( |
void |
| ) |
|
This function returns a new ve_aio_ctx managing a read/write request.
- Note
- User must initialize a ve_aio_ctx for AIO operation
-
User must invoke this function as many as multiplicity of read/write requests
-
For example, initialize two contexts to submit two read/write requests at a time
-
Context can be reused after completion of previous request
- Return values
-
ve_aio_ctx | on success |
NULL | on failure. |
int ve_aio_fini |
( |
struct ve_aio_ctx * |
ctx | ) |
|
This function releases context managing a read/write request.
- Parameters
-
[in] | ctx | Context to be released |
- Return values
-
0 | on success |
-1 | on failure and following errno is set
- EINVAL Context in arguments is invalid
- EBUSY Request for this context is in progress
|
int ve_aio_read |
( |
struct ve_aio_ctx * |
ctx, |
|
|
int |
fd, |
|
|
ssize_t |
count, |
|
|
void * |
buf, |
|
|
off_t |
offset |
|
) |
| |
This function starts asynchronous read.
- Note
- This function internally invokes pread() system call at VH side
-
Context can be reused after completion of previous request
- Parameters
-
[in] | ctx | Context managing this request |
[in] | fd | File descriptor which refer to a file this function reads to |
[in] | count | Number of bytes read |
[out] | buf | Buffer this function reads from |
[in] | offset | File offset |
- Return values
-
0 | on success |
-1 | on failure and following errno is set
- EINVAL Context in arguments is invalid
- EBUSY Not complete the previous read request for this context
- EAGAIN No resource to accept this request
- ENOMEM No memory to accept this request on host
|
int ve_aio_write |
( |
struct ve_aio_ctx * |
ctx, |
|
|
int |
fd, |
|
|
ssize_t |
count, |
|
|
void * |
buf, |
|
|
off_t |
offset |
|
) |
| |
This function starts asynchronous write.
- Note
- This function internally invokes pwrite() system call at VH side
-
Context can be reused after completion of previous request
- Parameters
-
[in] | ctx | Context managing this request |
[in] | fd | File descriptor which refer to a file function writes to |
[in] | count | Number of bytes written |
[in] | buf | Buffer this function writes from |
[in] | offset | File offset |
- Return values
-
0 | on success |
-1 | on failure and following errno is set
- EINVAL Context in arguments is invalid
- EBUSY Not complete the previous read request for this context
- EAGAIN No resource to accept this request
- ENOMEM No memory to accept this request on host
|
int ve_aio_query |
( |
struct ve_aio_ctx * |
ctx, |
|
|
ssize_t * |
retval, |
|
|
int * |
errnoval |
|
) |
| |
This function gets state of read/write operation for the context.
- Note
- If argument *retval or *errnoval below is NULL, status of read/write can be got but return value or error number can not be got
- Parameters
-
[in] | ctx | Context which this function gets some information from |
[out] | retval | Pointer to get return value of pread()/pwrite() |
[out] | errnoval | Pointer to get error number of pread()/pwrite() |
- Return values
-
0 | on completion of read/write and set retval and errnoval |
1 | on incompletion read/write |
-1 | on failure of query and following errno is set
- EINVAL Context in arguments is invalid
|
int ve_aio_wait |
( |
struct ve_aio_ctx * |
ctx, |
|
|
ssize_t * |
retval, |
|
|
int * |
errnoval |
|
) |
| |
This function waits read/write request for the context.
- Note
- When read or write is failure (actually, pread or pwrite is used internally), its error number is set
-
This function blocks VE process so VEOS finds other process to schedule
-
After context was reused, this function gets result of latest request for ve_aio_ctx
-
When this function fails, retval and errnoval are not set
- Parameters
-
[in] | ctx | Context managing read/write request |
[out] | retval | Pointer to get return value of pread()/pwrite() |
[out] | errnoval | Pointer to get error number of pread()/pwrite() |
- Return values
-
0 | on completion of read/write and set retval and errnoval |
-1 | on failure of wait and following errno is set
- EINVAL Context in arguments is invalid
- EBUSY Context in arguments has already managed new read/write request and failure to get result of previous request
|