]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[XFS] Rework the dquot hash sizing heuristics.
authorNathan Scott <nathans@sgi.com>
Wed, 2 Nov 2005 04:08:25 +0000 (15:08 +1100)
committerNathan Scott <nathans@sgi.com>
Wed, 2 Nov 2005 04:08:25 +0000 (15:08 +1100)
SGI-PV: 943123
SGI-Modid: xfs-linux:xfs-kern:24012a

Signed-off-by: Nathan Scott <nathans@sgi.com>
fs/xfs/linux-2.6/xfs_linux.h
fs/xfs/quota/xfs_qm.c
fs/xfs/quota/xfs_qm.h

index 52b2405395313da95fc241c6e83fd47e0f14f268..44fed10af0ddc63bdbe5e4eb20d8ed225c7617a8 100644 (file)
@@ -217,19 +217,7 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
 #define Q_XSETPQLIM    XQM_CMD(10)     /* set projects disk limits */
 #define Q_XGETPQUOTA   XQM_CMD(11)     /* get projects disk limits */
 
-/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */
-/* we may well need to fine-tune this if it ever becomes an issue.  */
-#define DQUOT_MAX_HEURISTIC    1024    /* NR_DQUOTS */
-#define ndquot                 DQUOT_MAX_HEURISTIC
-
-/* IRIX uses the current size of the name cache to guess a good value */
-/* - this isn't the same but is a good enough starting point for now. */
-#define DQUOT_HASH_HEURISTIC   files_stat.nr_files
-
-/* IRIX inodes maintain the project ID also, zero this field on Linux */
-#define DEFAULT_PROJID 0
-#define dfltprid       DEFAULT_PROJID
-
+#define dfltprid       0
 #define MAXPATHLEN     1024
 
 #define MIN(a,b)       (min(a,b))
index 79aadb1c1f442dd3763d9a3d88ab577ec69d8309..1aea42d71a6424ea6091bb4539e947fed9c287b9 100644 (file)
@@ -60,8 +60,9 @@
  * quota functionality, including maintaining the freelist and hash
  * tables of dquots.
  */
-mutex_t xfs_Gqm_lock;
+mutex_t                xfs_Gqm_lock;
 struct xfs_qm  *xfs_Gqm;
+uint           ndquot;
 
 kmem_zone_t    *qm_dqzone;
 kmem_zone_t    *qm_dqtrxzone;
@@ -108,25 +109,25 @@ extern mutex_t    qcheck_lock;
 STATIC struct xfs_qm *
 xfs_Gqm_init(void)
 {
-       xfs_qm_t                *xqm;
-       int                     hsize, i;
-
-       xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
-       ASSERT(xqm);
+       xfs_dqhash_t    *udqhash, *gdqhash;
+       xfs_qm_t        *xqm;
+       uint            i, hsize, flags = KM_SLEEP | KM_MAYFAIL;
 
        /*
         * Initialize the dquot hash tables.
         */
-       hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ?
-               XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH;
-       xqm->qm_dqhashmask = hsize - 1;
+       hsize = XFS_QM_HASHSIZE_HIGH;
+       while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) {
+               if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW)
+                       flags = KM_SLEEP;
+       }
+       gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP);
+       ndquot = hsize << 8;
 
-       xqm->qm_usr_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize *
-                                                     sizeof(xfs_dqhash_t),
-                                                     KM_SLEEP);
-       xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize *
-                                                     sizeof(xfs_dqhash_t),
-                                                     KM_SLEEP);
+       xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
+       xqm->qm_dqhashmask = hsize - 1;
+       xqm->qm_usr_dqhtable = udqhash;
+       xqm->qm_grp_dqhtable = gdqhash;
        ASSERT(xqm->qm_usr_dqhtable != NULL);
        ASSERT(xqm->qm_grp_dqhtable != NULL);
 
index 43219c97b37105bc74a85301ee360042a2982fb1..12da259f2fcb6e5b319108e6c028ffe3ddf572ec 100644 (file)
@@ -26,6 +26,7 @@
 struct xfs_qm;
 struct xfs_inode;
 
+extern uint            ndquot;
 extern mutex_t         xfs_Gqm_lock;
 extern struct xfs_qm   *xfs_Gqm;
 extern kmem_zone_t     *qm_dqzone;
@@ -51,9 +52,8 @@ extern kmem_zone_t    *qm_dqtrxzone;
 /*
  * Dquot hashtable constants/threshold values.
  */
-#define XFS_QM_NCSIZE_THRESHOLD                5000
-#define XFS_QM_HASHSIZE_LOW            32
-#define XFS_QM_HASHSIZE_HIGH           64
+#define XFS_QM_HASHSIZE_LOW            (NBPP / sizeof(xfs_dqhash_t))
+#define XFS_QM_HASHSIZE_HIGH           ((NBPP * 4) / sizeof(xfs_dqhash_t))
 
 /*
  * We output a cmn_err when quotachecking a quota file with more than