Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Make VOP_RECLAIM do the last unlock of the vnode.



details:   https://anonhg.NetBSD.org/src/rev/e454268d9c52
branches:  trunk
changeset: 353872:e454268d9c52
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri May 26 14:20:59 2017 +0000

description:
Make VOP_RECLAIM do the last unlock of the vnode.

VOP_RECLAIM naturally has exclusive access to the vnode, so having it
locked on entry is not strictly necessary -- but it means if there
are any final operations that must be done on the vnode, such as
ffs_update, requiring exclusive access to it, we can now kassert that
the vnode is locked in those operations.

We can't just have the caller release the last lock because some file
systems don't use genfs_lock, and require the vnode to remain valid
for VOP_UNLOCK to work, notably unionfs.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c |   3 ++-
 sys/coda/coda_vnops.c                                  |   8 +++++---
 sys/fs/adosfs/advnops.c                                |   8 +++++---
 sys/fs/cd9660/cd9660_node.c                            |   8 +++++---
 sys/fs/efs/efs_vnops.c                                 |   8 +++++---
 sys/fs/filecorefs/filecore_node.c                      |   8 +++++---
 sys/fs/hfs/hfs_vnops.c                                 |  10 ++++++----
 sys/fs/msdosfs/msdosfs_denode.c                        |   8 +++++---
 sys/fs/nilfs/nilfs_vnops.c                             |   8 +++++---
 sys/fs/ntfs/ntfs_vnops.c                               |   8 +++++---
 sys/fs/ptyfs/ptyfs_vnops.c                             |   8 +++++---
 sys/fs/puffs/puffs_vnops.c                             |   8 +++++---
 sys/fs/smbfs/smbfs_node.c                              |   8 +++++---
 sys/fs/sysvbfs/sysvbfs_vnops.c                         |   8 +++++---
 sys/fs/tmpfs/tmpfs_vnops.c                             |   9 ++++++---
 sys/fs/udf/udf_vnops.c                                 |   8 +++++---
 sys/fs/union/union_vnops.c                             |   8 +++++---
 sys/fs/unionfs/unionfs_vnops.c                         |   4 +++-
 sys/fs/v7fs/v7fs_vnops.c                               |   8 +++++---
 sys/kern/vfs_vnode.c                                   |   5 ++---
 sys/kern/vnode_if.src                                  |   7 ++++---
 sys/miscfs/fdesc/fdesc_vnops.c                         |   8 +++++---
 sys/miscfs/genfs/layer_vnops.c                         |   8 +++++---
 sys/miscfs/kernfs/kernfs_vnops.c                       |   8 +++++---
 sys/miscfs/procfs/procfs_vnops.c                       |   8 +++++---
 sys/miscfs/specfs/spec_vnops.c                         |  10 ++++++----
 sys/nfs/nfs_node.c                                     |   8 +++++---
 sys/rump/librump/rumpvfs/rumpfs.c                      |   8 +++++---
 sys/ufs/chfs/chfs_vnops.c                              |   6 ++++--
 sys/ufs/ext2fs/ext2fs_vnops.c                          |   8 +++++---
 sys/ufs/ffs/ffs_vnops.c                                |   8 +++++---
 sys/ufs/lfs/lfs_vnops.c                                |   8 +++++---
 sys/ufs/mfs/mfs_vnops.c                                |   8 +++++---
 33 files changed, 158 insertions(+), 96 deletions(-)

diffs (truncated from 1085 to 300 lines):

diff -r 2d5fa7bb9421 -r e454268d9c52 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Fri May 26 11:16:18 2017 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vnops.c    Fri May 26 14:20:59 2017 +0000
@@ -5537,7 +5537,7 @@
 static int
 zfs_netbsd_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
@@ -5546,6 +5546,7 @@
        int error;
 
        KASSERT(vp != NULL);
+       VOP_UNLOCK(vp);
        zp = VTOZ(vp);
        KASSERT(zp != NULL);
        zfsvfs = zp->z_zfsvfs;
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Fri May 26 11:16:18 2017 +0000
+++ b/sys/coda/coda_vnops.c     Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.c,v 1.105 2017/04/26 03:02:48 riastradh Exp $       */
+/*     $NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $       */
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.105 2017/04/26 03:02:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.106 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1632,12 +1632,14 @@
 coda_reclaim(void *v)
 {
 /* true args */
-    struct vop_reclaim_args *ap = v;
+    struct vop_reclaim_v2_args *ap = v;
     vnode_t *vp = ap->a_vp;
     struct cnode *cp = VTOC(vp);
 /* upcall decl */
 /* locals */
 
+    VOP_UNLOCK(vp);
+
 /*
  * Forced unmount/flush will let vnodes with non zero use be destroyed!
  */
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/adosfs/advnops.c
--- a/sys/fs/adosfs/advnops.c   Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/adosfs/advnops.c   Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advnops.c,v 1.49 2017/04/11 14:24:59 riastradh Exp $   */
+/*     $NetBSD: advnops.c,v 1.50 2017/05/26 14:21:00 riastradh Exp $   */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.49 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: advnops.c,v 1.50 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -866,12 +866,14 @@
 int
 adosfs_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
        } */ *sp = v;
        struct vnode *vp;
        struct anode *ap;
 
+       VOP_UNLOCK(sp->a_vp);
+
 #ifdef ADOSFS_DIAGNOSTIC
        printf("(reclaim 0)");
 #endif
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/cd9660/cd9660_node.c
--- a/sys/fs/cd9660/cd9660_node.c       Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/cd9660/cd9660_node.c       Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_node.c,v 1.36 2017/04/11 14:24:59 riastradh Exp $       */
+/*     $NetBSD: cd9660_node.c,v 1.37 2017/05/26 14:21:00 riastradh Exp $       */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.36 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_node.c,v 1.37 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -125,12 +125,14 @@
 int
 cd9660_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
                struct lwp *a_l;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
 
+       VOP_UNLOCK(vp);
+
        if (prtactive && vp->v_usecount > 1)
                vprint("cd9660_reclaim: pushing active", vp);
        /*
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/efs/efs_vnops.c
--- a/sys/fs/efs/efs_vnops.c    Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/efs/efs_vnops.c    Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efs_vnops.c,v 1.37 2017/04/11 14:24:59 riastradh Exp $ */
+/*     $NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $ */
 
 /*
  * Copyright (c) 2006 Stephen M. Rumble <rumble%ephemeral.org@localhost>
@@ -17,7 +17,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.37 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efs_vnops.c,v 1.38 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -575,13 +575,15 @@
 static int
 efs_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                const struct vnodeop_desc *a_desc;
                struct vnode *a_vp;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
        struct efs_inode *eip = EFS_VTOI(vp);
 
+       VOP_UNLOCK(vp);
+
        genfs_node_destroy(vp);
        pool_put(&efs_inode_pool, eip);
        vp->v_data = NULL;
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/filecorefs/filecore_node.c
--- a/sys/fs/filecorefs/filecore_node.c Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/filecorefs/filecore_node.c Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_node.c,v 1.29 2017/04/11 14:24:59 riastradh Exp $     */
+/*     $NetBSD: filecore_node.c,v 1.30 2017/05/26 14:21:00 riastradh Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1994
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filecore_node.c,v 1.29 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filecore_node.c,v 1.30 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -237,13 +237,15 @@
 int
 filecore_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
                struct lwp *a_l;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
        struct filecore_node *ip = VTOI(vp);
 
+       VOP_UNLOCK(vp);
+
        if (prtactive && vp->v_usecount > 1)
                vprint("filecore_reclaim: pushing active", vp);
 
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/hfs/hfs_vnops.c
--- a/sys/fs/hfs/hfs_vnops.c    Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/hfs/hfs_vnops.c    Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hfs_vnops.c,v 1.33 2016/08/20 12:37:07 hannken Exp $   */
+/*     $NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2005, 2007 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.33 2016/08/20 12:37:07 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hfs_vnops.c,v 1.34 2017/05/26 14:21:00 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ipsec.h"
@@ -1019,12 +1019,14 @@
 int
 hfs_vop_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
        } */ *ap = v;
        struct vnode *vp;
        struct hfsnode *hp;
-       
+
+       VOP_UNLOCK(ap->a_vp);
+
        DPRINTF(("VOP = hfs_vop_reclaim()\n"));
 
        vp = ap->a_vp;
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/msdosfs/msdosfs_denode.c
--- a/sys/fs/msdosfs/msdosfs_denode.c   Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/msdosfs/msdosfs_denode.c   Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_denode.c,v 1.54 2017/04/11 14:24:59 riastradh Exp $    */
+/*     $NetBSD: msdosfs_denode.c,v 1.55 2017/05/26 14:21:00 riastradh Exp $    */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.54 2017/04/11 14:24:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.55 2017/05/26 14:21:00 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -532,12 +532,14 @@
 int
 msdosfs_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
        struct denode *dep = VTODE(vp);
 
+       VOP_UNLOCK(vp);
+
 #ifdef MSDOSFS_DEBUG
        printf("msdosfs_reclaim(): dep %p, file %s, refcnt %ld\n",
            dep, dep->de_Name, dep->de_refcnt);
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/nilfs/nilfs_vnops.c
--- a/sys/fs/nilfs/nilfs_vnops.c        Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/nilfs/nilfs_vnops.c        Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nilfs_vnops.c,v 1.35 2017/04/26 03:02:48 riastradh Exp $ */
+/* $NetBSD: nilfs_vnops.c,v 1.36 2017/05/26 14:21:00 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.35 2017/04/26 03:02:48 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nilfs_vnops.c,v 1.36 2017/05/26 14:21:00 riastradh Exp $");
 #endif /* not lint */
 
 
@@ -99,12 +99,14 @@
 int
 nilfs_reclaim(void *v)
 {
-       struct vop_reclaim_args /* {
+       struct vop_reclaim_v2_args /* {
                struct vnode *a_vp;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
        struct nilfs_node *nilfs_node = VTOI(vp);
 
+       VOP_UNLOCK(vp);
+
        DPRINTF(NODE, ("nilfs_reclaim called for node %p\n", nilfs_node));
        if (prtactive && vp->v_usecount > 1)
                vprint("nilfs_reclaim(): pushing active", vp);
diff -r 2d5fa7bb9421 -r e454268d9c52 sys/fs/ntfs/ntfs_vnops.c
--- a/sys/fs/ntfs/ntfs_vnops.c  Fri May 26 11:16:18 2017 +0000
+++ b/sys/fs/ntfs/ntfs_vnops.c  Fri May 26 14:20:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vnops.c,v 1.61 2017/04/11 14:24:59 riastradh Exp $        */



Home | Main Index | Thread Index | Old Index