提交 6b3f6b5b 编写于 作者: N Nathan Scott

[XFS] Rework the dquot hash sizing heuristics.

SGI-PV: 943123
SGI-Modid: xfs-linux:xfs-kern:24012a
Signed-off-by: NNathan Scott <nathans@sgi.com>
上级 1f730e3b
......@@ -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))
......
......@@ -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);
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册