Index: kern/kern_descrip.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/kern_descrip.c,v retrieving revision 1.294 diff -u -r1.294 kern_descrip.c --- kern/kern_descrip.c 1 Apr 2006 11:09:54 -0000 1.294 +++ kern/kern_descrip.c 21 Apr 2006 02:19:51 -0000 @@ -359,24 +359,7 @@ struct vnode *vp; u_int newmin; int error, flg, tmp; - int giant_locked; - - /* - * XXXRW: Some fcntl() calls require Giant -- others don't. Try to - * avoid grabbing Giant for calls we know don't need it. - */ - switch (cmd) { - case F_DUPFD: - case F_GETFD: - case F_SETFD: - case F_GETFL: - giant_locked = 0; - break; - - default: - giant_locked = 1; - mtx_lock(&Giant); - } + int giant_locked = 0; error = 0; flg = F_POSIX; @@ -391,9 +374,21 @@ } pop = &fdp->fd_ofileflags[fd]; + if ((fp->f_ops->fo_flags & DFLAG_MPSAFE) == 0) { + switch (cmd) { + case F_DUPFD: + case F_GETFD: + case F_SETFD: + case F_GETFL: + giant_locked = 0; + break; + default: + giant_locked = 1; + mtx_lock(&Giant); + } + } switch (cmd) { case F_DUPFD: - /* mtx_assert(&Giant, MA_NOTOWNED); */ FILEDESC_UNLOCK(fdp); newmin = arg; PROC_LOCK(p); @@ -408,20 +403,17 @@ break; case F_GETFD: - /* mtx_assert(&Giant, MA_NOTOWNED); */ td->td_retval[0] = (*pop & UF_EXCLOSE) ? FD_CLOEXEC : 0; FILEDESC_UNLOCK(fdp); break; case F_SETFD: - /* mtx_assert(&Giant, MA_NOTOWNED); */ *pop = (*pop &~ UF_EXCLOSE) | (arg & FD_CLOEXEC ? UF_EXCLOSE : 0); FILEDESC_UNLOCK(fdp); break; case F_GETFL: - /* mtx_assert(&Giant, MA_NOTOWNED); */ FILE_LOCK(fp); td->td_retval[0] = OFLAGS(fp->f_flag); FILE_UNLOCK(fp); @@ -429,7 +421,6 @@ break; case F_SETFL: - mtx_assert(&Giant, MA_OWNED); FILE_LOCK(fp); fhold_locked(fp); fp->f_flag &= ~FCNTLFLAGS; @@ -457,7 +448,6 @@ break; case F_GETOWN: - mtx_assert(&Giant, MA_OWNED); fhold(fp); FILEDESC_UNLOCK(fdp); error = fo_ioctl(fp, FIOGETOWN, &tmp, td->td_ucred, td); @@ -467,7 +457,6 @@ break; case F_SETOWN: - mtx_assert(&Giant, MA_OWNED); fhold(fp); FILEDESC_UNLOCK(fdp); tmp = arg; @@ -476,12 +465,10 @@ break; case F_SETLKW: - mtx_assert(&Giant, MA_OWNED); flg |= F_WAIT; /* FALLTHROUGH F_SETLK */ case F_SETLK: - mtx_assert(&Giant, MA_OWNED); if (fp->f_type != DTYPE_VNODE) { FILEDESC_UNLOCK(fdp); error = EBADF; @@ -555,7 +542,6 @@ break; case F_GETLK: - mtx_assert(&Giant, MA_OWNED); if (fp->f_type != DTYPE_VNODE) { FILEDESC_UNLOCK(fdp); error = EBADF; Index: kern/sys_pipe.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/sys_pipe.c,v retrieving revision 1.186 diff -u -r1.186 sys_pipe.c --- kern/sys_pipe.c 30 Jan 2006 08:25:04 -0000 1.186 +++ kern/sys_pipe.c 15 Apr 2006 20:38:31 -0000 @@ -153,7 +153,7 @@ .fo_kqfilter = pipe_kqfilter, .fo_stat = pipe_stat, .fo_close = pipe_close, - .fo_flags = DFLAG_PASSABLE + .fo_flags = DFLAG_PASSABLE | DFLAG_MPSAFE }; static void filt_pipedetach(struct knote *kn); Index: kern/sys_socket.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/sys_socket.c,v retrieving revision 1.69 diff -u -r1.69 sys_socket.c --- kern/sys_socket.c 16 Apr 2005 18:46:28 -0000 1.69 +++ kern/sys_socket.c 15 Apr 2006 20:35:06 -0000 @@ -63,7 +63,7 @@ .fo_kqfilter = soo_kqfilter, .fo_stat = soo_stat, .fo_close = soo_close, - .fo_flags = DFLAG_PASSABLE + .fo_flags = DFLAG_PASSABLE | DFLAG_MPSAFE }; /* ARGSUSED */ Index: kern/vfs_vnops.c =================================================================== RCS file: /usr/ncvs/src/sys/kern/vfs_vnops.c,v retrieving revision 1.241 diff -u -r1.241 vfs_vnops.c --- kern/vfs_vnops.c 31 Mar 2006 03:54:19 -0000 1.241 +++ kern/vfs_vnops.c 15 Apr 2006 19:31:39 -0000 @@ -78,7 +78,7 @@ .fo_kqfilter = vn_kqfilter, .fo_stat = vn_statfile, .fo_close = vn_closefile, - .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE + .fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE | DFLAG_MPSAFE }; int Index: sys/file.h =================================================================== RCS file: /usr/ncvs/src/sys/sys/file.h,v retrieving revision 1.71 diff -u -r1.71 file.h --- sys/file.h 26 Nov 2005 12:42:35 -0000 1.71 +++ sys/file.h 21 Apr 2006 01:03:11 -0000 @@ -92,6 +92,7 @@ #define DFLAG_PASSABLE 0x01 /* may be passed via unix sockets. */ #define DFLAG_SEEKABLE 0x02 /* seekable / nonsequential */ +#define DFLAG_MPSAFE 0x04 /* These fileops are MPSAFE */ /* * Kernel descriptor table.