Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Modify vn_lock():



details:   https://anonhg.NetBSD.org/src/rev/2173c503925c
branches:  trunk
changeset: 756669:2173c503925c
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed Jul 28 09:30:21 2010 +0000

description:
Modify vn_lock():
- Take v_interlock before examining v_iflag
- Must always be called without v_interlock taken,
  LK_INTERLOCK flag is no longer allowed.

diffstat:

 sys/kern/vfs_vnops.c |  22 +++++++---------------
 1 files changed, 7 insertions(+), 15 deletions(-)

diffs (59 lines):

diff -r 536592bfdb1c -r 2173c503925c sys/kern/vfs_vnops.c
--- a/sys/kern/vfs_vnops.c      Wed Jul 28 00:00:11 2010 +0000
+++ b/sys/kern/vfs_vnops.c      Wed Jul 28 09:30:21 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_vnops.c,v 1.175 2010/07/13 15:38:15 pooka Exp $    */
+/*     $NetBSD: vfs_vnops.c,v 1.176 2010/07/28 09:30:21 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.175 2010/07/13 15:38:15 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnops.c,v 1.176 2010/07/28 09:30:21 hannken Exp $");
 
 #include "veriexec.h"
 
@@ -770,12 +770,10 @@
        int error;
 
 #if 0
-       KASSERT(vp->v_usecount > 0 || (flags & LK_INTERLOCK) != 0
-           || (vp->v_iflag & VI_ONWORKLST) != 0);
+       KASSERT(vp->v_usecount > 0 || (vp->v_iflag & VI_ONWORKLST) != 0);
 #endif
-       KASSERT((flags &
-           ~(LK_INTERLOCK|LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY))
-           == 0);
+       KASSERT((flags & ~(LK_SHARED|LK_EXCLUSIVE|LK_NOWAIT|LK_RETRY)) == 0);
+       KASSERT(!mutex_owned(&vp->v_interlock));
 
 #ifdef DIAGNOSTIC
        if (wapbl_vphaswapbl(vp))
@@ -787,11 +785,8 @@
                 * XXX PR 37706 forced unmount of file systems is unsafe.
                 * Race between vclean() and this the remaining problem.
                 */
+               mutex_enter(&vp->v_interlock);
                if (vp->v_iflag & VI_XLOCK) {
-                       if ((flags & LK_INTERLOCK) == 0) {
-                               mutex_enter(&vp->v_interlock);
-                       }
-                       flags &= ~LK_INTERLOCK;
                        if (flags & LK_NOWAIT) {
                                mutex_exit(&vp->v_interlock);
                                return EBUSY;
@@ -800,10 +795,7 @@
                        mutex_exit(&vp->v_interlock);
                        error = ENOENT;
                } else {
-                       if ((flags & LK_INTERLOCK) != 0) {
-                               mutex_exit(&vp->v_interlock);
-                       }
-                       flags &= ~LK_INTERLOCK;
+                       mutex_exit(&vp->v_interlock);
                        error = VOP_LOCK(vp, (flags & ~LK_RETRY));
                        if (error == 0 || error == EDEADLK || error == EBUSY)
                                return (error);



Home | Main Index | Thread Index | Old Index