Index: sys/kern/vfs_aio.c =================================================================== --- sys/kern/vfs_aio.c +++ sys/kern/vfs_aio.c @@ -90,13 +90,17 @@ #endif #ifndef MAX_AIO_QUEUE_PER_PROC -#define MAX_AIO_QUEUE_PER_PROC 256 /* Bigger than AIO_LISTIO_MAX */ +#define MAX_AIO_QUEUE_PER_PROC 256 #endif #ifndef MAX_AIO_QUEUE -#define MAX_AIO_QUEUE 1024 /* Bigger than AIO_LISTIO_MAX */ +#define MAX_AIO_QUEUE 1024 /* Bigger than MAX_AIO_QUEUE_PER_PROC */ #endif +#ifndef MAX_AIO_SUSPEND +#define MAX_AIO_SUSPEND 16 +#endif + #ifndef MAX_BUF_AIO #define MAX_BUF_AIO 16 #endif @@ -169,10 +173,14 @@ SYSCTL_INT(_vfs_aio, OID_AUTO, max_buf_aio, CTLFLAG_RW, &max_buf_aio, 0, "Maximum buf aio requests per process (stored in the process)"); -static int aio_listio_max = AIO_LISTIO_MAX; +/* + * Though redundant with vfs.aio.max_aio_queue_per_proc, POSIX requires + * sysconf(3) to support AIO_LISTIO_MAX, and we implement that with + * vfs.aio.aio_listio_max. + */ SYSCTL_INT(_p1003_1b, CTL_P1003_1B_AIO_LISTIO_MAX, aio_listio_max, - CTLFLAG_RDTUN | CTLFLAG_CAPRD, &aio_listio_max, 0, - "Maximum aio requests for a single lio_listio call"); + CTLFLAG_RD | CTLFLAG_CAPRD, &max_aio_queue_per_proc, + 0, "Maximum aio requests for a single lio_listio call"); #ifdef COMPAT_FREEBSD6 typedef struct oaiocb { @@ -334,10 +342,10 @@ * kaio Per process async io info * aiop async io process data * aiocb async io jobs - * aiol list io job pointer - internal to aio_suspend XXX + * aios aio_suspend jobs * aiolio list io jobs */ -static uma_zone_t kaio_zone, aiop_zone, aiocb_zone, aiol_zone, aiolio_zone; +static uma_zone_t kaio_zone, aiop_zone, aiocb_zone, aios_zone, aiolio_zone; /* kqueue filters for aio */ static struct filterops aio_filtops = { @@ -394,11 +402,6 @@ aio_onceonly(void) { - if (aio_listio_max < AIO_LISTIO_MAX) - aio_listio_max = AIO_LISTIO_MAX; - if (aio_listio_max > MIN(MAX_AIO_QUEUE_PER_PROC, max_queue_count)) - aio_listio_max = MIN(MAX_AIO_QUEUE_PER_PROC, max_queue_count); - exit_tag = EVENTHANDLER_REGISTER(process_exit, aio_proc_rundown, NULL, EVENTHANDLER_PRI_ANY); exec_tag = EVENTHANDLER_REGISTER(process_exec, aio_proc_rundown_exec, @@ -416,7 +419,7 @@ NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); aiocb_zone = uma_zcreate("AIOCB", sizeof(struct kaiocb), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); - aiol_zone = uma_zcreate("AIOL", aio_listio_max * sizeof(intptr_t) , + aios_zone = uma_zcreate("AIOS", MAX_AIO_SUSPEND * sizeof(intptr_t) , NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); aiolio_zone = uma_zcreate("AIOLIO", sizeof(struct aioliojob), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); @@ -1953,7 +1956,7 @@ struct aiocb **ujoblist; int error; - if (uap->nent < 0 || uap->nent > aio_listio_max) + if (uap->nent < 0 || uap->nent > MAX_AIO_SUSPEND) return (EINVAL); if (uap->timeout) { @@ -1964,11 +1967,11 @@ } else tsp = NULL; - ujoblist = uma_zalloc(aiol_zone, M_WAITOK); + ujoblist = uma_zalloc(aios_zone, M_WAITOK); error = copyin(uap->aiocbp, ujoblist, uap->nent * sizeof(ujoblist[0])); if (error == 0) error = kern_aio_suspend(td, uap->nent, ujoblist, tsp); - uma_zfree(aiol_zone, ujoblist); + uma_zfree(aios_zone, ujoblist); return (error); } @@ -2161,7 +2164,7 @@ if ((mode != LIO_NOWAIT) && (mode != LIO_WAIT)) return (EINVAL); - if (nent < 0 || nent > aio_listio_max) + if (nent < 0 || nent > max_aio_queue_per_proc) return (EINVAL); if (p->p_aioinfo == NULL) @@ -2293,7 +2296,7 @@ return (EINVAL); nent = uap->nent; - if (nent < 0 || nent > aio_listio_max) + if (nent < 0 || nent > max_aio_queue_per_proc) return (EINVAL); if (uap->sig && (uap->mode == LIO_NOWAIT)) { @@ -2330,7 +2333,7 @@ return (EINVAL); nent = uap->nent; - if (nent < 0 || nent > aio_listio_max) + if (nent < 0 || nent > max_aio_queue_per_proc) return (EINVAL); if (uap->sig && (uap->mode == LIO_NOWAIT)) { @@ -2799,7 +2802,7 @@ uint32_t *ujoblist32; int error, i; - if (uap->nent < 0 || uap->nent > aio_listio_max) + if (uap->nent < 0 || uap->nent > MAX_AIO_SUSPEND) return (EINVAL); if (uap->timeout) { @@ -2812,7 +2815,7 @@ } else tsp = NULL; - ujoblist = uma_zalloc(aiol_zone, M_WAITOK); + ujoblist = uma_zalloc(aios_zone, M_WAITOK); ujoblist32 = (uint32_t *)ujoblist; error = copyin(uap->aiocbp, ujoblist32, uap->nent * sizeof(ujoblist32[0])); @@ -2822,7 +2825,7 @@ error = kern_aio_suspend(td, uap->nent, ujoblist, tsp); } - uma_zfree(aiol_zone, ujoblist); + uma_zfree(aios_zone, ujoblist); return (error); } @@ -2925,7 +2928,7 @@ return (EINVAL); nent = uap->nent; - if (nent < 0 || nent > aio_listio_max) + if (nent < 0 || nent > max_aio_queue_per_proc) return (EINVAL); if (uap->sig && (uap->mode == LIO_NOWAIT)) { @@ -2971,7 +2974,7 @@ return (EINVAL); nent = uap->nent; - if (nent < 0 || nent > aio_listio_max) + if (nent < 0 || nent > max_aio_queue_per_proc) return (EINVAL); if (uap->sig && (uap->mode == LIO_NOWAIT)) {