aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/vfs_vnops.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index dd5e3765e3a8..70cdcdc6f752 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -430,12 +430,9 @@ vn_writechk(vp)
/*
* Vnode close call
*/
-int
-vn_close(vp, flags, file_cred, td)
- register struct vnode *vp;
- int flags;
- struct ucred *file_cred;
- struct thread *td;
+static int
+vn_close1(struct vnode *vp, int flags, struct ucred *file_cred,
+ struct thread *td, bool keep_ref)
{
struct mount *mp;
int error, lock_flags;
@@ -457,11 +454,22 @@ vn_close(vp, flags, file_cred, td)
__func__, vp, vp->v_writecount);
}
error = VOP_CLOSE(vp, flags, file_cred, td);
- vput(vp);
+ if (keep_ref)
+ VOP_UNLOCK(vp, 0);
+ else
+ vput(vp);
vn_finished_write(mp);
return (error);
}
+int
+vn_close(struct vnode *vp, int flags, struct ucred *file_cred,
+ struct thread *td)
+{
+
+ return (vn_close1(vp, flags, file_cred, td, false));
+}
+
/*
* Heuristic to detect sequential operation.
*/
@@ -1573,18 +1581,15 @@ vn_closefile(struct file *fp, struct thread *td)
struct vnode *vp;
struct flock lf;
int error;
+ bool ref;
vp = fp->f_vnode;
fp->f_ops = &badfileops;
+ ref= (fp->f_flag & FHASLOCK) != 0 && fp->f_type == DTYPE_VNODE;
- if (__predict_false((fp->f_flag & FHASLOCK) != 0) &&
- fp->f_type == DTYPE_VNODE)
- vrefact(vp);
-
- error = vn_close(vp, fp->f_flag, fp->f_cred, td);
+ error = vn_close1(vp, fp->f_flag, fp->f_cred, td, ref);
- if (__predict_false((fp->f_flag & FHASLOCK) != 0) &&
- fp->f_type == DTYPE_VNODE) {
+ if (__predict_false(ref)) {
lf.l_whence = SEEK_SET;
lf.l_start = 0;
lf.l_len = 0;