diff --git a/fs/aio/Kconfig b/fs/aio/Kconfig index fa09b9a38cc..11d74133e43 100644 --- a/fs/aio/Kconfig +++ b/fs/aio/Kconfig @@ -11,6 +11,18 @@ config FS_AIO Enable support for asynchronous I/O. This selection enables the interfaces declared in include/aio.h. +config FS_AIO_LISTIO_MAX + int "Maximum number of AIO operations in listio" + default 10 + ---help--- + This option sets the maximum number of asynchronous I/O (AIO) operations + that can be submitted in a single call to lio_listio(). + + This value defines the upper limit for the 'nent' parameter in + lio_listio(mode, aiocb_list, nent, sevp). Increasing this value allows + more operations to be queued. + Default: 10 + if FS_AIO config FS_NAIOC diff --git a/fs/aio/lio_listio.c b/fs/aio/lio_listio.c index 1edbf7c7e25..196677529d4 100644 --- a/fs/aio/lio_listio.c +++ b/fs/aio/lio_listio.c @@ -334,7 +334,8 @@ int lio_listio(int mode, FAR struct aiocb *restrict const list[restrict], int ret; int i; - if (mode != LIO_WAIT && mode != LIO_NOWAIT) + if (nent < 0 || nent > AIO_LISTIO_MAX || + (mode != LIO_WAIT && mode != LIO_NOWAIT)) { set_errno(EINVAL); return ERROR; diff --git a/include/limits.h b/include/limits.h index 59357fe83f3..a2da21497b2 100644 --- a/include/limits.h +++ b/include/limits.h @@ -188,7 +188,7 @@ /* Required for asynchronous I/O */ -#define _POSIX_AIO_LISTIO_MAX 2 +#define _POSIX_AIO_LISTIO_MAX CONFIG_FS_AIO_LISTIO_MAX #define _POSIX_AIO_MAX 1 /* Required for POSIX message passing */ diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c index 428482aea52..20655721c1b 100644 --- a/libs/libc/unistd/lib_sysconf.c +++ b/libs/libc/unistd/lib_sysconf.c @@ -266,6 +266,9 @@ long sysconf(int name) case _SC_THREAD_THREADS_MAX: return UINT8_MAX; + case _SC_AIO_LISTIO_MAX: + return AIO_LISTIO_MAX; + default: #if 0 /* Assume valid but not implemented for the time being */ errcode = EINVAL;