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
[EMAIL PROTECTED] | 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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to