git: bd5f7669c0fd - stable/14 - aio: handle errors from fork
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 12 Jul 2025 01:44:24 UTC
The branch stable/14 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=bd5f7669c0fd14eec352552cb569915c5421e7c0
commit bd5f7669c0fd14eec352552cb569915c5421e7c0
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-07-04 18:30:31 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-07-12 01:41:34 +0000
aio: handle errors from fork
(cherry picked from commit 4685fa8e4bef169e6a1ceaf07f149232326de805)
---
sys/kern/vfs_aio.c | 35 +++++++++++++++++++++++++----------
1 file changed, 25 insertions(+), 10 deletions(-)
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 91137fa1e0dd..ff1e522f7cf2 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -309,7 +309,7 @@ static TAILQ_HEAD(,kaiocb) aio_jobs; /* (c) Async job list */
static struct unrhdr *aiod_unr;
static void aio_biocleanup(struct bio *bp);
-static void aio_init_aioinfo(struct proc *p);
+static int aio_init_aioinfo(struct proc *p);
static int aio_onceonly(void);
static int aio_free_entry(struct kaiocb *job);
static void aio_process_rw(struct kaiocb *job);
@@ -431,10 +431,11 @@ aio_onceonly(void)
* Init the per-process aioinfo structure. The aioinfo limits are set
* per-process for user limit (resource) management.
*/
-static void
+static int
aio_init_aioinfo(struct proc *p)
{
struct kaioinfo *ki;
+ int error;
ki = uma_zalloc(kaio_zone, M_WAITOK);
mtx_init(&ki->kaio_mtx, "aiomtx", NULL, MTX_DEF | MTX_NEW);
@@ -460,8 +461,13 @@ aio_init_aioinfo(struct proc *p)
uma_zfree(kaio_zone, ki);
}
- while (num_aio_procs < MIN(target_aio_procs, max_aio_procs))
- aio_newproc(NULL);
+ error = 0;
+ while (num_aio_procs < MIN(target_aio_procs, max_aio_procs)) {
+ error = aio_newproc(NULL);
+ if (error != 0)
+ break;
+ }
+ return (error);
}
static int
@@ -1509,8 +1515,11 @@ aio_aqueue(struct thread *td, struct aiocb *ujob, struct aioliojob *lj,
int jid;
u_short evflags;
- if (p->p_aioinfo == NULL)
- aio_init_aioinfo(p);
+ if (p->p_aioinfo == NULL) {
+ error = aio_init_aioinfo(p);
+ if (error != 0)
+ goto err1;
+ }
ki = p->p_aioinfo;
@@ -2241,8 +2250,11 @@ kern_lio_listio(struct thread *td, int mode, struct aiocb * const *uacb_list,
if (nent < 0 || nent > max_aio_queue_per_proc)
return (EINVAL);
- if (p->p_aioinfo == NULL)
- aio_init_aioinfo(p);
+ if (p->p_aioinfo == NULL) {
+ error = aio_init_aioinfo(p);
+ if (error != 0)
+ return (error);
+ }
ki = p->p_aioinfo;
@@ -2531,8 +2543,11 @@ kern_aio_waitcomplete(struct thread *td, struct aiocb **ujobp,
timo = tvtohz(&atv);
}
- if (p->p_aioinfo == NULL)
- aio_init_aioinfo(p);
+ if (p->p_aioinfo == NULL) {
+ error = aio_init_aioinfo(p);
+ if (error != 0)
+ return (error);
+ }
ki = p->p_aioinfo;
error = 0;