Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Remove the special refcount behavior (adding an extra re...
details: https://anonhg.NetBSD.org/src/rev/c699f95fba03
branches: trunk
changeset: 760277:c699f95fba03
user: dholland <dholland%NetBSD.org@localhost>
date: Sun Jan 02 05:09:30 2011 +0000
description:
Remove the special refcount behavior (adding an extra reference to the
parent dir) associated with SAVESTART in relookup().
Check all call sites to make sure that SAVESTART wasn't set while
calling relookup(); if it was, adjust the refcount behavior. Remove
related references to SAVESTART.
The only code that was reaching the extra ref was msdosfs_rename,
where the refcount behavior was already fairly broken and/or gross;
repair it.
Add a dummy 4th argument to relookup to make sure code that hasn't
been inspected won't compile. (This will go away next time the
relookup semantics change, which they will.)
diffstat:
sys/fs/msdosfs/msdosfs_vnops.c | 38 ++++++++++----------------------------
sys/fs/udf/udf_vnops.c | 7 +++----
sys/fs/union/union_subr.c | 8 ++++----
sys/fs/union/union_vnops.c | 6 +++---
sys/fs/unionfs/unionfs_subr.c | 8 +++-----
sys/kern/vfs_lookup.c | 10 +++++-----
sys/kern/vfs_syscalls.c | 13 +++----------
sys/nfs/nfs_serv.c | 10 +++-------
sys/sys/namei.src | 4 ++--
sys/ufs/ext2fs/ext2fs_vnops.c | 15 +++++++--------
sys/ufs/lfs/lfs_vnops.c | 8 ++++----
sys/ufs/ufs/ufs_vnops.c | 15 +++++++--------
sys/ufs/ufs/ufs_wapbl.c | 15 +++++++--------
13 files changed, 61 insertions(+), 96 deletions(-)
diffs (truncated from 580 to 300 lines):
diff -r 98910335eec2 -r c699f95fba03 sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.70 2010/11/30 10:43:03 dholland Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.71 2011/01/02 05:09:30 dholland Exp $ */
/*-
* Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.70 2010/11/30 10:43:03 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.71 2011/01/02 05:09:30 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -829,7 +829,6 @@
struct msdosfsmount *pmp;
struct direntry *dotdotp;
struct buf *bp;
- int fdvp_dorele = 0;
pmp = VFSTOMSDOSFS(fdvp->v_mount);
@@ -922,16 +921,6 @@
if (VTODE(fdvp)->de_StartCluster != VTODE(tdvp)->de_StartCluster)
newparent = 1;
- /*
- * XXX: We can do this here because rename uses SAVEFART and
- * therefore fdvp has at least two references (one doesn't
- * belong to us, though, and that's evil). We'll get
- * another "extra" reference when we do relookup(), so we
- * need to compensate. We should *NOT* be doing this, but
- * it works, so whatever.
- */
- vrele(fdvp);
-
if (doingdirectory && newparent) {
if (error) /* write access check above */
goto tdvpbad;
@@ -939,22 +928,19 @@
vput(tvp);
tvp = NULL;
/*
- * doscheckpath() vput()'s dp,
- * so we have to do a relookup afterwards
+ * doscheckpath() vput()'s tdvp (dp == VTODE(tdvp)),
+ * so we have to get an extra ref to it first, and
+ * because it's been unlocked we need to do a relookup
+ * afterwards in case tvp has changed.
*/
+ vref(tdvp);
if ((error = doscheckpath(ip, dp)) != 0)
goto out;
- if ((tcnp->cn_flags & SAVESTART) == 0)
- panic("msdosfs_rename: lost to startdir");
vn_lock(tdvp, LK_EXCLUSIVE | LK_RETRY);
- if ((error = relookup(tdvp, &tvp, tcnp)) != 0) {
+ if ((error = relookup(tdvp, &tvp, tcnp, 0)) != 0) {
VOP_UNLOCK(tdvp);
goto out;
}
- /*
- * XXX: SAVESTART causes us to get a reference, but
- * that's released already above in doscheckpath()
- */
dp = VTODE(tdvp);
xp = tvp ? VTODE(tvp) : NULL;
}
@@ -1004,11 +990,9 @@
*/
fcnp->cn_flags &= ~MODMASK;
fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
- if ((fcnp->cn_flags & SAVESTART) == 0)
- panic("msdosfs_rename: lost from startdir");
VOP_UNLOCK(tdvp);
vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
- if ((error = relookup(fdvp, &fvp, fcnp))) {
+ if ((error = relookup(fdvp, &fvp, fcnp, 0))) {
VOP_UNLOCK(fdvp);
vrele(ap->a_fvp);
vrele(tdvp);
@@ -1027,7 +1011,6 @@
fstrans_done(fdvp->v_mount);
return 0;
}
- fdvp_dorele = 1;
VOP_UNLOCK(fdvp);
xp = VTODE(fvp);
zp = VTODE(fdvp);
@@ -1133,8 +1116,7 @@
vrele(tdvp);
out:
ip->de_flag &= ~DE_RENAME;
- if (fdvp_dorele)
- vrele(fdvp);
+ vrele(fdvp);
vrele(fvp);
fstrans_done(fdvp->v_mount);
return (error);
diff -r 98910335eec2 -r c699f95fba03 sys/fs/udf/udf_vnops.c
--- a/sys/fs/udf/udf_vnops.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/fs/udf/udf_vnops.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: udf_vnops.c,v 1.61 2010/11/30 10:43:04 dholland Exp $ */
+/* $NetBSD: udf_vnops.c,v 1.62 2011/01/02 05:09:30 dholland Exp $ */
/*
* Copyright (c) 2006, 2008 Reinoud Zandijk
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.61 2010/11/30 10:43:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: udf_vnops.c,v 1.62 2011/01/02 05:09:30 dholland Exp $");
#endif /* not lint */
@@ -2042,8 +2042,7 @@
* re-lookup tvp since the parent has been unlocked, so could
* have changed/removed in the meantime.
*/
- tcnp->cn_flags &= ~SAVESTART;
- error = relookup(tdvp, &tvp, tcnp);
+ error = relookup(tdvp, &tvp, tcnp, 0);
if (error) {
vput(tdvp);
goto out;
diff -r 98910335eec2 -r c699f95fba03 sys/fs/union/union_subr.c
--- a/sys/fs/union/union_subr.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/fs/union/union_subr.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union_subr.c,v 1.41 2010/11/30 10:43:04 dholland Exp $ */
+/* $NetBSD: union_subr.c,v 1.42 2011/01/02 05:09:31 dholland Exp $ */
/*
* Copyright (c) 1994
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.41 2010/11/30 10:43:04 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_subr.c,v 1.42 2011/01/02 05:09:31 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -815,7 +815,7 @@
cn->cn_hash = cnp->cn_hash;
cn->cn_consume = cnp->cn_consume;
- error = relookup(dvp, vpp, cn);
+ error = relookup(dvp, vpp, cn, 0);
if (error) {
PNBUF_PUT(pnbuf);
*pnbuf_ret = NULL;
@@ -972,7 +972,7 @@
cn.cn_consume = 0;
vn_lock(un->un_dirvp, LK_EXCLUSIVE | LK_RETRY);
- error = relookup(un->un_dirvp, &vp, &cn);
+ error = relookup(un->un_dirvp, &vp, &cn, 0);
if (error) {
PNBUF_PUT(pnbuf);
VOP_UNLOCK(un->un_dirvp);
diff -r 98910335eec2 -r c699f95fba03 sys/fs/union/union_vnops.c
--- a/sys/fs/union/union_vnops.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/fs/union/union_vnops.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: union_vnops.c,v 1.38 2010/07/02 07:56:46 hannken Exp $ */
+/* $NetBSD: union_vnops.c,v 1.39 2011/01/02 05:09:31 dholland Exp $ */
/*
* Copyright (c) 1992, 1993, 1994, 1995
@@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.38 2010/07/02 07:56:46 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: union_vnops.c,v 1.39 2011/01/02 05:09:31 dholland Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1228,7 +1228,7 @@
vp = NULLVP;
if (dun->un_uppervp == NULLVP)
panic("union: null upperdvp?");
- error = relookup(ap->a_dvp, &vp, ap->a_cnp);
+ error = relookup(ap->a_dvp, &vp, ap->a_cnp, 0);
if (error) {
VOP_UNLOCK(ap->a_vp);
return EROFS; /* ? */
diff -r 98910335eec2 -r c699f95fba03 sys/fs/unionfs/unionfs_subr.c
--- a/sys/fs/unionfs/unionfs_subr.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/fs/unionfs/unionfs_subr.c Sun Jan 02 05:09:30 2011 +0000
@@ -317,14 +317,12 @@
cn->cn_consume = cnp->cn_consume;
if (nameiop == DELETE)
- cn->cn_flags |= (cnp->cn_flags & (DOWHITEOUT | SAVESTART));
- else if (RENAME == nameiop)
- cn->cn_flags |= (cnp->cn_flags & SAVESTART);
+ cn->cn_flags |= (cnp->cn_flags & DOWHITEOUT);
vref(dvp);
VOP_UNLOCK(dvp);
- if ((error = relookup(dvp, vpp, cn))) {
+ if ((error = relookup(dvp, vpp, cn, 0))) {
PNBUF_PUT(pnbuf);
*pnbuf_ret = NULL;
vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
@@ -631,7 +629,7 @@
cn.cn_consume = 0;
vref(udvp);
- if ((error = relookup(udvp, &vp, &cn)) != 0)
+ if ((error = relookup(udvp, &vp, &cn, 0)) != 0)
goto unionfs_vn_create_on_upper_free_out2;
vrele(udvp);
diff -r 98910335eec2 -r c699f95fba03 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/kern/vfs_lookup.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_lookup.c,v 1.129 2011/01/02 05:04:58 dholland Exp $ */
+/* $NetBSD: vfs_lookup.c,v 1.130 2011/01/02 05:09:31 dholland Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.129 2011/01/02 05:04:58 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.130 2011/01/02 05:09:31 dholland Exp $");
#include "opt_magiclinks.h"
@@ -1463,7 +1463,7 @@
* *vpp is locked on exit unless it's NULL.
*/
int
-relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp)
+relookup(struct vnode *dvp, struct vnode **vpp, struct componentname *cnp, int dummy)
{
int rdonly; /* lookup read-only flag bit */
int error = 0;
@@ -1472,6 +1472,8 @@
const char *cp; /* DEBUG: check name ptr/len */
#endif /* DEBUG */
+ (void)dummy;
+
/*
* Setup: break out flag bits into variables.
*/
@@ -1544,8 +1546,6 @@
}
goto bad;
}
- if (cnp->cn_flags & SAVESTART)
- vref(dvp);
return (0);
bad:
diff -r 98910335eec2 -r c699f95fba03 sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c Sun Jan 02 05:09:27 2011 +0000
+++ b/sys/kern/vfs_syscalls.c Sun Jan 02 05:09:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_syscalls.c,v 1.411 2011/01/02 05:01:20 dholland Exp $ */
+/* $NetBSD: vfs_syscalls.c,v 1.412 2011/01/02 05:09:31 dholland Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.411 2011/01/02 05:01:20 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.412 2011/01/02 05:09:31 dholland Exp $");
#ifdef _KERNEL_OPT
#include "opt_fileassoc.h"
@@ -3438,7 +3438,6 @@
struct mount *fs;
struct lwp *l = curlwp;
struct proc *p;
- uint32_t saveflag;
int error;
error = pathbuf_maybe_copyin(from, seg, &frompb);
@@ -3482,9 +3481,6 @@
* order and do the lookups in the right places, but that's a
* major rototill.
*
- * Preserve the SAVESTART in cn_flags, because who knows what
- * might happen if we don't.
Home |
Main Index |
Thread Index |
Old Index