summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2005-06-03 05:27:20 +0000
committeralc <alc@FreeBSD.org>2005-06-03 05:27:20 +0000
commit652afa11cf1a7cf1acdfec8444141b3be09866d9 (patch)
tree81b060b975a1c6af324da038ff14883aad4d6195
parentb1d9bded139c37a7b628a3e37456b27ef03617a2 (diff)
downloadFreeBSD-src-652afa11cf1a7cf1acdfec8444141b3be09866d9.zip
FreeBSD-src-652afa11cf1a7cf1acdfec8444141b3be09866d9.tar.gz
Synchronize access to the per process aiocb lists in many of the functions.
-rw-r--r--sys/kern/vfs_aio.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 3cff799..f94366b 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -1566,6 +1566,7 @@ aio_return(struct thread *td, struct aio_return_args *uap)
ki = p->p_aioinfo;
if (ki == NULL)
return (EINVAL);
+ PROC_LOCK(p);
TAILQ_FOREACH(cb, &ki->kaio_jobdone, plist) {
if (((intptr_t) cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
@@ -1590,6 +1591,7 @@ aio_return(struct thread *td, struct aio_return_args *uap)
}
splx(s);
done:
+ PROC_UNLOCK(p);
if (cb != NULL) {
if (ujob == cb->uuaiocb) {
td->td_retval[0] =
@@ -1664,11 +1666,13 @@ aio_suspend(struct thread *td, struct aio_suspend_args *uap)
error = 0;
for (;;) {
+ PROC_LOCK(p);
TAILQ_FOREACH(cb, &ki->kaio_jobdone, plist) {
for (i = 0; i < njoblist; i++) {
if (((intptr_t)
cb->uaiocb._aiocb_private.kernelinfo) ==
ijoblist[i]) {
+ PROC_UNLOCK(p);
if (ujoblist[i] != cb->uuaiocb)
error = EINVAL;
uma_zfree(aiol_zone, ijoblist);
@@ -1685,6 +1689,7 @@ aio_suspend(struct thread *td, struct aio_suspend_args *uap)
if (((intptr_t)
cb->uaiocb._aiocb_private.kernelinfo) ==
ijoblist[i]) {
+ PROC_UNLOCK(p);
splx(s);
if (ujoblist[i] != cb->uuaiocb)
error = EINVAL;
@@ -1696,7 +1701,8 @@ aio_suspend(struct thread *td, struct aio_suspend_args *uap)
}
ki->kaio_flags |= KAIO_WAKEUP;
- error = tsleep(p, PRIBIO | PCATCH, "aiospn", timo);
+ error = msleep(p, &p->p_mtx, PDROP | PRIBIO | PCATCH, "aiospn",
+ timo);
splx(s);
if (error == ERESTART || error == EINTR) {
@@ -1855,9 +1861,11 @@ aio_error(struct thread *td, struct aio_error_args *uap)
if ((jobref == -1) || (jobref == 0))
return (EINVAL);
+ PROC_LOCK(p);
TAILQ_FOREACH(cb, &ki->kaio_jobdone, plist) {
if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
+ PROC_UNLOCK(p);
td->td_retval[0] = cb->uaiocb._aiocb_private.error;
return (0);
}
@@ -1869,6 +1877,7 @@ aio_error(struct thread *td, struct aio_error_args *uap)
plist)) {
if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
+ PROC_UNLOCK(p);
td->td_retval[0] = EINPROGRESS;
splx(s);
return (0);
@@ -1879,6 +1888,7 @@ aio_error(struct thread *td, struct aio_error_args *uap)
plist)) {
if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
+ PROC_UNLOCK(p);
td->td_retval[0] = EINPROGRESS;
splx(s);
return (0);
@@ -1891,6 +1901,7 @@ aio_error(struct thread *td, struct aio_error_args *uap)
plist)) {
if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
+ PROC_UNLOCK(p);
td->td_retval[0] = cb->uaiocb._aiocb_private.error;
splx(s);
return (0);
@@ -1901,12 +1912,14 @@ aio_error(struct thread *td, struct aio_error_args *uap)
plist)) {
if (((intptr_t)cb->uaiocb._aiocb_private.kernelinfo) ==
jobref) {
+ PROC_UNLOCK(p);
td->td_retval[0] = EINPROGRESS;
splx(s);
return (0);
}
}
splx(s);
+ PROC_UNLOCK(p);
#if (0)
/*
@@ -2235,7 +2248,9 @@ aio_waitcomplete(struct thread *td, struct aio_waitcomplete_args *uap)
return (EAGAIN);
for (;;) {
+ PROC_LOCK(p);
if ((cb = TAILQ_FIRST(&ki->kaio_jobdone)) != 0) {
+ PROC_UNLOCK(p);
suword(uap->aiocbp, (uintptr_t)cb->uuaiocb);
td->td_retval[0] = cb->uaiocb._aiocb_private.status;
if (cb->uaiocb.aio_lio_opcode == LIO_WRITE) {
@@ -2253,6 +2268,7 @@ aio_waitcomplete(struct thread *td, struct aio_waitcomplete_args *uap)
s = splbio();
if ((cb = TAILQ_FIRST(&ki->kaio_bufdone)) != 0 ) {
+ PROC_UNLOCK(p);
splx(s);
suword(uap->aiocbp, (uintptr_t)cb->uuaiocb);
error = cb->uaiocb._aiocb_private.error;
@@ -2262,7 +2278,8 @@ aio_waitcomplete(struct thread *td, struct aio_waitcomplete_args *uap)
}
ki->kaio_flags |= KAIO_WAKEUP;
- error = tsleep(p, PRIBIO | PCATCH, "aiowc", timo);
+ error = msleep(p, &p->p_mtx, PDROP | PRIBIO | PCATCH, "aiowc",
+ timo);
splx(s);
if (error == ERESTART)
OpenPOWER on IntegriCloud