Source-Changes-HG archive

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

[src/trunk]: src/sys add a new VFS op, vfs_reinit, which is called when desir...



details:   https://anonhg.NetBSD.org/src/rev/83ef0e96b90d
branches:  trunk
changeset: 514994:83ef0e96b90d
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Sep 15 16:12:54 2001 +0000

description:
add a new VFS op, vfs_reinit, which is called when desiredvnodes is
adjusted via sysctl.  file systems that have hash tables which are
sized based on the value of this variable now resize those hash tables
using the new value.  the max number of FFS softdeps is also recalculated.

convert various file systems to use the <sys/queue.h> macros for
their hash tables.

diffstat:

 sys/adosfs/advfsops.c               |    4 +-
 sys/coda/coda_vfsops.c              |    7 +-
 sys/filecorefs/filecore_extern.h    |    3 +-
 sys/filecorefs/filecore_node.c      |   54 +++++++++++-----
 sys/filecorefs/filecore_node.h      |    4 +-
 sys/filecorefs/filecore_vfsops.c    |    3 +-
 sys/isofs/cd9660/cd9660_extern.h    |    3 +-
 sys/isofs/cd9660/cd9660_node.c      |  115 +++++++++++++++++++++++------------
 sys/isofs/cd9660/cd9660_node.h      |    6 +-
 sys/isofs/cd9660/cd9660_vfsops.c    |    8 +-
 sys/isofs/cd9660/cd9660_vnops.c     |    8 +-
 sys/kern/kern_sysctl.c              |    5 +-
 sys/kern/vfs_subr.c                 |   18 ++++-
 sys/miscfs/fdesc/fdesc_vfsops.c     |    3 +-
 sys/miscfs/kernfs/kernfs_vfsops.c   |    3 +-
 sys/miscfs/nullfs/null_vfsops.c     |    3 +-
 sys/miscfs/overlay/overlay_vfsops.c |    3 +-
 sys/miscfs/portal/portal_vfsops.c   |    3 +-
 sys/miscfs/procfs/procfs.h          |    3 +-
 sys/miscfs/procfs/procfs_subr.c     |   43 +++++++++++-
 sys/miscfs/procfs/procfs_vfsops.c   |   10 ++-
 sys/miscfs/umapfs/umap_vfsops.c     |    3 +-
 sys/miscfs/union/union_vfsops.c     |    3 +-
 sys/msdosfs/denode.h                |    5 +-
 sys/msdosfs/msdosfs_denode.c        |   69 +++++++++++++-------
 sys/msdosfs/msdosfs_vfsops.c        |    3 +-
 sys/msdosfs/msdosfsmount.h          |    3 +-
 sys/nfs/nfs.h                       |    5 +-
 sys/nfs/nfs_node.c                  |   41 +++++++++++-
 sys/nfs/nfs_subs.c                  |   15 ++--
 sys/nfs/nfs_var.h                   |    3 +-
 sys/nfs/nfs_vfsops.c                |    3 +-
 sys/nfs/nfsmount.h                  |    3 +-
 sys/ntfs/ntfs_ihash.c               |   45 +++++++++++--
 sys/ntfs/ntfs_ihash.h               |    3 +-
 sys/ntfs/ntfs_vfsops.c              |   12 ++-
 sys/sys/mount.h                     |    4 +-
 sys/ufs/ext2fs/ext2fs_extern.h      |    3 +-
 sys/ufs/ext2fs/ext2fs_vfsops.c      |    9 ++-
 sys/ufs/ffs/ffs_extern.h            |    4 +-
 sys/ufs/ffs/ffs_softdep.c           |   71 ++++++++++++++++++---
 sys/ufs/ffs/ffs_vfsops.c            |   11 +++-
 sys/ufs/lfs/lfs_extern.h            |    3 +-
 sys/ufs/lfs/lfs_vfsops.c            |    9 ++-
 sys/ufs/mfs/mfs_extern.h            |    3 +-
 sys/ufs/mfs/mfs_vfsops.c            |    9 ++-
 sys/ufs/ufs/quota.h                 |    3 +-
 sys/ufs/ufs/ufs_extern.h            |    4 +-
 sys/ufs/ufs/ufs_ihash.c             |   49 ++++++++++++---
 sys/ufs/ufs/ufs_quota.c             |   63 +++++++++++++-----
 sys/ufs/ufs/ufs_vfsops.c            |   11 +++-
 51 files changed, 570 insertions(+), 211 deletions(-)

diffs (truncated from 2046 to 300 lines):

diff -r 457cc9da1344 -r 83ef0e96b90d sys/adosfs/advfsops.c
--- a/sys/adosfs/advfsops.c     Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/adosfs/advfsops.c     Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: advfsops.c,v 1.46 2001/05/30 11:40:35 mrg Exp $        */
+/*     $NetBSD: advfsops.c,v 1.47 2001/09/15 16:12:54 chs Exp $        */
 
 /*
  * Copyright (c) 1994 Christian E. Hopps
@@ -53,6 +53,7 @@
 #include <adosfs/adosfs.h>
 
 void adosfs_init __P((void));
+void adosfs_reinit __P((void));
 void adosfs_done __P((void));
 int adosfs_mount __P((struct mount *, const char *, void *, struct nameidata *,
                      struct proc *));
@@ -848,6 +849,7 @@
        adosfs_fhtovp,                  
        adosfs_vptofh,                  
        adosfs_init,                    
+       NULL,
        adosfs_done,
        adosfs_sysctl,
        NULL,                           /* vfs_mountroot */
diff -r 457cc9da1344 -r 83ef0e96b90d sys/coda/coda_vfsops.c
--- a/sys/coda/coda_vfsops.c    Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/coda/coda_vfsops.c    Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coda_vfsops.c,v 1.12 2001/07/18 16:12:31 thorpej Exp $ */
+/*     $NetBSD: coda_vfsops.c,v 1.13 2001/09/15 16:12:55 chs Exp $     */
 
 /*
  * 
@@ -109,9 +109,8 @@
        eopnotsupp,
     (int (*) (struct vnode *, struct fid *)) eopnotsupp,
     coda_init,
-#ifdef __NetBSD__
+    NULL,
     coda_done,
-#endif
     coda_sysctl,
     (int (*)(void)) eopnotsupp,
     (int (*)(struct mount *, struct mbuf *, int *, struct ucred **))
@@ -538,13 +537,11 @@
     ENTRY;
 }
 
-#ifdef __NetBSD__
 void
 coda_done(void)
 {
     ENTRY;
 }
-#endif
 
 int
 coda_sysctl(name, namelen, oldp, oldlp, newp, newl, p)
diff -r 457cc9da1344 -r 83ef0e96b90d sys/filecorefs/filecore_extern.h
--- a/sys/filecorefs/filecore_extern.h  Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/filecorefs/filecore_extern.h  Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_extern.h,v 1.6 2000/03/16 18:08:22 jdolecek Exp $     */
+/*     $NetBSD: filecore_extern.h,v 1.7 2001/09/15 16:12:55 chs Exp $  */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -86,6 +86,7 @@
            struct ucred **));
 int filecore_vptofh __P((struct vnode *, struct fid *));
 void filecore_init __P((void));
+void filecore_reinit __P((void));
 void filecore_done __P((void));
 int filecore_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
                        struct proc *));
diff -r 457cc9da1344 -r 83ef0e96b90d sys/filecorefs/filecore_node.c
--- a/sys/filecorefs/filecore_node.c    Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/filecorefs/filecore_node.c    Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_node.c,v 1.7 2001/02/07 12:34:59 tsutsui Exp $        */
+/*     $NetBSD: filecore_node.c,v 1.8 2001/09/15 16:12:55 chs Exp $    */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -58,7 +58,7 @@
 /*
  * Structures associated with filecore_node caching.
  */
-struct filecore_node **filecorehashtbl;
+LIST_HEAD(ihashhead, filecore_node) *filecorehashtbl;
 u_long filecorehash;
 #define        INOHASH(device, inum)   (((device) + ((inum)>>12)) & filecorehash)
 struct simplelock filecore_ihash_slock;
@@ -82,6 +82,36 @@
 }
 
 /*
+ * Reinitialize inode hash table.
+ */
+void
+filecore_reinit()
+{
+       struct filecore_node *ip;
+       struct ihashhead *oldhash, *hash;
+       u_long oldmask, mask, val;
+       int i;
+
+       hash = hashinit(desiredvnodes, HASH_LIST, M_FILECOREMNT, M_WAITOK,
+           &mask);
+
+       simple_lock(&filecore_ihash_slock);
+       oldhash = filecorehashtbl;
+       oldmask = filecorehash;
+       filecorehashtbl = hash;
+       filecorehash = mask;
+       for (i = 0; i <= oldmask; i++) {
+               while ((ip = LIST_FIRST(&oldhash[i])) != NULL) {
+                       LIST_REMOVE(ip, i_hash);
+                       val = INOHASH(ip->i_dev, ip->i_number);
+                       LIST_INSERT_HEAD(&hash[val], ip, i_hash);
+               }
+       }
+       simple_unlock(&filecore_ihash_slock);
+       hashdone(oldhash, M_FILECOREMNT);
+}
+
+/*
  * Destroy node pool and hash table.
  */
 void
@@ -105,7 +135,7 @@
 
 loop:
        simple_lock(&filecore_ihash_slock);
-       for (ip = filecorehashtbl[INOHASH(dev, inum)]; ip; ip = ip->i_next) {
+       LIST_FOREACH(ip, &filecorehashtbl[INOHASH(dev, inum)], i_hash) {
                if (inum == ip->i_number && dev == ip->i_dev) {
                        vp = ITOV(ip);
                        simple_lock(&vp->v_interlock);
@@ -126,16 +156,12 @@
 filecore_ihashins(ip)
        struct filecore_node *ip;
 {
-       struct filecore_node **ipp, *iq;
+       struct ihashhead *ipp;
        struct vnode *vp;
 
        simple_lock(&filecore_ihash_slock);
        ipp = &filecorehashtbl[INOHASH(ip->i_dev, ip->i_number)];
-       if ((iq = *ipp) != NULL)
-               iq->i_prev = &ip->i_next;
-       ip->i_next = iq;
-       ip->i_prev = ipp;
-       *ipp = ip;
+       LIST_INSERT_HEAD(ipp, ip, i_hash);
        simple_unlock(&filecore_ihash_slock);
 
        vp = ip->i_vnode;
@@ -149,16 +175,8 @@
 filecore_ihashrem(ip)
        struct filecore_node *ip;
 {
-       struct filecore_node *iq;
-
        simple_lock(&filecore_ihash_slock);
-       if ((iq = ip->i_next) != NULL)
-               iq->i_prev = ip->i_prev;
-       *ip->i_prev = iq;
-#ifdef DIAGNOSTIC
-       ip->i_next = NULL;
-       ip->i_prev = NULL;
-#endif
+       LIST_REMOVE(ip, i_hash);
        simple_unlock(&filecore_ihash_slock);
 }
 
diff -r 457cc9da1344 -r 83ef0e96b90d sys/filecorefs/filecore_node.h
--- a/sys/filecorefs/filecore_node.h    Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/filecorefs/filecore_node.h    Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_node.h,v 1.4 2001/05/28 02:50:51 chs Exp $    */
+/*     $NetBSD: filecore_node.h,v 1.5 2001/09/15 16:12:56 chs Exp $    */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -46,7 +46,7 @@
 #define doff_t long
 
 struct filecore_node {
-       struct  filecore_node *i_next, **i_prev;        /* hash chain */
+       LIST_ENTRY(filecore_node) i_hash;
        struct  vnode *i_vnode; /* vnode associated with this inode */
        struct  vnode *i_devvp; /* vnode for block I/O */
        u_long  i_flag;         /* see below */
diff -r 457cc9da1344 -r 83ef0e96b90d sys/filecorefs/filecore_vfsops.c
--- a/sys/filecorefs/filecore_vfsops.c  Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/filecorefs/filecore_vfsops.c  Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: filecore_vfsops.c,v 1.14 2001/05/30 11:42:13 mrg Exp $ */
+/*     $NetBSD: filecore_vfsops.c,v 1.15 2001/09/15 16:12:56 chs Exp $ */
 
 /*-
  * Copyright (c) 1998 Andrew McMurry
@@ -79,6 +79,7 @@
        filecore_fhtovp,
        filecore_vptofh,
        filecore_init,
+       filecore_reinit,
        filecore_done,
        filecore_sysctl,
        NULL,                           /* filecore_mountroot */
diff -r 457cc9da1344 -r 83ef0e96b90d sys/isofs/cd9660/cd9660_extern.h
--- a/sys/isofs/cd9660/cd9660_extern.h  Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/isofs/cd9660/cd9660_extern.h  Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_extern.h,v 1.9 2000/05/27 16:03:55 jdolecek Exp $       */
+/*     $NetBSD: cd9660_extern.h,v 1.10 2001/09/15 16:12:56 chs Exp $   */
 
 /*-
  * Copyright (c) 1994
@@ -98,6 +98,7 @@
            struct ucred **));
 int cd9660_vptofh __P((struct vnode *, struct fid *));
 void cd9660_init __P((void));
+void cd9660_reinit __P((void));
 void cd9660_done __P((void));
 int cd9660_sysctl __P((int *, u_int, void *, size_t *, void *, size_t,
                        struct proc *));
diff -r 457cc9da1344 -r 83ef0e96b90d sys/isofs/cd9660/cd9660_node.c
--- a/sys/isofs/cd9660/cd9660_node.c    Sat Sep 15 15:43:40 2001 +0000
+++ b/sys/isofs/cd9660/cd9660_node.c    Sat Sep 15 16:12:54 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cd9660_node.c,v 1.25 2001/02/03 12:48:43 tsutsui Exp $ */
+/*     $NetBSD: cd9660_node.c,v 1.26 2001/09/15 16:12:56 chs Exp $     */
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1994
@@ -62,13 +62,13 @@
 /*
  * Structures associated with iso_node caching.
  */
-struct iso_node **isohashtbl;
+LIST_HEAD(ihashhead, iso_node) *isohashtbl;
 u_long isohash;
 #define        INOHASH(device, inum)   (((device) + ((inum)>>12)) & isohash)
 struct simplelock cd9660_ihash_slock;
 
 #ifdef ISODEVMAP
-struct iso_node **idvhashtbl;
+LIST_HEAD(idvhashhead, iso_dnode) *idvhashtbl;
 u_long idvhash;
 #define        DNOHASH(device, inum)   (((device) + ((inum)>>12)) & idvhash)
 #endif
@@ -98,6 +98,62 @@
 }
 
 /*
+ * Reinitialize inode hash table.
+ */
+
+void
+cd9660_reinit()
+{
+       struct iso_node *ip;
+       struct ihashhead *oldhash1, *hash1;
+       u_long oldmask1, mask1, val;
+#ifdef ISODEVMAP
+       struct iso_dnode *dp;
+       struct idvhashhead *oldhash2, *hash2;
+       u_long oldmask2, mask2;
+#endif
+       int i;
+
+       hash1 = hashinit(desiredvnodes, HASH_LIST, M_ISOFSMNT, M_WAITOK,
+           &mask1);
+#ifdef ISODEVMAP
+       hash2 = hashinit(desiredvnodes / 8, HASH_LIST, M_ISOFSMNT, M_WAITOK,
+           &mask2);
+#endif
+
+       simple_lock(&cd9660_ihash_slock);
+       oldhash1 = isohashtbl;
+       oldmask1 = isohash;
+       isohashtbl = hash1;
+       isohash = mask1;
+#ifdef ISODEVMAP
+       oldhash2 = idvhashtbl;
+       oldmask2 = idvhash;
+       idvhashtbl = hash2;
+       idvhash = mask2;
+       for (i = 0; i <= oldmask2; i++) {
+               while ((dp = LIST_FIRST(&oldhash2[i])) != NULL) {
+                       LIST_REMOVE(dp, d_hash);
+                       val = DNOHASH(dp->i_dev, dp->i_number);
+                       LIST_INSERT_HEAD(&hash2[val], dp, d_hash);
+               }
+       }
+#endif
+       for (i = 0; i <= oldmask1; i++) {



Home | Main Index | Thread Index | Old Index