Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs/ufs Replace most uses of vp->v_usecount with a call ...



details:   https://anonhg.NetBSD.org/src/rev/3b07924a0e8a
branches:  trunk
changeset: 971104:3b07924a0e8a
user:      ad <ad%NetBSD.org@localhost>
date:      Mon Apr 13 19:23:17 2020 +0000

description:
Replace most uses of vp->v_usecount with a call to vrefcnt(vp), a function
that hides the details and does atomic_load_relaxed().  Signature matches
FreeBSD.

diffstat:

 external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c |   2 +-
 external/cddl/osnet/sys/sys/vnode.h                     |   7 +-
 sys/coda/coda_namecache.c                               |  12 +-
 sys/coda/coda_subr.c                                    |  18 ++--
 sys/coda/coda_vnops.c                                   |  16 ++--
 sys/fs/msdosfs/msdosfs_denode.c                         |   8 +-
 sys/fs/msdosfs/msdosfs_vfsops.c                         |   6 +-
 sys/fs/msdosfs/msdosfs_vnops.c                          |  10 +-
 sys/fs/nilfs/nilfs_vnops.c                              |   8 +-
 sys/fs/ntfs/ntfs_vfsops.c                               |   6 +-
 sys/fs/ptyfs/ptyfs_vnops.c                              |   6 +-
 sys/fs/udf/udf_vfsops.c                                 |   8 +-
 sys/fs/udf/udf_vnops.c                                  |   8 +-
 sys/fs/v7fs/v7fs_vnops.c                                |  10 +-
 sys/kern/exec_subr.c                                    |   6 +-
 sys/kern/vfs_cache.c                                    |   6 +-
 sys/kern/vfs_getcwd.c                                   |   6 +-
 sys/kern/vfs_mount.c                                    |  10 +-
 sys/kern/vfs_subr.c                                     |   6 +-
 sys/kern/vfs_vnode.c                                    |  60 ++++++++++------
 sys/kern/vfs_vnops.c                                    |   6 +-
 sys/miscfs/fdesc/fdesc_vfsops.c                         |   6 +-
 sys/miscfs/genfs/layer_subr.c                           |  12 +-
 sys/miscfs/genfs/layer_vnops.c                          |   6 +-
 sys/miscfs/nullfs/null_vfsops.c                         |   6 +-
 sys/miscfs/overlay/overlay_vfsops.c                     |   6 +-
 sys/miscfs/umapfs/umap_vfsops.c                         |   6 +-
 sys/nfs/nfs_vfsops.c                                    |   6 +-
 sys/nfs/nfs_vnops.c                                     |  18 ++--
 sys/rump/librump/rumpvfs/rump_vfs.c                     |   6 +-
 sys/rump/librump/rumpvfs/rumpfs.c                       |   6 +-
 sys/sys/vnode.h                                         |   5 +-
 sys/ufs/lfs/lfs_vnops.c                                 |  10 +-
 sys/ufs/mfs/mfs_vnops.c                                 |   6 +-
 sys/ufs/ufs/ufs_vnops.c                                 |  10 +-
 35 files changed, 173 insertions(+), 161 deletions(-)

diffs (truncated from 1374 to 300 lines):

diff -r 8b6d4cf1c29d -r 3b07924a0e8a external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c
--- a/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c   Mon Apr 13 16:29:59 2020 +0000
+++ b/external/cddl/osnet/dist/uts/common/fs/zfs/zfs_vfsops.c   Mon Apr 13 19:23:17 2020 +0000
@@ -1994,7 +1994,7 @@
        mutex_enter(mvp->v_interlock);
        if ((uap->flags & MS_REMOUNT) == 0 &&
            (uap->flags & MS_OVERLAY) == 0 &&
-           (mvp->v_count != 1 || (mvp->v_flag & VROOT))) {
+           (vrefcnt(mvp) != 1 || (mvp->v_flag & VROOT))) {
                mutex_exit(mvp->v_interlock);
                return (SET_ERROR(EBUSY));
        }
diff -r 8b6d4cf1c29d -r 3b07924a0e8a external/cddl/osnet/sys/sys/vnode.h
--- a/external/cddl/osnet/sys/sys/vnode.h       Mon Apr 13 16:29:59 2020 +0000
+++ b/external/cddl/osnet/sys/sys/vnode.h       Mon Apr 13 19:23:17 2020 +0000
@@ -1,5 +1,4 @@
-
-/*     $NetBSD: vnode.h,v 1.15 2019/01/12 10:44:36 hannken Exp $       */
+/*     $NetBSD: vnode.h,v 1.16 2020/04/13 19:23:17 ad Exp $    */
 
 /*
  * CDDL HEADER START
@@ -156,7 +155,7 @@
 #define        vn_vfsunlock(vp)        do { } while (0)
 #define        vn_ismntpt(vp)          ((vp)->v_type == VDIR && (vp)->v_mountedhere != NULL)
 #define        vn_mountedvfs(vp)       ((vp)->v_mountedhere)
-#define vn_has_cached_data(vp) ((vp)->v_uobj.uo_npages != 0)
+#define vn_has_cached_data(vp) (((vp)->v_iflag & VI_PAGES) != 0)
 #define        vn_exists(vp)           do { } while (0)
 #define        vn_invalid(vp)          do { } while (0)
 #define        vn_free(vp)             do { } while (0)
@@ -166,7 +165,7 @@
 #define        VN_HOLD(v)      vref(v)
 #define        VN_RELE(v)                                                    \
 do {                                                                 \
-       if ((v)->v_usecount == 0) {                                   \
+       if (vrefcnt(v) == 0) {                                        \
                printf("VN_RELE(%s,%d): %p unused\n", __FILE__, __LINE__, v); \
                vprint("VN_RELE", (v));                               \
                panic("VN_RELE");                                     \
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/coda/coda_namecache.c
--- a/sys/coda/coda_namecache.c Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/coda/coda_namecache.c Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_namecache.c,v 1.26 2014/10/18 08:33:27 snj Exp $  */
+/*     $NetBSD: coda_namecache.c,v 1.27 2020/04/13 19:23:17 ad Exp $   */
 
 /*
  *
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_namecache.c,v 1.26 2014/10/18 08:33:27 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_namecache.c,v 1.27 2020/04/13 19:23:17 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -348,12 +348,12 @@
        LIST_REMOVE(cncp, hash);
        memset(&cncp->hash, 0, sizeof(cncp->hash));
 
-       if ((dcstat == IS_DOWNCALL) && (CTOV(cncp->dcp)->v_usecount == 1)) {
+       if ((dcstat == IS_DOWNCALL) && (vrefcnt(CTOV(cncp->dcp)) == 1)) {
                cncp->dcp->c_flags |= C_PURGING;
        }
        vrele(CTOV(cncp->dcp));
 
-       if ((dcstat == IS_DOWNCALL) && (CTOV(cncp->cp)->v_usecount == 1)) {
+       if ((dcstat == IS_DOWNCALL) && (vrefcnt(CTOV(cncp->cp)) == 1)) {
                cncp->cp->c_flags |= C_PURGING;
        }
        vrele(CTOV(cncp->cp));
@@ -570,7 +570,7 @@
                        memset(&cncp->hash, 0, sizeof(cncp->hash));
 
                        if ((dcstat == IS_DOWNCALL)
-                           && (CTOV(cncp->dcp)->v_usecount == 1))
+                           && (vrefcnt(CTOV(cncp->dcp)) == 1))
                        {
                                cncp->dcp->c_flags |= C_PURGING;
                        }
@@ -584,7 +584,7 @@
                        }
 
                        if ((dcstat == IS_DOWNCALL)
-                           && (CTOV(cncp->cp)->v_usecount == 1))
+                           && (vrefcnt(CTOV(cncp->cp)) == 1))
                        {
                                cncp->cp->c_flags |= C_PURGING;
                        }
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/coda/coda_subr.c
--- a/sys/coda/coda_subr.c      Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/coda/coda_subr.c      Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_subr.c,v 1.31 2015/01/06 11:24:46 hannken Exp $   */
+/*     $NetBSD: coda_subr.c,v 1.32 2020/04/13 19:23:17 ad Exp $        */
 
 /*
  *
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_subr.c,v 1.31 2015/01/06 11:24:46 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_subr.c,v 1.32 2020/04/13 19:23:17 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -220,7 +220,7 @@
 
        if (cp != NULL)
                myprintf(("Live cnode fid %s count %d\n",
-                    coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount));
+                    coda_f2s(&cp->c_fid), vrefcnt(CTOV(cp))));
 
        return false;
 }
@@ -370,8 +370,8 @@
                  error = coda_vmflush(cp);
              CODADEBUG(CODA_ZAPFILE, myprintf((
                    "zapfile: fid = %s, refcnt = %d, error = %d\n",
-                   coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount - 1, error)););
-             if (CTOV(cp)->v_usecount == 1) {
+                   coda_f2s(&cp->c_fid), vrefcnt(CTOV(cp)) - 1, error)););
+             if (vrefcnt(CTOV(cp)) == 1) {
                  cp->c_flags |= C_PURGING;
              }
              mutex_exit(&cp->c_lock);
@@ -394,8 +394,8 @@
 
              CODADEBUG(CODA_ZAPDIR, myprintf((
                    "zapdir: fid = %s, refcnt = %d\n",
-                   coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount - 1)););
-             if (CTOV(cp)->v_usecount == 1) {
+                   coda_f2s(&cp->c_fid), vrefcnt(CTOV(cp)) - 1)););
+             if (vrefcnt(CTOV(cp)) == 1) {
                  cp->c_flags |= C_PURGING;
              }
              mutex_exit(&cp->c_lock);
@@ -427,8 +427,8 @@
              }
              CODADEBUG(CODA_PURGEFID, myprintf((
                         "purgefid: fid = %s, refcnt = %d, error = %d\n",
-                        coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount - 1, error)););
-             if (CTOV(cp)->v_usecount == 1) {
+                        coda_f2s(&cp->c_fid), vrefcnt(CTOV(cp)) - 1, error)););
+             if (vrefcnt(CTOV(cp)) == 1) {
                  cp->c_flags |= C_PURGING;
              }
              mutex_exit(&cp->c_lock);
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/coda/coda_vnops.c
--- a/sys/coda/coda_vnops.c     Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/coda/coda_vnops.c     Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vnops.c,v 1.110 2020/02/24 20:53:11 ad Exp $      */
+/*     $NetBSD: coda_vnops.c,v 1.111 2020/04/13 19:23:17 ad Exp $      */
 
 /*
  *
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.110 2020/02/24 20:53:11 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: coda_vnops.c,v 1.111 2020/04/13 19:23:17 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -329,7 +329,7 @@
        if (cp->c_ovp) {
 #ifdef CODA_VERBOSE
            printf("%s: destroying container %d, ufs vp %p of vp %p/cp %p\n",
-               __func__, vp->v_usecount, cp->c_ovp, vp, cp);
+               __func__, vrefcnt(vp), cp->c_ovp, vp, cp);
 #endif
 #ifdef hmm
            vgone(cp->c_ovp);
@@ -465,7 +465,7 @@
 
     /* Have UFS handle the call. */
     CODADEBUG(CODA_RDWR, myprintf(("%s: fid = %s, refcnt = %d\n", __func__,
-       coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount)); )
+       coda_f2s(&cp->c_fid), vrefcnt(CTOV(cp)))); )
 
     if (rw == UIO_READ) {
        error = VOP_READ(cfvp, uiop, ioflag, cred);
@@ -850,8 +850,8 @@
 
 #ifdef CODA_VERBOSE
     /* Sanity checks that perhaps should be panic. */
-    if (vp->v_usecount > 1)
-       printf("%s: %p usecount %d\n", __func__, vp, vp->v_usecount);
+    if (vrefcnt(vp) > 1)
+       printf("%s: %p usecount %d\n", __func__, vp, vrefcnt(vp));
     if (cp->c_ovp != NULL)
        printf("%s: %p ovp != NULL\n", __func__, vp);
 #endif
@@ -1569,7 +1569,7 @@
 
        /* Have UFS handle the call. */
        CODADEBUG(CODA_READDIR, myprintf(("%s: fid = %s, refcnt = %d\n",
-           __func__, coda_f2s(&cp->c_fid), vp->v_usecount)); )
+           __func__, coda_f2s(&cp->c_fid), vrefcnt(vp))); )
        saved_type = vp->v_type;
        vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
        vp->v_type = VDIR; /* pretend the container file is a dir */
@@ -1661,7 +1661,7 @@
 #endif
     } else {
 #ifdef OLD_DIAGNOSTIC
-       if (vp->v_usecount != 0)
+       if (vrefcnt(vp) != 0)
            print("%s: pushing active %p\n", __func__, vp);
        if (VTOC(vp)->c_ovp) {
            panic("%s: c_ovp not void", __func__);
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/fs/msdosfs/msdosfs_denode.c
--- a/sys/fs/msdosfs/msdosfs_denode.c   Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/fs/msdosfs/msdosfs_denode.c   Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_denode.c,v 1.57 2018/05/28 21:04:37 chs Exp $  */
+/*     $NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad 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.57 2018/05/28 21:04:37 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_denode.c,v 1.58 2020/04/13 19:23:17 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -611,8 +611,8 @@
         * so that it can be reused immediately.
         */
 #ifdef MSDOSFS_DEBUG
-       printf("msdosfs_inactive(): v_usecount %d, de_Name[0] %x\n",
-               vp->v_usecount, dep->de_Name[0]);
+       printf("msdosfs_inactive(): usecount %d, de_Name[0] %x\n",
+               vrefcnt(vp), dep->de_Name[0]);
 #endif
        *ap->a_recycle = (dep->de_Name[0] == SLOT_DELETED);
 
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c   Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c   Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.134 2020/04/04 20:49:30 ad Exp $  */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $  */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.134 2020/04/04 20:49:30 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.135 2020/04/13 19:23:17 ad Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -926,7 +926,7 @@
 
                printf("msdosfs_umount(): just before calling VOP_CLOSE()\n");
                printf("flag %08x, usecount %d, writecount %d, holdcnt %d\n",
-                   vp->v_vflag | vp->v_iflag | vp->v_uflag, vp->v_usecount,
+                   vp->v_vflag | vp->v_iflag | vp->v_uflag, vrefcnt(vp),
                    vp->v_writecount, vp->v_holdcnt);
                printf("mount %p, op %p\n",
                    vp->v_mount, vp->v_op);
diff -r 8b6d4cf1c29d -r 3b07924a0e8a sys/fs/msdosfs/msdosfs_vnops.c
--- a/sys/fs/msdosfs/msdosfs_vnops.c    Mon Apr 13 16:29:59 2020 +0000
+++ b/sys/fs/msdosfs/msdosfs_vnops.c    Mon Apr 13 19:23:17 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vnops.c,v 1.100 2020/02/23 15:46:40 ad Exp $   */
+/*     $NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad 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.100 2020/02/23 15:46:40 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.101 2020/04/13 19:23:17 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -173,7 +173,7 @@
        struct denode *dep = VTODE(vp);
 
        mutex_enter(vp->v_interlock);
-       if (vp->v_usecount > 1)
+       if (vrefcnt(vp) > 1)
                DETIMES(dep, NULL, NULL, NULL, dep->de_pmp->pm_gmtoff);
        mutex_exit(vp->v_interlock);
        return (0);
@@ -731,8 +731,8 @@



Home | Main Index | Thread Index | Old Index