From d24dce9f96591cf63d7c1ab22c36b9aed16a4ef2 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Thu, 28 Jul 2011 21:00:09 -0700 Subject: [PATCH 1/1] LU-550 incorrect quota hash function Quota code uses 'uid' or '(1 << 32) + gid' as the hash key, however, the quota hash function lqs_hash() always try to interpret such a unsigned long long key as a 'quota_adjust_qunit' struct, then calculate the hash value by quota_adjust_qunit->qaq_id. Signed-off-by: Niu Yawei Change-Id: I48dc7f276eb97f34b22097b4edc529d5f76acf37 Reviewed-on: http://review.whamcloud.com/1162 Tested-by: Hudson Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Johann Lombardi Reviewed-by: Oleg Drokin --- lustre/quota/quota_context.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index fbed203..181474b 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -1577,13 +1577,13 @@ void build_lqs(struct obd_device *obd) static unsigned lqs_hash(cfs_hash_t *hs, const void *key, unsigned mask) { - struct quota_adjust_qunit *lqs_key; + unsigned long long id; unsigned hash; ENTRY; LASSERT(key); - lqs_key = (struct quota_adjust_qunit *)key; - hash = (QAQ_IS_GRP(lqs_key) ? 5381 : 5387) * lqs_key->qaq_id; + id = *((unsigned long long *)key); + hash = (LQS_KEY_GRP(id) ? 5381 : 5387) * (unsigned)LQS_KEY_ID(id); RETURN(hash & mask); } -- 1.8.3.1