diff options
author | alfred <alfred@FreeBSD.org> | 2002-01-19 01:03:54 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2002-01-19 01:03:54 +0000 |
commit | 20073b03222ce9d43b2d432e035bd2e049f47ea6 (patch) | |
tree | 92518e39867d967ad979689670bf924da1d8deb6 /sys/kern/sys_generic.c | |
parent | 1d07367781bb565df7c1015af891004f6ed68974 (diff) | |
download | FreeBSD-src-20073b03222ce9d43b2d432e035bd2e049f47ea6.zip FreeBSD-src-20073b03222ce9d43b2d432e035bd2e049f47ea6.tar.gz |
undo a bit of the Giant pushdown.
fdrop isn't SMP safe as it may call into the file's close routine which
definetly is not SMP safe right now, so we hold Giant over calls to
fdrop now.
Diffstat (limited to 'sys/kern/sys_generic.c')
-rw-r--r-- | sys/kern/sys_generic.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c index d4fd7285..0a900b6 100644 --- a/sys/kern/sys_generic.c +++ b/sys/kern/sys_generic.c @@ -164,15 +164,15 @@ pread(td, uap) fp = holdfp(td->td_proc->p_fd, uap->fd, FREAD); if (fp == NULL) return (EBADF); + mtx_lock(&Giant); if (fp->f_type != DTYPE_VNODE) { error = ESPIPE; } else { - mtx_lock(&Giant); error = dofileread(td, fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); - mtx_unlock(&Giant); } fdrop(fp, td); + mtx_unlock(&Giant); return(error); } @@ -395,15 +395,15 @@ pwrite(td, uap) int error; if ((error = fget_write(td, uap->fd, &fp)) == 0) { + mtx_lock(&Giant); if (fp->f_type == DTYPE_VNODE) { - mtx_lock(&Giant); error = dofilewrite(td, fp, uap->fd, uap->buf, uap->nbyte, uap->offset, FOF_OFFSET); - mtx_unlock(&Giant); } else { error = ESPIPE; } fdrop(fp, td); + mtx_unlock(&Giant); } else { error = EBADF; /* this can't be right */ } @@ -619,8 +619,10 @@ ioctl(td, uap) if ((error = fget(td, uap->fd, &fp)) != 0) return (error); + mtx_lock(&Giant); if ((fp->f_flag & (FREAD | FWRITE)) == 0) { fdrop(fp, td); + mtx_unlock(&Giant); return (EBADF); } fdp = td->td_proc->p_fd; @@ -630,12 +632,14 @@ ioctl(td, uap) fdp->fd_ofileflags[uap->fd] &= ~UF_EXCLOSE; FILEDESC_UNLOCK(fdp); fdrop(fp, td); + mtx_unlock(&Giant); return (0); case FIOCLEX: FILEDESC_LOCK(fdp); fdp->fd_ofileflags[uap->fd] |= UF_EXCLOSE; FILEDESC_UNLOCK(fdp); fdrop(fp, td); + mtx_unlock(&Giant); return (0); } @@ -646,10 +650,10 @@ ioctl(td, uap) size = IOCPARM_LEN(com); if (size > IOCPARM_MAX) { fdrop(fp, td); + mtx_unlock(&Giant); return (ENOTTY); } - mtx_lock(&Giant); memp = NULL; if (size > sizeof (ubuf.stkbuf)) { memp = (caddr_t)malloc((u_long)size, M_IOCTLOPS, M_WAITOK); |