Source-Changes-HG archive

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

[src/trunk]: src/sys/ufs Add new VFS op routine - vfs_done and call it on fil...



details:   https://anonhg.NetBSD.org/src/rev/b340cc2b9c68
branches:  trunk
changeset: 483727:b340cc2b9c68
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Mar 16 18:20:06 2000 +0000

description:
Add new VFS op routine - vfs_done and call it on filesystem detach
in vfs_detach(). vfs_done may free global filesystem's resources,
typically those allocated in respective filesystem's init function.
Needed so those filesystems which went in via LKM have a chance to
clean after themselves before unloading.

For each leaf filesystem, add appropriate vfs_done routine.

Also remember how many times ffs_init() was called and do
the appropriate initialization on first call only. In ffs_done(),
destroy the resources when called by the last user of ffs code.
Change mfs to call ffs_init()/ffs_done() appropriately.

diffstat:

 sys/ufs/ffs/ffs_extern.h |   5 +++--
 sys/ufs/ffs/ffs_vfsops.c |  20 +++++++++++++++++++-
 sys/ufs/mfs/mfs_extern.h |   3 ++-
 sys/ufs/mfs/mfs_vfsops.c |  17 ++++++++++++++++-
 4 files changed, 40 insertions(+), 5 deletions(-)

diffs (138 lines):

diff -r 23089fd323fa -r b340cc2b9c68 sys/ufs/ffs/ffs_extern.h
--- a/sys/ufs/ffs/ffs_extern.h  Thu Mar 16 18:08:17 2000 +0000
+++ b/sys/ufs/ffs/ffs_extern.h  Thu Mar 16 18:20:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_extern.h,v 1.14 2000/02/14 22:00:22 fvdl Exp $     */
+/*     $NetBSD: ffs_extern.h,v 1.15 2000/03/16 18:20:06 jdolecek Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993, 1994
@@ -94,7 +94,6 @@
 void ffs_csum_swap __P((struct csum *, struct csum *, int));
 
 /* ffs_inode.c */
-void ffs_init __P((void));
 int ffs_update __P((void *));
 int ffs_truncate __P((void *));
 
@@ -111,6 +110,8 @@
 void ffs_setblock __P((struct fs *, unsigned char *, ufs_daddr_t));
 
 /* ffs_vfsops.c */
+void ffs_init __P((void));
+void ffs_done __P((void));
 int ffs_mountroot __P((void));
 int ffs_mount __P((struct mount *, const char *, void *, struct nameidata *,
                   struct proc *));
diff -r 23089fd323fa -r b340cc2b9c68 sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c  Thu Mar 16 18:08:17 2000 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c  Thu Mar 16 18:20:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_vfsops.c,v 1.58 2000/03/16 10:37:00 fvdl Exp $     */
+/*     $NetBSD: ffs_vfsops.c,v 1.59 2000/03/16 18:20:06 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1989, 1991, 1993, 1994
@@ -74,6 +74,9 @@
 #include <ufs/ffs/fs.h>
 #include <ufs/ffs/ffs_extern.h>
 
+/* how many times ffs_init() was called */
+int ffs_initcount = 0;
+
 extern struct lock ufs_hashlock;
 
 int ffs_sbupdate __P((struct ufsmount *, int));
@@ -102,6 +105,7 @@
        ffs_fhtovp,
        ffs_vptofh,
        ffs_init,
+       ffs_done,
        ffs_sysctl,
        ffs_mountroot,
        ufs_check_export,
@@ -1106,6 +1110,9 @@
 void
 ffs_init()
 {
+       if (ffs_initcount++ > 0)
+               return;
+
        softdep_initialize();
        ufs_init();
 
@@ -1113,6 +1120,17 @@
            0, pool_page_alloc_nointr, pool_page_free_nointr, M_FFSNODE);
 }
 
+void
+ffs_done()
+{
+       if (--ffs_initcount > 0)
+               return;
+
+       /* XXX softdep cleanup ? */
+       ufs_done();
+       pool_destroy(&ffs_inode_pool);
+}
+
 int
 ffs_sysctl(name, namelen, oldp, oldlenp, newp, newlen, p)
        int *name;
diff -r 23089fd323fa -r b340cc2b9c68 sys/ufs/mfs/mfs_extern.h
--- a/sys/ufs/mfs/mfs_extern.h  Thu Mar 16 18:08:17 2000 +0000
+++ b/sys/ufs/mfs/mfs_extern.h  Thu Mar 16 18:20:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mfs_extern.h,v 1.8 1998/08/10 08:11:13 matthias Exp $  */
+/*     $NetBSD: mfs_extern.h,v 1.9 2000/03/16 18:20:07 jdolecek Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -57,6 +57,7 @@
                             struct proc *));
 
 void   mfs_init        __P((void));
+void   mfs_done        __P((void));
 
 /* mfs_vnops.c */
 int    mfs_open        __P((void *));
diff -r 23089fd323fa -r b340cc2b9c68 sys/ufs/mfs/mfs_vfsops.c
--- a/sys/ufs/mfs/mfs_vfsops.c  Thu Mar 16 18:08:17 2000 +0000
+++ b/sys/ufs/mfs/mfs_vfsops.c  Thu Mar 16 18:20:06 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mfs_vfsops.c,v 1.22 2000/01/21 23:43:10 thorpej Exp $  */
+/*     $NetBSD: mfs_vfsops.c,v 1.23 2000/03/16 18:20:07 jdolecek Exp $ */
 
 /*
  * Copyright (c) 1989, 1990, 1993, 1994
@@ -92,6 +92,7 @@
        ffs_fhtovp,
        ffs_vptofh,
        mfs_init,
+       mfs_done,
        ffs_sysctl,
        NULL,
        ufs_check_export,
@@ -104,8 +105,22 @@
 void
 mfs_init()
 {
+       /*
+        * ffs_init() ensures to initialize necessary resources
+        * only once.
+        */
+       ffs_init();
 }
 
+void
+mfs_done()
+{
+       /*
+        * ffs_done() ensures to free necessary resources
+        * only once, when it's no more needed.
+        */
+       ffs_done();
+}
 
 /*
  * Called by main() when mfs is going to be mounted as root.



Home | Main Index | Thread Index | Old Index