Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/miscfs/genfs Restructure layer_lock() to always lock bef...
details: https://anonhg.NetBSD.org/src/rev/0868af7ba5d1
branches: trunk
changeset: 794334:0868af7ba5d1
user: hannken <hannken%NetBSD.org@localhost>
date: Wed Mar 12 09:39:23 2014 +0000
description:
Restructure layer_lock() to always lock before testing for dead node.
Use ISSET() to test flags, add assertions.
diffstat:
sys/miscfs/genfs/layer_vnops.c | 34 +++++++++++++++++++++-------------
1 files changed, 21 insertions(+), 13 deletions(-)
diffs (64 lines):
diff -r 58c82e7b84c9 -r 0868af7ba5d1 sys/miscfs/genfs/layer_vnops.c
--- a/sys/miscfs/genfs/layer_vnops.c Wed Mar 12 09:38:51 2014 +0000
+++ b/sys/miscfs/genfs/layer_vnops.c Wed Mar 12 09:39:23 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: layer_vnops.c,v 1.55 2014/02/27 16:51:38 hannken Exp $ */
+/* $NetBSD: layer_vnops.c,v 1.56 2014/03/12 09:39:23 hannken Exp $ */
/*
* Copyright (c) 1999 National Aeronautics & Space Administration
@@ -170,7 +170,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.55 2014/02/27 16:51:38 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.56 2014/03/12 09:39:23 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -718,15 +718,23 @@
int flags = ap->a_flags;
int error;
- if ((flags & LK_NOWAIT) != 0) {
- if (!mutex_tryenter(vp->v_interlock))
- return EBUSY;
- if ((vp->v_iflag & (VI_XLOCK | VI_CLEAN)) != 0) {
+ if (ISSET(flags, LK_NOWAIT)) {
+ error = VOP_LOCK(lowervp, flags);
+ if (error)
+ return error;
+ if (mutex_tryenter(vp->v_interlock)) {
+ if (ISSET(vp->v_iflag, VI_XLOCK))
+ error = EBUSY;
+ else if (ISSET(vp->v_iflag, VI_CLEAN))
+ error = ENOENT;
+ else
+ error = 0;
mutex_exit(vp->v_interlock);
- return EBUSY;
- }
- mutex_exit(vp->v_interlock);
- return VOP_LOCK(lowervp, flags);
+ } else
+ error = EBUSY;
+ if (error)
+ VOP_UNLOCK(lowervp);
+ return error;
}
error = VOP_LOCK(lowervp, flags);
@@ -734,10 +742,10 @@
return error;
mutex_enter(vp->v_interlock);
- if ((vp->v_iflag & (VI_XLOCK | VI_CLEAN)) != 0) {
+ if (ISSET(vp->v_iflag, VI_XLOCK) || ISSET(vp->v_iflag, VI_CLEAN)) {
VOP_UNLOCK(lowervp);
- if ((vp->v_iflag & VI_XLOCK))
- vwait(vp, VI_XLOCK);
+ vwait(vp, VI_XLOCK);
+ KASSERT(ISSET(vp->v_iflag, VI_CLEAN));
mutex_exit(vp->v_interlock);
return ENOENT;
}
Home |
Main Index |
Thread Index |
Old Index