Skip to content

Commit

Permalink
[XFS] Rework the dquot hash sizing heuristics.
Browse files Browse the repository at this point in the history
SGI-PV: 943123
SGI-Modid: xfs-linux:xfs-kern:24012a

Signed-off-by: Nathan Scott <nathans@sgi.com>
  • Loading branch information
Nathan Scott committed Nov 2, 2005
1 parent 1f730e3 commit 6b3f6b5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
14 changes: 1 addition & 13 deletions fs/xfs/linux-2.6/xfs_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
31 changes: 16 additions & 15 deletions fs/xfs/quota/xfs_qm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
6 changes: 3 additions & 3 deletions fs/xfs/quota/xfs_qm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 6b3f6b5

Please sign in to comment.