diff options
-rw-r--r-- | sys/kern/kern_descrip.c | 12 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 19 |
2 files changed, 19 insertions, 12 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 7144979..0f2dbad 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -2052,8 +2052,6 @@ fdrop_locked(fp, td) struct file *fp; struct thread *td; { - struct flock lf; - struct vnode *vp; int error; FILE_LOCK_ASSERT(fp, MA_OWNED); @@ -2064,17 +2062,9 @@ fdrop_locked(fp, td) } /* We have the last ref so we can proceed without the file lock. */ FILE_UNLOCK(fp); - mtx_lock(&Giant); if (fp->f_count < 0) panic("fdrop: count < 0"); - if ((fp->f_flag & FHASLOCK) && fp->f_type == DTYPE_VNODE) { - lf.l_whence = SEEK_SET; - lf.l_start = 0; - lf.l_len = 0; - lf.l_type = F_UNLCK; - vp = fp->f_vnode; - (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK); - } + mtx_lock(&Giant); if (fp->f_ops != &badfileops) error = fo_close(fp, td); else diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 1e9d3bb..2da4b6b 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ttycom.h> #include <sys/conf.h> #include <sys/syslog.h> +#include <sys/unistd.h> static fo_rdwr_t vn_read; static fo_rdwr_t vn_write; @@ -909,9 +910,25 @@ vn_closefile(fp, td) struct file *fp; struct thread *td; { + struct vnode *vp; + struct flock lf; + + GIANT_REQUIRED; + + KASSERT(fp->f_type == DTYPE_VNODE, ("vn_closefile: !DTYPE_VNODE")); + vp = fp->f_vnode; + + if (fp->f_flag & FHASLOCK) { + lf.l_whence = SEEK_SET; + lf.l_start = 0; + lf.l_len = 0; + lf.l_type = F_UNLCK; + (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK); + } fp->f_ops = &badfileops; - return (vn_close(fp->f_vnode, fp->f_flag, fp->f_cred, td)); + + return (vn_close(vp, fp->f_flag, fp->f_cred, td)); } /* |