Source-Changes-HG archive

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

[src/trunk]: src/sys/kern When both vget() and vrelel() call vn_lock() we kno...



details:   https://anonhg.NetBSD.org/src/rev/f2f1ae6bc2f0
branches:  trunk
changeset: 756618:f2f1ae6bc2f0
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Jul 26 15:22:16 2010 +0000

description:
When both vget() and vrelel() call vn_lock() we know VI_XLOCK is clear.
No need to use LK_INTERLOCK or LK_RETRY here.
The return value of vn_lock() is already examined here.

Ok: Antti Kantee <pooka%netbsd.org@localhost>

diffstat:

 sys/kern/vfs_subr.c |  17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diffs (56 lines):

diff -r 904dca214d26 -r f2f1ae6bc2f0 sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Mon Jul 26 15:14:33 2010 +0000
+++ b/sys/kern/vfs_subr.c       Mon Jul 26 15:22:16 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.411 2010/07/25 10:23:40 hannken Exp $   */
+/*     $NetBSD: vfs_subr.c,v 1.412 2010/07/26 15:22:16 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.411 2010/07/25 10:23:40 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.412 2010/07/26 15:22:16 hannken Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -1332,13 +1332,12 @@
         * Ok, we got it in good shape.  Just locking left.
         */
        KASSERT((vp->v_iflag & VI_CLEAN) == 0);
+       mutex_exit(&vp->v_interlock);
        if (flags & (LK_EXCLUSIVE | LK_SHARED)) {
-               error = vn_lock(vp, flags | LK_INTERLOCK);
+               error = vn_lock(vp, flags);
                if (error != 0) {
                        vrele(vp);
                }
-       } else {
-               mutex_exit(&vp->v_interlock);
        }
        return error;
 }
@@ -1438,8 +1437,8 @@
                         */
                        vp->v_iflag &= ~(VI_INACTREDO|VI_INACTNOW);
                        cv_broadcast(&vp->v_cv);
-                       error = vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK |
-                           LK_RETRY);
+                       mutex_exit(&vp->v_interlock);
+                       error = vn_lock(vp, LK_EXCLUSIVE);
                        if (error != 0) {
                                /* XXX */
                                vpanic(vp, "vrele: unable to lock %p");
@@ -1467,8 +1466,8 @@
                } else {                
                        /* If we can't acquire the lock, then defer. */
                        vp->v_iflag &= ~VI_INACTREDO;
-                       error = vn_lock(vp, LK_EXCLUSIVE | LK_INTERLOCK |
-                           LK_NOWAIT);
+                       mutex_exit(&vp->v_interlock);
+                       error = vn_lock(vp, LK_EXCLUSIVE | LK_NOWAIT);
                        if (error != 0) {
                                defer = true;
                                mutex_enter(&vp->v_interlock);



Home | Main Index | Thread Index | Old Index