Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2003 18:08:47 -0500
From:      Mike Makonnen <mtm@identd.net>
To:        Poul-Henning Kamp <phk@phk.freebsd.dk>
Cc:        current@FreeBSD.org
Subject:   Re: MSDOSFS wastes 256k when nothing is mounted!
Message-ID:  <20030209230848.VZI7113.pop015.verizon.net@kokeb.ambesa.net>
In-Reply-To: <31456.1044819599@critter.freebsd.dk>
References:  <31456.1044819599@critter.freebsd.dk>

next in thread | previous in thread | raw e-mail | index | archive | help
How about the attached?

It's only partially tested since it seems I can't mount any msdos floppies (both
on this _and_ my previous kernel).


Cheers.
-- 
Mike Makonnen  | GPG-KEY: http://www.identd.net/~mtm/mtm.asc
mtm@identd.net | Fingerprint: D228 1A6F C64E 120A A1C9  A3AA DAE1 E2AF DBCC 68B9

Index: sys/fs/msdosfs/msdosfs_denode.c
===================================================================
RCS file: /home/ncvs/src/sys/fs/msdosfs/msdosfs_denode.c,v
retrieving revision 1.67
diff -u -r1.67 msdosfs_denode.c
--- sys/fs/msdosfs/msdosfs_denode.c	21 Jan 2003 08:55:46 -0000	1.67
+++ sys/fs/msdosfs/msdosfs_denode.c	9 Feb 2003 22:14:41 -0000
@@ -73,6 +73,12 @@
 static u_long dehash;			/* size of hash table - 1 */
 #define	DEHASH(dev, dcl, doff)	(dehashtbl[(minor(dev) + (dcl) + (doff) / 
\ 				sizeof(struct direntry)) & dehash])
+#define DEHASH_INIT  do {\
+	if (dehashtbl == NULL) {\
+		dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash);\
+		KASSERT(dehashtbl != NULL, "msdosfs dehashtbl == NULL");\
+	}\
+     } while (0)
 static struct mtx dehash_mtx;
 
 union _qcvt {
@@ -102,8 +108,8 @@
 msdosfs_init(vfsp)
 	struct vfsconf *vfsp;
 {
-	dehashtbl = hashinit(desiredvnodes/2, M_MSDOSFSMNT, &dehash);
 	mtx_init(&dehash_mtx, "msdosfs dehash", NULL, MTX_DEF);
+	dehashtbl = NULL;
 	return (0);
 }
 
@@ -112,8 +118,10 @@
 	struct vfsconf *vfsp;
 {
 
-	if (dehashtbl)
+	if (dehashtbl) {
 		free(dehashtbl, M_MSDOSFSMNT);
+		dehashtbl = NULL;
+	}
 	mtx_destroy(&dehash_mtx);
 	return (0);
 }
@@ -130,6 +138,7 @@
 
 loop:
 	mtx_lock(&dehash_mtx);
+	DEHASH_INIT;
 	for (dep = DEHASH(dev, dirclust, diroff); dep; dep = dep->de_next) {
 		if (dirclust == dep->de_dirclust
 		    && diroff == dep->de_diroffset
@@ -154,6 +163,7 @@
 	struct denode **depp, *deq;
 
 	mtx_lock(&dehash_mtx);
+	DEHASH_INIT;
 	depp = &DEHASH(dep->de_dev, dep->de_dirclust, dep->de_diroffset);
 	deq = *depp;
 	if (deq)

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030209230848.VZI7113.pop015.verizon.net>