Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.
details: https://anonhg.NetBSD.org/src/rev/430758a0b58c
branches: trunk
changeset: 353247:430758a0b58c
user: riastradh <riastradh%NetBSD.org@localhost>
date: Wed Apr 26 03:02:47 2017 +0000
description:
Change VOP_REMOVE and VOP_RMDIR to preserve lock/ref on dvp.
No change to vp -- the plan is to replace the node by the
componentname in the vop parameters, and let all directory vops do
lookups internally.
Proposed on tech-kern with no objections:
https://mail-index.netbsd.org/tech-kern/2017/04/17/msg021825.html
diffstat:
external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c | 17 +----------
lib/libp2k/p2k.c | 7 +++-
sys/coda/coda_vnops.c | 14 ++++-----
sys/compat/svr4/svr4_stream.c | 5 ++-
sys/fs/msdosfs/msdosfs_vnops.c | 17 ++++-------
sys/fs/nilfs/nilfs_vnops.c | 16 ++++-------
sys/fs/puffs/puffs_vnops.c | 15 ++++++----
sys/fs/smbfs/smbfs_vnops.c | 13 +++-----
sys/fs/sysvbfs/sysvbfs_vnops.c | 11 ++++---
sys/fs/tmpfs/tmpfs_vnops.c | 19 ++++++-------
sys/fs/udf/udf_vnops.c | 16 ++++-------
sys/fs/union/union_vnops.c | 25 ++++-------------
sys/fs/unionfs/unionfs_vnops.c | 12 +++++--
sys/fs/v7fs/v7fs_vnops.c | 10 ++----
sys/kern/vfs_syscalls.c | 6 ++-
sys/kern/vnode_if.src | 12 +++++---
sys/miscfs/deadfs/dead_vnops.c | 10 ++----
sys/miscfs/genfs/layer_vnops.c | 10 +++---
sys/nfs/nfs_serv.c | 6 ++-
sys/nfs/nfs_vnops.c | 13 +++-----
sys/rump/librump/rumpvfs/rumpfs.c | 12 ++-----
sys/ufs/chfs/chfs_vnops.c | 16 +++++------
sys/ufs/ext2fs/ext2fs_vnops.c | 16 +++-------
sys/ufs/lfs/lfs_vnops.c | 14 ++++-----
sys/ufs/lfs/ulfs_vnops.c | 15 ++++------
sys/ufs/ufs/ufs_vnops.c | 15 ++++------
26 files changed, 144 insertions(+), 198 deletions(-)
diffs (truncated from 1421 to 300 lines):
diff -r 2b468434bf01 -r 430758a0b58c external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Wed Apr 26 01:51:52 2017 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c Wed Apr 26 03:02:47 2017 +0000
@@ -4975,7 +4975,7 @@
static int
zfs_netbsd_remove(void *v)
{
- struct vop_remove_args /* {
+ struct vop_remove_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -5002,13 +5002,6 @@
0);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
-
- /*
- * Unlock and release dvp because the VOP_REMOVE protocol is insane.
- */
- VOP_UNLOCK(dvp);
- VN_RELE(dvp);
-
return (error);
}
@@ -5048,7 +5041,7 @@
static int
zfs_netbsd_rmdir(void *v)
{
- struct vop_rmdir_args /* {
+ struct vop_rmdir_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -5075,12 +5068,6 @@
NULL, 0);
KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
-
- /*
- * Unlock and release dvp because the VOP_RMDIR protocol is insane.
- */
- VOP_UNLOCK(dvp);
- VN_RELE(dvp);
return error;
}
diff -r 2b468434bf01 -r 430758a0b58c lib/libp2k/p2k.c
--- a/lib/libp2k/p2k.c Wed Apr 26 01:51:52 2017 +0000
+++ b/lib/libp2k/p2k.c Wed Apr 26 03:02:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: p2k.c,v 1.69 2017/04/11 14:25:02 riastradh Exp $ */
+/* $NetBSD: p2k.c,v 1.70 2017/04/26 03:02:48 riastradh Exp $ */
/*
* Copyright (c) 2007, 2008, 2009 Antti Kantee. All Rights Reserved.
@@ -1026,8 +1026,11 @@
RUMP_VOP_LOCK(vp, LK_EXCLUSIVE);
rump_pub_vp_incref(vp);
rv = nukefn(dvp, vp, cn);
- assert(RUMP_VOP_ISLOCKED(dvp) == 0);
+ assert(dvp != vp);
+ assert(RUMP_VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
assert(RUMP_VOP_ISLOCKED(vp) == 0);
+ rump_pub_vp_rele(dvp);
+ RUMP_VOP_UNLOCK(dvp);
freecn(cn);
return rv;
diff -r 2b468434bf01 -r 430758a0b58c sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c Wed Apr 26 01:51:52 2017 +0000
+++ b/sys/coda/coda_vnops.c Wed Apr 26 03:02:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: coda_vnops.c,v 1.104 2017/04/11 14:24:59 riastradh Exp $ */
+/* $NetBSD: coda_vnops.c,v 1.105 2017/04/26 03:02:48 riastradh Exp $ */
/*
*
@@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.104 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.105 2017/04/26 03:02:48 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1071,7 +1071,7 @@
coda_remove(void *v)
{
/* true args */
- struct vop_remove_args *ap = v;
+ struct vop_remove_v2_args *ap = v;
vnode_t *dvp = ap->a_dvp;
struct cnode *cp = VTOC(dvp);
vnode_t *vp = ap->a_vp;
@@ -1124,14 +1124,13 @@
CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); )
/*
- * Unlock parent and child (avoiding double if ".").
+ * Unlock and release child (avoiding double if ".").
*/
if (dvp == vp) {
vrele(vp);
} else {
vput(vp);
}
- vput(dvp);
return(error);
}
@@ -1377,7 +1376,7 @@
coda_rmdir(void *v)
{
/* true args */
- struct vop_rmdir_args *ap = v;
+ struct vop_rmdir_v2_args *ap = v;
vnode_t *dvp = ap->a_dvp;
struct cnode *dcp = VTOC(dvp);
vnode_t *vp = ap->a_vp;
@@ -1429,8 +1428,7 @@
CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); )
exit:
- /* vput both vnodes */
- vput(dvp);
+ /* unlock and release child */
if (dvp == vp) {
vrele(vp);
} else {
diff -r 2b468434bf01 -r 430758a0b58c sys/compat/svr4/svr4_stream.c
--- a/sys/compat/svr4/svr4_stream.c Wed Apr 26 01:51:52 2017 +0000
+++ b/sys/compat/svr4/svr4_stream.c Wed Apr 26 03:02:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: svr4_stream.c,v 1.87 2016/09/13 07:01:08 martin Exp $ */
+/* $NetBSD: svr4_stream.c,v 1.88 2017/04/26 03:02:48 riastradh Exp $ */
/*-
* Copyright (c) 1994, 2008 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.87 2016/09/13 07:01:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: svr4_stream.c,v 1.88 2017/04/26 03:02:48 riastradh Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -328,6 +328,7 @@
goto bad;
error = VOP_REMOVE(nd.ni_dvp, nd.ni_vp, &nd.ni_cnd);
+ vput(nd.ni_dvp);
pathbuf_destroy(pb);
return error;
diff -r 2b468434bf01 -r 430758a0b58c sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c Wed Apr 26 01:51:52 2017 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c Wed Apr 26 03:02:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msdosfs_vnops.c,v 1.97 2017/03/01 10:41:28 hannken Exp $ */
+/* $NetBSD: msdosfs_vnops.c,v 1.98 2017/04/26 03:02:48 riastradh 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.97 2017/03/01 10:41:28 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.98 2017/04/26 03:02:48 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -715,7 +715,7 @@
int
msdosfs_remove(void *v)
{
- struct vop_remove_args /* {
+ struct vop_remove_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -739,7 +739,7 @@
else
vput(ap->a_vp); /* causes msdosfs_inactive() to be called
* via vrele() */
- vput(ap->a_dvp);
+
return (error);
}
@@ -1266,7 +1266,7 @@
int
msdosfs_rmdir(void *v)
{
- struct vop_rmdir_args /* {
+ struct vop_rmdir_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -1283,8 +1283,7 @@
* No rmdir "." please.
*/
if (dp == ip) {
- vrele(dvp);
- vput(vp);
+ vrele(vp);
return (EINVAL);
}
/*
@@ -1316,8 +1315,6 @@
*/
VN_KNOTE(dvp, NOTE_WRITE | NOTE_LINK);
cache_purge(dvp);
- vput(dvp);
- dvp = NULL;
/*
* Truncate the directory that is being deleted.
*/
@@ -1325,8 +1322,6 @@
cache_purge(vp);
out:
VN_KNOTE(vp, NOTE_DELETE);
- if (dvp)
- vput(dvp);
vput(vp);
return (error);
}
diff -r 2b468434bf01 -r 430758a0b58c sys/fs/nilfs/nilfs_vnops.c
--- a/sys/fs/nilfs/nilfs_vnops.c Wed Apr 26 01:51:52 2017 +0000
+++ b/sys/fs/nilfs/nilfs_vnops.c Wed Apr 26 03:02:47 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.34 2017/04/11 14:24:59 riastradh Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.35 2017/04/26 03:02:48 riastradh Exp $ */
/*
* Copyright (c) 2008, 2009 Reinoud Zandijk
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.34 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.35 2017/04/26 03:02:48 riastradh Exp $");
#endif /* not lint */
@@ -1404,7 +1404,7 @@
int
nilfs_remove(void *v)
{
- struct vop_remove_args /* {
+ struct vop_remove_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -1435,7 +1435,6 @@
vrele(vp);
else
vput(vp);
- vput(dvp);
return error;
}
@@ -1445,7 +1444,7 @@
int
nilfs_rmdir(void *v)
{
- struct vop_rmdir_args /* {
+ struct vop_rmdir_v2_args /* {
struct vnode *a_dvp;
struct vnode *a_vp;
struct componentname *a_cnp;
@@ -1462,8 +1461,7 @@
/* don't allow '.' to be deleted */
if (dir_node == nilfs_node) {
- vrele(dvp);
- vput(vp);
+ vrele(vp);
return EINVAL;
}
@@ -1472,7 +1470,6 @@
refcnt = 2; /* XXX */
if (refcnt > 1) {
/* NOT empty */
- vput(dvp);
vput(vp);
return ENOTEMPTY;
}
@@ -1486,8 +1483,7 @@
}
DPRINTFIF(NODE, error, ("\tgot error removing file\n"));
- /* unput the nodes and exit */
- vput(dvp);
+ /* put the node and exit */
Home |
Main Index |
Thread Index |
Old Index