Commit 6b3f6b5b authored by Nathan Scott's avatar Nathan Scott

[XFS] Rework the dquot hash sizing heuristics.

SGI-PV: 943123
SGI-Modid: xfs-linux:xfs-kern:24012a
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 1f730e3b
...@@ -217,19 +217,7 @@ static inline void set_buffer_unwritten_io(struct buffer_head *bh) ...@@ -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_XSETPQLIM XQM_CMD(10) /* set projects disk limits */
#define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */ #define Q_XGETPQUOTA XQM_CMD(11) /* get projects disk limits */
/* IRIX uses a dynamic sizing algorithm (ndquot = 200 + numprocs*2) */ #define dfltprid 0
/* 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 MAXPATHLEN 1024 #define MAXPATHLEN 1024
#define MIN(a,b) (min(a,b)) #define MIN(a,b) (min(a,b))
......
...@@ -60,8 +60,9 @@ ...@@ -60,8 +60,9 @@
* quota functionality, including maintaining the freelist and hash * quota functionality, including maintaining the freelist and hash
* tables of dquots. * tables of dquots.
*/ */
mutex_t xfs_Gqm_lock; mutex_t xfs_Gqm_lock;
struct xfs_qm *xfs_Gqm; struct xfs_qm *xfs_Gqm;
uint ndquot;
kmem_zone_t *qm_dqzone; kmem_zone_t *qm_dqzone;
kmem_zone_t *qm_dqtrxzone; kmem_zone_t *qm_dqtrxzone;
...@@ -108,25 +109,25 @@ extern mutex_t qcheck_lock; ...@@ -108,25 +109,25 @@ extern mutex_t qcheck_lock;
STATIC struct xfs_qm * STATIC struct xfs_qm *
xfs_Gqm_init(void) xfs_Gqm_init(void)
{ {
xfs_qm_t *xqm; xfs_dqhash_t *udqhash, *gdqhash;
int hsize, i; xfs_qm_t *xqm;
uint i, hsize, flags = KM_SLEEP | KM_MAYFAIL;
xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
ASSERT(xqm);
/* /*
* Initialize the dquot hash tables. * Initialize the dquot hash tables.
*/ */
hsize = (DQUOT_HASH_HEURISTIC < XFS_QM_NCSIZE_THRESHOLD) ? hsize = XFS_QM_HASHSIZE_HIGH;
XFS_QM_HASHSIZE_LOW : XFS_QM_HASHSIZE_HIGH; while (!(udqhash = kmem_zalloc(hsize * sizeof(xfs_dqhash_t), flags))) {
xqm->qm_dqhashmask = hsize - 1; 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 * xqm = kmem_zalloc(sizeof(xfs_qm_t), KM_SLEEP);
sizeof(xfs_dqhash_t), xqm->qm_dqhashmask = hsize - 1;
KM_SLEEP); xqm->qm_usr_dqhtable = udqhash;
xqm->qm_grp_dqhtable = (xfs_dqhash_t *)kmem_zalloc(hsize * xqm->qm_grp_dqhtable = gdqhash;
sizeof(xfs_dqhash_t),
KM_SLEEP);
ASSERT(xqm->qm_usr_dqhtable != NULL); ASSERT(xqm->qm_usr_dqhtable != NULL);
ASSERT(xqm->qm_grp_dqhtable != NULL); ASSERT(xqm->qm_grp_dqhtable != NULL);
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
struct xfs_qm; struct xfs_qm;
struct xfs_inode; struct xfs_inode;
extern uint ndquot;
extern mutex_t xfs_Gqm_lock; extern mutex_t xfs_Gqm_lock;
extern struct xfs_qm *xfs_Gqm; extern struct xfs_qm *xfs_Gqm;
extern kmem_zone_t *qm_dqzone; extern kmem_zone_t *qm_dqzone;
...@@ -51,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone; ...@@ -51,9 +52,8 @@ extern kmem_zone_t *qm_dqtrxzone;
/* /*
* Dquot hashtable constants/threshold values. * Dquot hashtable constants/threshold values.
*/ */
#define XFS_QM_NCSIZE_THRESHOLD 5000 #define XFS_QM_HASHSIZE_LOW (NBPP / sizeof(xfs_dqhash_t))
#define XFS_QM_HASHSIZE_LOW 32 #define XFS_QM_HASHSIZE_HIGH ((NBPP * 4) / sizeof(xfs_dqhash_t))
#define XFS_QM_HASHSIZE_HIGH 64
/* /*
* We output a cmn_err when quotachecking a quota file with more than * We output a cmn_err when quotachecking a quota file with more than
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment