Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Lock the vnode before changing its writecount.



details:   https://anonhg.NetBSD.org/src/rev/665d4198f944
branches:  trunk
changeset: 352398:665d4198f944
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Mar 30 09:13:37 2017 +0000

description:
Lock the vnode before changing its writecount.

diffstat:

 sys/kern/vfs_vnops.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r d54d0c4ea94a -r 665d4198f944 sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c      Thu Mar 30 09:13:01 2017 +0000
+++ b/sys/kern/vfs_vnops.c      Thu Mar 30 09:13:37 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $  */
+/*     $NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $  */
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.194 2017/03/01 10:43:37 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.195 2017/03/30 09:13:37 hannken Exp $");
 
 #include "veriexec.h"
 
@@ -376,13 +376,13 @@
 {
        int error;
 
+       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        if (flags & FWRITE) {
                mutex_enter(vp->v_interlock);
                KASSERT(vp->v_writecount > 0);
                vp->v_writecount--;
                mutex_exit(vp->v_interlock);
        }
-       vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        error = VOP_CLOSE(vp, flags, cred);
        vput(vp);
        return (error);



Home | Main Index | Thread Index | Old Index