mirror of
https://github.com/apache/nuttx.git
synced 2026-10-06 11:03:16 +08:00
fs/aio: add configurable AIO_LISTIO_MAX limit
lio_listio() never validated 'nent' against {AIO_LISTIO_MAX}, so a
batch larger than the documented limit was silently accepted, and the
hard-coded _POSIX_AIO_LISTIO_MAX value of 2 was too small for real
workloads (LTP uses 10 entries per call).
Add the FS_AIO_LISTIO_MAX Kconfig option (default 10), use it for
_POSIX_AIO_LISTIO_MAX in include/limits.h, validate 'nent' in
lio_listio(), and report the limit through sysconf(_SC_AIO_LISTIO_MAX).
Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
This commit is contained in:
committed by
Alan C. Assis
parent
1ea86e65fd
commit
2f4d017bb6
@@ -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
|
||||
|
||||
+2
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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 */
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user