Source-Changes-HG archive

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

[src/trunk]: src/sys Add vfs_ref(mp) and vfs_rele(mp) to add or remove a refe...



details:   https://anonhg.NetBSD.org/src/rev/baa7c30f6092
branches:  trunk
changeset: 823255:baa7c30f6092
user:      hannken <hannken%NetBSD.org@localhost>
date:      Mon Apr 17 08:31:01 2017 +0000

description:
Add vfs_ref(mp) and vfs_rele(mp) to add or remove a reference to
struct mount.  Rename vfs_destroy(mp) to vfs_rele(mp) and replace
incrementing mp->mnt_refcnt with vfs_ref(mp).

diffstat:

 sys/fs/cd9660/cd9660_vfsops.c       |   6 ++--
 sys/fs/filecorefs/filecore_vfsops.c |   6 ++--
 sys/fs/msdosfs/msdosfs_vfsops.c     |   8 +++---
 sys/fs/ntfs/ntfs_vfsops.c           |   6 ++--
 sys/fs/puffs/puffs_msgif.c          |  12 ++++----
 sys/fs/v7fs/v7fs_vfsops.c           |   6 ++--
 sys/kern/vfs_mount.c                |  46 +++++++++++++++++++++++-------------
 sys/kern/vfs_syscalls.c             |  14 +++++-----
 sys/kern/vfs_trans.c                |   6 ++--
 sys/kern/vfs_vnode.c                |   6 ++--
 sys/nfs/nfs_vfsops.c                |   6 ++--
 sys/sys/mount.h                     |   5 ++-
 sys/ufs/ext2fs/ext2fs_vfsops.c      |   6 ++--
 sys/ufs/ffs/ffs_vfsops.c            |   6 ++--
 sys/ufs/lfs/lfs_vfsops.c            |   6 ++--
 sys/ufs/mfs/mfs_vfsops.c            |   6 ++--
 16 files changed, 82 insertions(+), 69 deletions(-)

diffs (truncated from 618 to 300 lines):

diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/cd9660/cd9660_vfsops.c
--- a/sys/fs/cd9660/cd9660_vfsops.c     Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/cd9660/cd9660_vfsops.c     Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_vfsops.c,v 1.91 2017/02/17 08:31:24 hannken Exp $       */
+/*     $NetBSD: cd9660_vfsops.c,v 1.92 2017/04/17 08:31:01 hannken Exp $       */
 
 /*-
  * Copyright (c) 1994
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.91 2017/02/17 08:31:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd9660_vfsops.c,v 1.92 2017/04/17 08:31:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -192,7 +192,7 @@
        args.flags = ISOFSMNT_ROOT;
        if ((error = iso_mountfs(rootvp, mp, l, &args)) != 0) {
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return (error);
        }
        mountlist_append(mp);
diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/filecorefs/filecore_vfsops.c
--- a/sys/fs/filecorefs/filecore_vfsops.c       Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/filecorefs/filecore_vfsops.c       Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_vfsops.c,v 1.79 2017/02/17 08:31:24 hannken Exp $     */
+/*     $NetBSD: filecore_vfsops.c,v 1.80 2017/04/17 08:31:01 hannken Exp $     */
 
 /*-
  * Copyright (c) 1994 The Regents of the University of California.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.79 2017/02/17 08:31:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filecore_vfsops.c,v 1.80 2017/04/17 08:31:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -202,7 +202,7 @@
        args.flags = FILECOREMNT_ROOT;
        if ((error = filecore_mountfs(rootvp, mp, p, &args)) != 0) {
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return (error);
        }
        mountlist_append(mp);
diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/msdosfs/msdosfs_vfsops.c
--- a/sys/fs/msdosfs/msdosfs_vfsops.c   Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/msdosfs/msdosfs_vfsops.c   Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vfsops.c,v 1.125 2017/04/01 19:35:56 riastradh Exp $   */
+/*     $NetBSD: msdosfs_vfsops.c,v 1.126 2017/04/17 08:31:01 hannken 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.125 2017/04/01 19:35:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.126 2017/04/17 08:31:01 hannken Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -248,14 +248,14 @@
 
        if ((error = msdosfs_mountfs(rootvp, mp, l, &args)) != 0) {
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return (error);
        }
 
        if ((error = update_mp(mp, &args)) != 0) {
                (void)msdosfs_unmount(mp, 0);
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                vrele(rootvp);
                return (error);
        }
diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/ntfs/ntfs_vfsops.c
--- a/sys/fs/ntfs/ntfs_vfsops.c Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/ntfs/ntfs_vfsops.c Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ntfs_vfsops.c,v 1.105 2017/02/17 08:31:24 hannken Exp $        */
+/*     $NetBSD: ntfs_vfsops.c,v 1.106 2017/04/17 08:31:01 hannken Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999 Semen Ustimenko
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.105 2017/02/17 08:31:24 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ntfs_vfsops.c,v 1.106 2017/04/17 08:31:01 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,7 +116,7 @@
 
        if ((error = ntfs_mountfs(rootvp, mp, &args, l)) != 0) {
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return (error);
        }
 
diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/puffs/puffs_msgif.c
--- a/sys/fs/puffs/puffs_msgif.c        Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/puffs/puffs_msgif.c        Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: puffs_msgif.c,v 1.100 2016/12/26 08:21:09 skrll Exp $  */
+/*     $NetBSD: puffs_msgif.c,v 1.101 2017/04/17 08:31:01 hannken Exp $        */
 
 /*
  * Copyright (c) 2005, 2006, 2007  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.100 2016/12/26 08:21:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.101 2017/04/17 08:31:01 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1097,7 +1097,7 @@
                         * We know the mountpoint is still alive because
                         * the thread that is us (poetic?) is still alive.
                         */
-                       atomic_inc_uint((unsigned int*)&mp->mnt_refcnt);
+                       vfs_ref(mp);
                        break;
                }
 
@@ -1137,7 +1137,7 @@
         */
        if (unmountme) {
                (void)dounmount(mp, MNT_FORCE, curlwp);
-               vfs_destroy(mp);
+               vfs_rele(mp);
        }
 
        kthread_exit(0);
@@ -1182,13 +1182,13 @@
        }
 
        /* Won't access pmp from here anymore */
-       atomic_inc_uint((unsigned int*)&mp->mnt_refcnt);
+       vfs_ref(mp);
        puffs_mp_release(pmp);
        mutex_exit(&pmp->pmp_lock);
 
        /* Detach from VFS. */
        (void)dounmount(mp, MNT_FORCE, curlwp);
-       vfs_destroy(mp);
+       vfs_rele(mp);
 
        return 0;
 }
diff -r d7911b3f5536 -r baa7c30f6092 sys/fs/v7fs/v7fs_vfsops.c
--- a/sys/fs/v7fs/v7fs_vfsops.c Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/fs/v7fs/v7fs_vfsops.c Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: v7fs_vfsops.c,v 1.13 2017/04/01 19:35:57 riastradh Exp $       */
+/*     $NetBSD: v7fs_vfsops.c,v 1.14 2017/04/17 08:31:02 hannken Exp $ */
 
 /*-
  * Copyright (c) 2004, 2011 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.13 2017/04/01 19:35:57 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: v7fs_vfsops.c,v 1.14 2017/04/17 08:31:02 hannken Exp $");
 #if defined _KERNEL_OPT
 #include "opt_v7fs.h"
 #endif
@@ -580,7 +580,7 @@
        if ((error = v7fs_mountfs(rootvp, mp, _BYTE_ORDER))) {
                DPRINTF("mountfs error=%d\n", error);
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return error;
        }
 
diff -r d7911b3f5536 -r baa7c30f6092 sys/kern/vfs_mount.c
--- a/sys/kern/vfs_mount.c      Mon Apr 17 08:29:58 2017 +0000
+++ b/sys/kern/vfs_mount.c      Mon Apr 17 08:31:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_mount.c,v 1.54 2017/04/17 08:29:58 hannken Exp $   */
+/*     $NetBSD: vfs_mount.c,v 1.55 2017/04/17 08:31:02 hannken Exp $   */
 
 /*-
  * Copyright (c) 1997-2011 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.54 2017/04/17 08:29:58 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_mount.c,v 1.55 2017/04/17 08:31:02 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -264,10 +264,22 @@
 }
 
 /*
+ * Take a reference to a mount structure.
+ */
+void
+vfs_ref(struct mount *mp)
+{
+
+       KASSERT(mp->mnt_refcnt > 0 || mutex_owned(&mountlist_lock));
+
+       atomic_inc_uint(&mp->mnt_refcnt);
+}
+
+/*
  * Drop a reference to a mount structure, freeing if the last reference.
  */
 void
-vfs_destroy(struct mount *mp)
+vfs_rele(struct mount *mp)
 {
 
        if (__predict_true((int)atomic_dec_uint_nv(&mp->mnt_refcnt) > 0)) {
@@ -315,7 +327,7 @@
        ++mp->mnt_busynest;
        KASSERT(mp->mnt_busynest != 0);
        mutex_exit(&mp->mnt_unmounting);
-       atomic_inc_uint(&mp->mnt_refcnt);
+       vfs_ref(mp);
        return 0;
 }
 
@@ -340,7 +352,7 @@
        mp->mnt_busynest--;
        mutex_exit(&mp->mnt_unmounting);
        if (!keepref) {
-               vfs_destroy(mp);
+               vfs_rele(mp);
        }
 }
 
@@ -460,7 +472,7 @@
 
        if (omp != NULL) {
                /* Release reference to old mount. */
-               vfs_destroy(omp);
+               vfs_rele(omp);
        }
 }
 
@@ -716,7 +728,7 @@
 
        if ((error = fstrans_mount(mp)) != 0) {
                vfs_unbusy(mp, false, NULL);
-               vfs_destroy(mp);
+               vfs_rele(mp);
                return error;
        }
 
@@ -791,7 +803,7 @@
                (void)start_extattr(mp);
        }
        /* Drop reference held for VFS_START(). */
-       vfs_destroy(mp);
+       vfs_rele(mp);
        *vpp = NULL;
        return error;
 
@@ -804,7 +816,7 @@
        mutex_exit(&mp->mnt_updating);
        fstrans_unmount(mp);
        vfs_unbusy(mp, false, NULL);
-       vfs_destroy(mp);
+       vfs_rele(mp);
 
        return error;
 }
@@ -941,7 +953,7 @@
        vfs_hooks_unmount(mp);
 
        fstrans_unmount(mp);
-       vfs_destroy(mp);        /* reference from mount() */
+       vfs_rele(mp);   /* reference from mount() */
        if (coveredvp != NULLVP) {
                vrele(coveredvp);
        }



Home | Main Index | Thread Index | Old Index