Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Change vnode operation lookup to return the resulting vnode ...
details: https://anonhg.NetBSD.org/src/rev/9d6b9429bda9
branches: trunk
changeset: 326616:9d6b9429bda9
user: hannken <hannken%NetBSD.org@localhost>
date: Fri Feb 07 15:29:20 2014 +0000
description:
Change vnode operation lookup to return the resulting vnode *vpp unlocked.
Change cache_lookup() to return an unlocked vnode.
Discussed on tech-kern@
Welcome to 6.99.31
diffstat:
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c | 14 +++++-
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c | 10 +---
lib/libp2k/p2k.c | 3 +-
share/man/man9/namecache.9 | 7 +-
share/man/man9/vnodeops.9 | 17 ++-----
sys/coda/coda_vnops.c | 40 +---------------
sys/fs/adosfs/adlookup.c | 8 ++-
sys/fs/cd9660/cd9660_lookup.c | 9 ++-
sys/fs/efs/efs_vnops.c | 9 ++-
sys/fs/filecorefs/filecore_lookup.c | 8 ++-
sys/fs/hfs/hfs_vnops.c | 8 ++-
sys/fs/msdosfs/msdosfs_lookup.c | 11 +++-
sys/fs/nilfs/nilfs_vnops.c | 12 +++-
sys/fs/ntfs/ntfs_vnops.c | 9 ++-
sys/fs/ptyfs/ptyfs_vnops.c | 11 ++-
sys/fs/puffs/puffs_vnops.c | 27 +++++-----
sys/fs/smbfs/smbfs_vnops.c | 17 ++++--
sys/fs/sysvbfs/sysvbfs_vnops.c | 7 +-
sys/fs/tmpfs/tmpfs_vnops.c | 14 +++--
sys/fs/udf/udf_vnops.c | 8 ++-
sys/fs/union/union_subr.c | 11 +--
sys/fs/union/union_vnops.c | 19 ++++++-
sys/fs/v7fs/v7fs_vnops.c | 8 ++-
sys/kern/vfs_cache.c | 26 +----------
sys/kern/vfs_getcwd.c | 16 ++++--
sys/kern/vfs_lookup.c | 31 +++++++++++--
sys/kern/vnode_if.c | 14 ++--
sys/miscfs/deadfs/dead_vnops.c | 6 +-
sys/miscfs/fdesc/fdesc_vnops.c | 7 +-
sys/miscfs/fifofs/fifo_vnops.c | 6 +-
sys/miscfs/genfs/layer_vnops.c | 10 ++--
sys/miscfs/kernfs/kernfs_vnops.c | 11 ++-
sys/miscfs/procfs/procfs_subr.c | 30 ++++--------
sys/miscfs/procfs/procfs_vfsops.c | 16 +++++-
sys/miscfs/procfs/procfs_vnops.c | 33 ++-----------
sys/miscfs/specfs/spec_vnops.c | 6 +-
sys/miscfs/umapfs/umap_vnops.c | 8 +-
sys/nfs/nfs_vnops.c | 16 ++++--
sys/rump/include/rump/rumpvnode_if.h | 4 +-
sys/rump/librump/rumpvfs/rumpfs.c | 20 +------
sys/rump/librump/rumpvfs/rumpvnode_if.c | 6 +-
sys/sys/param.h | 4 +-
sys/sys/vnode_if.h | 6 +-
sys/ufs/chfs/chfs_vnops.c | 19 ++++---
sys/ufs/ext2fs/ext2fs_lookup.c | 12 +++-
sys/ufs/lfs/ulfs_extattr.c | 17 +++++--
sys/ufs/lfs/ulfs_lookup.c | 8 ++-
sys/ufs/ufs/ufs_extattr.c | 17 +++++--
sys/ufs/ufs/ufs_lookup.c | 8 ++-
tests/rump/rumpvfs/t_p2kifs.c | 4 +-
50 files changed, 330 insertions(+), 318 deletions(-)
diffs (truncated from 2181 to 300 lines):
diff -r 2358ff14a3d8 -r 9d6b9429bda9 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c Fri Feb 07 15:26:42 2014 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_replay.c Fri Feb 07 15:29:20 2014 +0000
@@ -572,6 +572,12 @@
VOP_UNLOCK(ZTOV(dzp));
goto fail;
}
+ error = vn_lock(vp, LK_EXCLUSIVE);
+ if (error != 0) {
+ VOP_UNLOCK(ZTOV(dzp));
+ vrele(vp);
+ goto fail;
+ }
switch ((int)lr->lr_common.lrc_txtype) {
case TX_REMOVE:
@@ -667,7 +673,6 @@
VOP_UNLOCK(ZTOV(sdzp));
if (error != 0)
goto fail;
- VOP_UNLOCK(svp);
tcn.cn_nameptr = tname;
tcn.cn_namelen = strlen(tname);
@@ -682,6 +687,13 @@
else if (error != 0) {
VOP_UNLOCK(ZTOV(tdzp));
goto fail;
+ } else {
+ error = vn_lock(tvp, LK_EXCLUSIVE);
+ if (error != 0) {
+ VOP_UNLOCK(ZTOV(tdzp));
+ vrele(tvp);
+ goto fail;
+ }
}
error = VOP_RENAME(ZTOV(sdzp), svp, &scn, ZTOV(tdzp), tvp, &tcn /*,vflg*/);
diff -r 2358ff14a3d8 -r 9d6b9429bda9 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Fri Feb 07 15:26:42 2014 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Fri Feb 07 15:29:20 2014 +0000
@@ -4813,7 +4813,7 @@
static int
zfs_netbsd_lookup(void *v)
{
- struct vop_lookup_args /* {
+ struct vop_lookup_v2_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
@@ -4890,9 +4890,6 @@
}
KASSERT(*vpp != NULL); /* XXX Correct? */
- /*
- * Do a locking dance in conformance to the VOP_LOOKUP protocol.
- */
if ((cnp->cn_namelen == 1) && (cnp->cn_nameptr[0] == '.')) {
KASSERT(!(cnp->cn_flags & ISDOTDOT));
KASSERT(dvp == *vpp);
@@ -4900,17 +4897,12 @@
(cnp->cn_nameptr[0] == '.') &&
(cnp->cn_nameptr[1] == '.')) {
KASSERT(cnp->cn_flags & ISDOTDOT);
- VOP_UNLOCK(dvp);
- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
} else {
KASSERT(!(cnp->cn_flags & ISDOTDOT));
- vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
}
out:
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
- KASSERT((*vpp == NULL) || (VOP_ISLOCKED(*vpp) == LK_EXCLUSIVE));
#if 0 /* Namecache too scary to contemplate. */
/*
diff -r 2358ff14a3d8 -r 9d6b9429bda9 lib/libp2k/p2k.c
--- a/lib/libp2k/p2k.c Fri Feb 07 15:26:42 2014 +0000
+++ b/lib/libp2k/p2k.c Fri Feb 07 15:29:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: p2k.c,v 1.62 2014/01/23 10:13:55 hannken Exp $ */
+/* $NetBSD: p2k.c,v 1.63 2014/02/07 15:29:21 hannken Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved.
@@ -731,7 +731,6 @@
}
return rv;
}
- RUMP_VOP_UNLOCK(vp);
p2n = getp2n(p2m, vp, false, NULL);
if (p2n == NULL) {
diff -r 2358ff14a3d8 -r 9d6b9429bda9 share/man/man9/namecache.9
--- a/share/man/man9/namecache.9 Fri Feb 07 15:26:42 2014 +0000
+++ b/share/man/man9/namecache.9 Fri Feb 07 15:29:20 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: namecache.9,v 1.17 2012/11/05 22:49:14 wiz Exp $
+.\" $NetBSD: namecache.9,v 1.18 2014/02/07 15:29:21 hannken Exp $
.\"
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd November 5, 2012
+.Dd February 7, 2014
.Dt NAMECACHE 9
.Os
.Sh NAME
@@ -157,8 +157,7 @@
.Fn cache_lookup
returns zero
.Pq false .
-On a positive hit, the vnode for the object found is locked and stored
-in
+On a positive hit, the unlocked vnode for the object found is stored in
.Fa vpp ,
and a nonzero
.Pq true
diff -r 2358ff14a3d8 -r 9d6b9429bda9 share/man/man9/vnodeops.9
--- a/share/man/man9/vnodeops.9 Fri Feb 07 15:26:42 2014 +0000
+++ b/share/man/man9/vnodeops.9 Fri Feb 07 15:29:20 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: vnodeops.9,v 1.91 2014/01/23 10:13:56 hannken Exp $
+.\" $NetBSD: vnodeops.9,v 1.92 2014/02/07 15:29:21 hannken Exp $
.\"
.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 23, 2014
+.Dd February 7, 2014
.Dt VNODEOPS 9
.Os
.Sh NAME
@@ -367,7 +367,7 @@
.Fa cnp
is the pathname component to be searched for.
If the pathname component is found, the address of the resulting
-locked vnode is returned in
+unlocked vnode is returned in
.Fa vpp .
The operation specified in
.Em cnp-\*[Gt]cn_nameiop
@@ -382,13 +382,6 @@
.Fa dvp
has an extra reference added to it and it is returned in
.Fa *vpp .
-If the pathname component being search for is ".." (ISDOTDOT),
-.Fa dvp
-is unlocked, the ".." node is locked and then
-.Fa dvp
-is relocked.
-This process preserves the protocol of always locking nodes from root
-downward and prevents deadlock.
For other pathname components,
.Fn VOP_LOOKUP
checks the accessibility of the directory and searches the name cache
@@ -397,7 +390,7 @@
.Xr namecache 9 .
If the pathname is not found in the name cache, the directory is
searched for the pathname.
-The resulting locked vnode is returned in
+The resulting unlocked vnode is returned in
.Fa vpp .
.Fa dvp
is always returned locked.
@@ -411,7 +404,7 @@
is left locked.
If the operation is successful
.Fa *vpp
-is locked and zero is returned.
+is unlocked and zero is returned.
Typically, if
.Fa *vpp
and
diff -r 2358ff14a3d8 -r 9d6b9429bda9 sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c Fri Feb 07 15:26:42 2014 +0000
+++ b/sys/coda/coda_vnops.c Fri Feb 07 15:29:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coda_vnops.c,v 1.93 2014/01/23 10:13:56 hannken Exp $ */
+/* $NetBSD: coda_vnops.c,v 1.94 2014/02/07 15:29:21 hannken Exp $ */
/*
*
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.93 2014/01/23 10:13:56 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.94 2014/02/07 15:29:21 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -882,7 +882,7 @@
coda_lookup(void *v)
{
/* true args */
- struct vop_lookup_args *ap = v;
+ struct vop_lookup_v2_args *ap = v;
/* (locked) vnode of dir in which to do lookup */
vnode_t *dvp = ap->a_dvp;
struct cnode *dcp = VTOC(dvp);
@@ -896,7 +896,6 @@
struct cnode *cp;
const char *nm = cnp->cn_nameptr;
int len = cnp->cn_namelen;
- int flags = cnp->cn_flags;
CodaFid VFid;
int vtype;
int error = 0;
@@ -912,9 +911,7 @@
/*
* The overall strategy is to switch on the lookup type and get a
- * result vnode that is vref'd but not locked. Then, the code at
- * exit: switches on ., .., and regular lookups and does the right
- * locking.
+ * result vnode that is vref'd but not locked.
*/
/* Check for lookup of control object. */
@@ -990,32 +987,6 @@
*ap->a_vpp = NULL;
}
- /*
- * If the lookup succeeded, we must generally lock the returned
- * vnode. This could be a ., .., or normal lookup. See
- * vnodeops(9) for the details.
- */
- /*
- * XXX LK_RETRY is likely incorrect. Handle vn_lock failure
- * somehow, and remove LK_RETRY.
- */
- if (!error || (error == EJUSTRETURN)) {
- /* Lookup has a value and it isn't "."? */
- if (*ap->a_vpp && (*ap->a_vpp != dvp)) {
- if (flags & ISDOTDOT)
- /* ..: unlock parent */
- VOP_UNLOCK(dvp);
- /* all but .: lock child */
- vn_lock(*ap->a_vpp, LK_EXCLUSIVE | LK_RETRY);
- if (flags & ISDOTDOT)
- /* ..: relock parent */
- vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
- }
- /* else .: leave dvp locked */
- } else {
- /* The lookup failed, so return NULL. Leave dvp locked. */
- *ap->a_vpp = NULL;
- }
return(error);
}
@@ -1554,9 +1525,6 @@
cnp->cn_flags &= ~(MODMASK | OPMASK);
cnp->cn_flags |= LOOKUP;
error = VOP_LOOKUP(dvp, ap->a_vpp, cnp);
- /* XXX unlock node until lookup returns unlocked nodes. */
- if (error == 0)
- VOP_UNLOCK(*ap->a_vpp);
cnp->cn_flags = saved_cn_flags;
}
diff -r 2358ff14a3d8 -r 9d6b9429bda9 sys/fs/adosfs/adlookup.c
--- a/sys/fs/adosfs/adlookup.c Fri Feb 07 15:26:42 2014 +0000
+++ b/sys/fs/adosfs/adlookup.c Fri Feb 07 15:29:20 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adlookup.c,v 1.18 2012/11/05 17:27:37 dholland Exp $ */
+/* $NetBSD: adlookup.c,v 1.19 2014/02/07 15:29:21 hannken Exp $ */
/*
* Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.18 2012/11/05 17:27:37 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adlookup.c,v 1.19 2014/02/07 15:29:21 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -64,7 +64,7 @@
int
adosfs_lookup(void *v)
{
- struct vop_lookup_args /* {
+ struct vop_lookup_v2_args /* {
struct vnode *a_dvp;
struct vnode **a_vpp;
struct componentname *a_cnp;
@@ -243,6 +243,8 @@
if (vdp == *vpp)
Home |
Main Index |
Thread Index |
Old Index