Replace vget() with vref()/vn_lock(), this node already has a reference.

This commit is contained in:
hannken 2010-07-09 08:10:50 +00:00
parent 3cc3be4df9
commit 7296ba383a
5 changed files with 30 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_node.c,v 1.43 2010/06/24 13:03:10 hannken Exp $ */
/* $NetBSD: smbfs_node.c,v 1.44 2010/07/09 08:16:28 hannken Exp $ */
/*
* Copyright (c) 2000-2001 Boris Popov
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_node.c,v 1.43 2010/06/24 13:03:10 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_node.c,v 1.44 2010/07/09 08:16:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -112,8 +112,11 @@ smbfs_node_alloc(struct mount *mp, struct vnode *dvp,
if (dvp == NULL)
return EINVAL;
vp = VTOSMB(VTOSMB(dvp)->n_parent)->n_vnode;
if ((error = vget(vp, LK_EXCLUSIVE | LK_RETRY)) == 0)
vref(vp);
if ((error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY)) == 0)
*vpp = vp;
else
vrele(vp);
return (error);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: smbfs_vfsops.c,v 1.91 2010/06/24 13:03:10 hannken Exp $ */
/* $NetBSD: smbfs_vfsops.c,v 1.92 2010/07/09 08:16:28 hannken Exp $ */
/*
* Copyright (c) 2000-2001, Boris Popov
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.91 2010/06/24 13:03:10 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: smbfs_vfsops.c,v 1.92 2010/07/09 08:16:28 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -322,9 +322,10 @@ int
smbfs_root(struct mount *mp, struct vnode **vpp)
{
struct smbmount *smp = VFSTOSMBFS(mp);
int error;
if (__predict_false(!smp->sm_root)) {
int error = smbfs_setroot(mp);
error = smbfs_setroot(mp);
if (error)
return (error);
/* fallthrough */
@ -332,7 +333,11 @@ smbfs_root(struct mount *mp, struct vnode **vpp)
KASSERT(smp->sm_root != NULL && SMBTOV(smp->sm_root) != NULL);
*vpp = SMBTOV(smp->sm_root);
return vget(*vpp, LK_EXCLUSIVE | LK_RETRY);
vref(*vpp);
error = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY);
if (error)
vrele(*vpp);
return error;
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: overlay_vfsops.c,v 1.55 2010/06/24 13:03:17 hannken Exp $ */
/* $NetBSD: overlay_vfsops.c,v 1.56 2010/07/09 08:14:26 hannken Exp $ */
/*
* Copyright (c) 1999, 2000 National Aeronautics & Space Administration
@ -74,7 +74,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.55 2010/06/24 13:03:17 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: overlay_vfsops.c,v 1.56 2010/07/09 08:14:26 hannken Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -136,8 +136,11 @@ ov_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
* Find lower node
*/
lowerrootvp = mp->mnt_vnodecovered;
if ((error = vget(lowerrootvp, LK_EXCLUSIVE | LK_RETRY)))
vref(lowerrootvp);
if ((error = vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY))) {
vrele(lowerrootvp);
return (error);
}
/*
* First cut at fixing up upper mount point

View File

@ -1,4 +1,4 @@
/* $NetBSD: rumpfs.c,v 1.60 2010/07/03 10:55:47 pooka Exp $ */
/* $NetBSD: rumpfs.c,v 1.61 2010/07/09 08:10:50 hannken Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.60 2010/07/03 10:55:47 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.61 2010/07/09 08:10:50 hannken Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@ -1207,7 +1207,8 @@ rumpfs_root(struct mount *mp, struct vnode **vpp)
{
struct rumpfs_mount *rfsmp = mp->mnt_data;
vget(rfsmp->rfsmp_rvp, LK_EXCLUSIVE | LK_RETRY);
vref(rfsmp->rfsmp_rvp);
vn_lock(rfsmp->rfsmp_rvp, LK_EXCLUSIVE | LK_RETRY);
*vpp = rfsmp->rfsmp_rvp;
return 0;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uvm_swap.c,v 1.151 2010/06/24 13:03:20 hannken Exp $ */
/* $NetBSD: uvm_swap.c,v 1.152 2010/07/09 08:13:33 hannken Exp $ */
/*
* Copyright (c) 1995, 1996, 1997, 2009 Matthew R. Green
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.151 2010/06/24 13:03:20 hannken Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_swap.c,v 1.152 2010/07/09 08:13:33 hannken Exp $");
#include "opt_uvmhist.h"
#include "opt_compat_netbsd.h"
@ -552,7 +552,9 @@ sys_swapctl(struct lwp *l, const struct sys_swapctl_args *uap, register_t *retva
*/
if (SCARG(uap, arg) == NULL) {
vp = rootvp; /* miniroot */
if (vget(vp, LK_EXCLUSIVE)) {
vref(vp);
if (vn_lock(vp, LK_EXCLUSIVE)) {
vrele(vp);
error = EBUSY;
goto out;
}