Refactor the pnode2vnode translation slightly so that VFS_ROOT

can use it directly.
This commit is contained in:
pooka 2007-06-21 14:54:49 +00:00
parent 8921ea3a85
commit e601546393
5 changed files with 37 additions and 47 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_subr.c,v 1.33 2007/06/21 14:11:34 pooka Exp $ */
/* $NetBSD: puffs_subr.c,v 1.34 2007/06/21 14:54:49 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_subr.c,v 1.33 2007/06/21 14:11:34 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_subr.c,v 1.34 2007/06/21 14:54:49 pooka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -338,7 +338,7 @@ puffs_cookie2pnode(struct puffs_mount *pmp, void *cookie)
/*
* Make sure root vnode exists and reference it. Does NOT lock.
*/
int
static int
puffs_makeroot(struct puffs_mount *pmp)
{
struct vnode *vp;
@ -396,46 +396,48 @@ puffs_makeroot(struct puffs_mount *pmp)
* in situations where we want the vnode but don't care for the
* vnode lock, e.g. file server issued putpages.
*/
struct vnode *
puffs_pnode2vnode(struct puffs_mount *pmp, void *cookie, int lock)
int
puffs_pnode2vnode(struct puffs_mount *pmp, void *cookie, int lock,
struct vnode **vpp)
{
struct puffs_node *pnode;
struct vnode *vp;
int vgetflags;
int vgetflags, rv;
/*
* Handle root in a special manner, since we want to make sure
* pmp_root is properly set.
*/
if (cookie == pmp->pmp_root_cookie) {
if (puffs_makeroot(pmp))
return NULL;
if ((rv = puffs_makeroot(pmp)))
return rv;
if (lock)
vn_lock(pmp->pmp_root, LK_EXCLUSIVE | LK_RETRY);
return pmp->pmp_root;
*vpp = pmp->pmp_root;
return 0;
}
vgetflags = LK_INTERLOCK;
if (lock)
vgetflags |= LK_EXCLUSIVE | LK_RETRY;
mutex_enter(&pmp->pmp_lock);
pnode = puffs_cookie2pnode(pmp, cookie);
if (pnode == NULL) {
mutex_exit(&pmp->pmp_lock);
return NULL;
return ENOENT;
}
vp = pnode->pn_vp;
vp = pnode->pn_vp;
simple_lock(&vp->v_interlock);
mutex_exit(&pmp->pmp_lock);
if (vget(vp, vgetflags))
return NULL;
vgetflags = LK_INTERLOCK;
if (lock)
vgetflags |= LK_EXCLUSIVE | LK_RETRY;
if ((rv = vget(vp, vgetflags)))
return rv;
return vp;
*vpp = vp;
return 0;
}
void

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_sys.h,v 1.40 2007/06/21 14:11:34 pooka Exp $ */
/* $NetBSD: puffs_sys.h,v 1.41 2007/06/21 14:54:49 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -227,8 +227,7 @@ void puffs_putvnode(struct vnode *);
void puffs_releasenode(struct puffs_node *);
void puffs_referencenode(struct puffs_node *);
int puffs_makeroot(struct puffs_mount *);
struct vnode *puffs_pnode2vnode(struct puffs_mount *, void *, int);
int puffs_pnode2vnode(struct puffs_mount *, void *, int, struct vnode **);
void puffs_makecn(struct puffs_kcn *, const struct componentname *);
void puffs_credcvt(struct puffs_cred *, kauth_cred_t);
pid_t puffs_lwp2pid(struct lwp *);

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_transport.c,v 1.19 2007/06/06 01:55:00 pooka Exp $ */
/* $NetBSD: puffs_transport.c,v 1.20 2007/06/21 14:54:49 pooka Exp $ */
/*
* Copyright (c) 2006 Antti Kantee. All Rights Reserved.
@ -29,7 +29,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_transport.c,v 1.19 2007/06/06 01:55:00 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_transport.c,v 1.20 2007/06/21 14:54:49 pooka Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@ -337,8 +337,6 @@ puffs_flush(struct puffs_mount *pmp, struct puffs_flush *pf)
return 0;
}
rv = 0;
/*
* Get vnode, don't lock it. Namecache is protected by its own lock
* and we have a reference to protect against premature harvesting.
@ -348,9 +346,9 @@ puffs_flush(struct puffs_mount *pmp, struct puffs_flush *pf)
* reason we need to eventually bump locking to userspace, as we
* will need to lock the node if we wish to do flushes.
*/
vp = puffs_pnode2vnode(pmp, pf->pf_cookie, 0);
if (vp == NULL)
return ENOENT;
rv = puffs_pnode2vnode(pmp, pf->pf_cookie, 0, &vp);
if (rv)
return rv;
switch (pf->pf_op) {
#if 0

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_vfsops.c,v 1.44 2007/06/21 14:11:34 pooka Exp $ */
/* $NetBSD: puffs_vfsops.c,v 1.45 2007/06/21 14:54:49 pooka Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.44 2007/06/21 14:11:34 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.45 2007/06/21 14:54:49 pooka Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@ -339,18 +339,9 @@ puffs_unmount(struct mount *mp, int mntflags, struct lwp *l)
int
puffs_root(struct mount *mp, struct vnode **vpp)
{
struct puffs_mount *pmp;
int rv;
struct puffs_mount *pmp = MPTOPUFFSMP(mp);
pmp = MPTOPUFFSMP(mp);
rv = puffs_makeroot(pmp);
if (rv)
return rv;
vn_lock(pmp->pmp_root, LK_EXCLUSIVE | LK_RETRY);
*vpp = pmp->pmp_root;
return 0;
return puffs_pnode2vnode(pmp, pmp->pmp_root_cookie, 1, vpp);
}
int
@ -559,10 +550,10 @@ puffs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
if (error)
goto out;
vp = puffs_pnode2vnode(pmp, fhtonode_argp->pvfsr_fhcookie, 1);
error = puffs_pnode2vnode(pmp, fhtonode_argp->pvfsr_fhcookie, 1, &vp);
DPRINTF(("puffs_fhtovp: got cookie %p, existing vnode %p\n",
fhtonode_argp->pvfsr_fhcookie, vp));
if (!vp) {
if (error) {
error = puffs_getvnode(mp, fhtonode_argp->pvfsr_fhcookie,
fhtonode_argp->pvfsr_vtype, fhtonode_argp->pvfsr_size,
fhtonode_argp->pvfsr_rdev, &vp);

View File

@ -1,4 +1,4 @@
/* $NetBSD: puffs_vnops.c,v 1.76 2007/06/06 01:55:00 pooka Exp $ */
/* $NetBSD: puffs_vnops.c,v 1.77 2007/06/21 14:54:49 pooka Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.76 2007/06/06 01:55:00 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.77 2007/06/21 14:54:49 pooka Exp $");
#include <sys/param.h>
#include <sys/fstrans.h>
@ -497,8 +497,8 @@ puffs_lookup(void *v)
/* XXX: race here */
/* XXX2: this check for node existence twice */
vp = puffs_pnode2vnode(pmp, lookup_arg.pvnr_newnode, 1);
if (!vp) {
error = puffs_pnode2vnode(pmp, lookup_arg.pvnr_newnode, 1, &vp);
if (error) {
error = puffs_getvnode(dvp->v_mount,
lookup_arg.pvnr_newnode, lookup_arg.pvnr_vtype,
lookup_arg.pvnr_size, lookup_arg.pvnr_rdev, &vp);