From owner-freebsd-current Sun Feb 9 15: 8:52 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1151D37B401 for ; Sun, 9 Feb 2003 15:08:50 -0800 (PST) Received: from pop015.verizon.net (pop015pub.verizon.net [206.46.170.172]) by mx1.FreeBSD.org (Postfix) with ESMTP id 455E643F93 for ; Sun, 9 Feb 2003 15:08:49 -0800 (PST) (envelope-from mtm@identd.net) Received: from kokeb.ambesa.net ([138.88.50.112]) by pop015.verizon.net (InterMail vM.5.01.05.20 201-253-122-126-120-20021101) with ESMTP id <20030209230848.VZI7113.pop015.verizon.net@kokeb.ambesa.net>; Sun, 9 Feb 2003 17:08:48 -0600 Date: Sun, 9 Feb 2003 18:08:47 -0500 From: Mike Makonnen To: Poul-Henning Kamp Cc: current@FreeBSD.org Subject: Re: MSDOSFS wastes 256k when nothing is mounted! In-Reply-To: <31456.1044819599@critter.freebsd.dk> References: <31456.1044819599@critter.freebsd.dk> X-Mailer: Sylpheed version 0.8.10 (GTK+ 1.2.10; i386-portbld-freebsd5.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authentication-Info: Submitted using SMTP AUTH at pop015.verizon.net from [138.88.50.112] at Sun, 9 Feb 2003 17:08:48 -0600 Message-Id: <20030209230848.VZI7113.pop015.verizon.net@kokeb.ambesa.net> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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