Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ufs Change ufs_init() to keep global count of how ma...
details: https://anonhg.NetBSD.org/src/rev/d5211de330c6
branches: trunk
changeset: 483728:d5211de330c6
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Thu Mar 16 18:26:49 2000 +0000
description:
Change ufs_init() to keep global count of how many times it was called.
Resources are initialized still just once (on first call).
Add ufs_done(), which takes care of freeing all resources allocated in
ufs_init(). The resources are freed only when last user of the code exits.
diffstat:
sys/ufs/ufs/quota.h | 3 ++-
sys/ufs/ufs/ufs_extern.h | 6 ++++--
sys/ufs/ufs/ufs_ihash.c | 11 ++++++++++-
sys/ufs/ufs/ufs_quota.c | 12 ++++++++++--
sys/ufs/ufs/ufs_vfsops.c | 27 +++++++++++++++++++++------
5 files changed, 47 insertions(+), 12 deletions(-)
diffs (160 lines):
diff -r b340cc2b9c68 -r d5211de330c6 sys/ufs/ufs/quota.h
--- a/sys/ufs/ufs/quota.h Thu Mar 16 18:20:06 2000 +0000
+++ b/sys/ufs/ufs/quota.h Thu Mar 16 18:26:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: quota.h,v 1.7 1996/09/28 19:07:06 christos Exp $ */
+/* $NetBSD: quota.h,v 1.8 2000/03/16 18:26:49 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
@@ -190,6 +190,7 @@
int dqget __P((struct vnode *,
u_long, struct ufsmount *, int, struct dquot **));
void dqinit __P((void));
+void dqdone __P((void));
void dqref __P((struct dquot *));
void dqrele __P((struct vnode *, struct dquot *));
int dqsync __P((struct vnode *, struct dquot *));
diff -r b340cc2b9c68 -r d5211de330c6 sys/ufs/ufs/ufs_extern.h
--- a/sys/ufs/ufs/ufs_extern.h Thu Mar 16 18:20:06 2000 +0000
+++ b/sys/ufs/ufs/ufs_extern.h Thu Mar 16 18:26:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_extern.h,v 1.22 2000/02/14 22:00:23 fvdl Exp $ */
+/* $NetBSD: ufs_extern.h,v 1.23 2000/03/16 18:26:49 jdolecek Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -105,13 +105,13 @@
/* ufs_ihash.c */
void ufs_ihashinit __P((void));
+void ufs_ihashdone __P((void));
struct vnode *ufs_ihashlookup __P((dev_t, ino_t));
struct vnode *ufs_ihashget __P((dev_t, ino_t, int));
void ufs_ihashins __P((struct inode *));
void ufs_ihashrem __P((struct inode *));
/* ufs_inode.c */
-void ufs_init __P((void));
int ufs_reclaim __P((struct vnode *, struct proc *));
/* ufs_lookup.c */
@@ -147,6 +147,8 @@
void dqflush __P((struct vnode *));
/* ufs_vfsops.c */
+void ufs_init __P((void));
+void ufs_done __P((void));
int ufs_start __P((struct mount *, int, struct proc *));
int ufs_root __P((struct mount *, struct vnode **));
int ufs_quotactl __P((struct mount *, int, uid_t, caddr_t, struct proc *));
diff -r b340cc2b9c68 -r d5211de330c6 sys/ufs/ufs/ufs_ihash.c
--- a/sys/ufs/ufs/ufs_ihash.c Thu Mar 16 18:20:06 2000 +0000
+++ b/sys/ufs/ufs/ufs_ihash.c Thu Mar 16 18:26:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_ihash.c,v 1.9 1999/11/15 18:49:15 fvdl Exp $ */
+/* $NetBSD: ufs_ihash.c,v 1.10 2000/03/16 18:26:49 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -68,6 +68,15 @@
}
/*
+ * Free inode hash table.
+ */
+void
+ufs_ihashdone()
+{
+ hashdone(ihashtbl, M_UFSMNT);
+}
+
+/*
* Use the device/inum pair to find the incore inode, and return a pointer
* to it. If it is in core, return it, even if it is locked.
*/
diff -r b340cc2b9c68 -r d5211de330c6 sys/ufs/ufs/ufs_quota.c
--- a/sys/ufs/ufs/ufs_quota.c Thu Mar 16 18:20:06 2000 +0000
+++ b/sys/ufs/ufs/ufs_quota.c Thu Mar 16 18:26:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_quota.c,v 1.13 1999/11/15 18:49:15 fvdl Exp $ */
+/* $NetBSD: ufs_quota.c,v 1.14 2000/03/16 18:26:49 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -684,12 +684,20 @@
void
dqinit()
{
-
dqhashtbl = hashinit(desiredvnodes, M_DQUOT, M_WAITOK, &dqhash);
TAILQ_INIT(&dqfreelist);
}
/*
+ * Free resources held by quota system.
+ */
+void
+dqdone()
+{
+ hashdone(dqhashtbl, M_DQUOT);
+}
+
+/*
* Obtain a dquot structure for the specified identifier and quota file
* reading the information from the file if necessary.
*/
diff -r b340cc2b9c68 -r d5211de330c6 sys/ufs/ufs/ufs_vfsops.c
--- a/sys/ufs/ufs/ufs_vfsops.c Thu Mar 16 18:20:06 2000 +0000
+++ b/sys/ufs/ufs/ufs_vfsops.c Thu Mar 16 18:26:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ufs_vfsops.c,v 1.9 1999/02/26 23:44:50 wrstuden Exp $ */
+/* $NetBSD: ufs_vfsops.c,v 1.10 2000/03/16 18:26:49 jdolecek Exp $ */
/*
* Copyright (c) 1991, 1993, 1994
@@ -57,6 +57,9 @@
#include <ufs/ufs/ufsmount.h>
#include <ufs/ufs/ufs_extern.h>
+/* how many times ufs_init() was called */
+int ufs_initcount = 0;
+
/*
* Make a filesystem operational.
* Nothing to do at the moment.
@@ -219,17 +222,29 @@
/*
* Initialize UFS filesystems, done only once.
*/
-
void
ufs_init()
{
- static int done = 0;
+ if (ufs_initcount++ > 0)
+ return;
- if (done)
- return;
- done = 1;
ufs_ihashinit();
#ifdef QUOTA
dqinit();
#endif
}
+
+/*
+ * Free UFS filesystem resources, done only once.
+ */
+void
+ufs_done()
+{
+ if (--ufs_initcount > 0)
+ return;
+
+ ufs_ihashdone();
+#ifdef QUOTA
+ dqdone();
+#endif
+}
Home |
Main Index |
Thread Index |
Old Index