aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2005-11-01 23:08:25 -0500
committerNathan Scott <nathans@sgi.com>2005-11-01 23:08:25 -0500
commit6b3f6b5b87f03d1649340d6b3a572206653a2a2b (patch)
tree7b8791eed46bbfa82f777ca25282c434270fdf50 /fs/xfs
parent1f730e3b530fb2fa3159df06405c83f9a6fbbd83 (diff)
[XFS] Rework the dquot hash sizing heuristics.
SGI-PV: 943123 SGI-Modid: xfs-linux:xfs-kern:24012a Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h14
-rw-r--r--fs/xfs/quota/xfs_qm.c31
-rw-r--r--fs/xfs/quota/xfs_qm.h6
3 files changed, 20 insertions, 31 deletions
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index 52b240539531..44fed10af0dd 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -217,19 +217,7 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh)
217#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */ 217#define Q_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
218#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ 218#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
219 219
220/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ 220#define dfltprid 0
221/* we may well need to fine-tune this if it ever becomes an issue. */
222#define DQUOT_MAX_HEURISTIC 1024 /* NR_DQUOTS */
223#define ndquot DQUOT_MAX_HEURISTIC
224
225/* IRIX uses the current size of the name cache to guess a good value */
226/* - this isn't the same but is a good enough starting point for now. */
227#define DQUOT_HASH_HEURISTIC files_stat.nr_files
228
229/* IRIX inodes maintain the project ID also, zero this field on Linux */
230#define DEFAULT_PROJID 0
231#define dfltprid DEFAULT_PROJID
232
233#define MAXPATHLEN 1024 221#define MAXPATHLEN 1024
234 222
235#define MIN(a,b) (min(a,b)) 223#define MIN(a,b) (min(a,b))
diff --git a/fs/xfs/quota/xfs_qm.c b/fs/xfs/quota/xfs_qm.c
index 79aadb1c1f44..1aea42d71a64 100644
--- a/fs/xfs/quota/xfs_qm.c
+++ b/fs/xfs/quota/xfs_qm.c
@@ -60,8 +60,9 @@
60 * quota functionality, including maintaining the freelist and hash 60 * quota functionality, including maintaining the freelist and hash
61 * tables of dquots. 61 * tables of dquots.
62 */ 62 */
63mutex_t xfs_Gqm_lock; 63mutex_t xfs_Gqm_lock;
64struct xfs_qm *xfs_Gqm; 64struct xfs_qm *xfs_Gqm;
65uint ndquot;
65 66
66kmem_zone_t *qm_dqzone; 67kmem_zone_t *qm_dqzone;
67kmem_zone_t *qm_dqtrxzone; 68kmem_zone_t *qm_dqtrxzone;
@@ -108,25 +109,25 @@ extern mutex_t qcheck_lock;
108STATIC struct xfs_qm * 109STATIC struct xfs_qm *
109xfs_Gqm_init(void) 110xfs_Gqm_init(void)
110{ 111{
111 xfs_qm_t *xqm; 112 xfs_dqhash_t *udqhash, *gdqhash;
112 int hsize, i; 113 xfs_qm_t *xqm;
113 114 uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL;
114 xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
115 ASSERT(xqm);
116 115
117 /* 116 /*
118 * Initialize the dquot hash tables. 117 * Initialize the dquot hash tables.
119 */ 118 */
120 hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ? 119 hsize = XFS_QM_HASHSIZE_HIGH;
121 XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH; 120 while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) {
122 xqm->qm_dqhashmask = hsize - 1; 121 if ((hsize >>= 1) <= XFS_QM_HASHSIZE_LOW)
122 flags = KM_SLEEP;
123 }
124 gdqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), KM_SLEEP);
125 ndquot = hsize << 8;
123 126
124 xqm->qm_usr_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * 127 xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
125 sizeof(xfs_dqhash_t), 128 xqm->qm_dqhashmask = hsize - 1;
126 KM_SLEEP); 129 xqm->qm_usr_dqhtable = udqhash;
127 xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * 130 xqm->qm_grp_dqhtable = gdqhash;
128 sizeof(xfs_dqhash_t),
129 KM_SLEEP);
130 ASSERT(xqm->qm_usr_dqhtable != NULL); 131 ASSERT(xqm->qm_usr_dqhtable != NULL);
131 ASSERT(xqm->qm_grp_dqhtable != NULL); 132 ASSERT(xqm->qm_grp_dqhtable != NULL);
132 133
diff --git a/fs/xfs/quota/xfs_qm.h b/fs/xfs/quota/xfs_qm.h
index 43219c97b371..12da259f2fcb 100644
--- a/fs/xfs/quota/xfs_qm.h
+++ b/fs/xfs/quota/xfs_qm.h
@@ -26,6 +26,7 @@
26struct xfs_qm; 26struct xfs_qm;
27struct xfs_inode; 27struct xfs_inode;
28 28
29extern uint ndquot;
29extern mutex_t xfs_Gqm_lock; 30extern mutex_t xfs_Gqm_lock;
30extern struct xfs_qm *xfs_Gqm; 31extern struct xfs_qm *xfs_Gqm;
31extern kmem_zone_t *qm_dqzone; 32extern kmem_zone_t *qm_dqzone;
@@ -51,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone;
51/* 52/*
52 * Dquot hashtable constants/threshold values. 53 * Dquot hashtable constants/threshold values.
53 */ 54 */
54#define XFS_QM_NCSIZE_THRESHOLD 5000 55#define XFS_QM_HASHSIZE_LOW (NBPP / sizeof(xfs_dqhash_t))
55#define XFS_QM_HASHSIZE_LOW 32 56#define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t))
56#define XFS_QM_HASHSIZE_HIGH 64
57 57
58/* 58/*
59 * We output a cmn_err when quotachecking a quota file with more than 59 * We output a cmn_err when quotachecking a quota file with more than