From 35cb48bae8bc59f4909168050f5608960a3ff788 Mon Sep 17 00:00:00 2001 From: Landen Date: Tue, 18 May 2010 19:23:12 +0800 Subject: [PATCH] b=21846 add a test for testing rehash in sanity.sh Except this, this patch does: 1. enable rehash on lqs 2. if long is 64bit, __fls() is wrong. Fix it. i=andreas.dilger i=johann --- lnet/include/libcfs/user-bitops.h | 10 +++--- lustre/ChangeLog | 4 +-- lustre/include/obd.h | 1 + lustre/obdclass/lprocfs_status.c | 5 +++ lustre/quota/quota_context.c | 10 ++++-- lustre/tests/cfg/local.sh | 1 + lustre/tests/sanity-quota.sh | 70 +++++++++++++++++++++++++++++++++++++++ lustre/tests/test-framework.sh | 2 +- 8 files changed, 92 insertions(+), 11 deletions(-) diff --git a/lnet/include/libcfs/user-bitops.h b/lnet/include/libcfs/user-bitops.h index 641eb67..7c8f787 100644 --- a/lnet/include/libcfs/user-bitops.h +++ b/lnet/include/libcfs/user-bitops.h @@ -84,11 +84,11 @@ static __inline__ unsigned long __fls(long data) return 0; #if BITS_PER_LONG == 64 - pos += 32; - - if ((data & 0xFFFFFFFF) == 0) { - data <<= 32; - pos -= 32; + /* If any bit of the high 32 bits are set, shift the high + * 32 bits down and pretend like it is a 32-bit value. */ + if ((data & 0xFFFFFFFF00000000llu)) { + data >>= 32; + pos += 32; } #endif diff --git a/lustre/ChangeLog b/lustre/ChangeLog index 9edc0e0..c8921da 100644 --- a/lustre/ChangeLog +++ b/lustre/ChangeLog @@ -602,8 +602,8 @@ Details : fix race during quota release on the slave. Severity : enhancement Bugzilla : 18690 Description: smaller hash bucket sizes, cleanups -Details : increase hash table sizes and enabled rehashing for pools, uuid, - nid & per-nid stats. +Details : increase hash table sizes and enabled rehashing for pools, quota, + uuid, nid & per-nid stats. Severity : enhancement Bugzilla : 19673 diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 638d7c9..c3b4103 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -562,6 +562,7 @@ struct client_obd { #define CL_NOT_QUOTACHECKED 1 /* client->cl_qchk_stat init value */ struct mgs_obd { + struct obd_device_target mgs_obt; struct ptlrpc_service *mgs_service; struct vfsmount *mgs_vfsmnt; struct super_block *mgs_sb; diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 15d824a..2692490 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -2122,6 +2122,11 @@ int lprocfs_obd_rd_hash(char *page, char **start, off_t off, c += lustre_hash_debug_str(obd->obd_uuid_hash, page + c, count - c); c += lustre_hash_debug_str(obd->obd_nid_hash, page + c, count - c); c += lustre_hash_debug_str(obd->obd_nid_stats_hash, page+c, count-c); +#ifdef HAVE_QUOTA_SUPPORT + if (obd->u.obt.obt_qctxt.lqc_lqs_hash) + c += lustre_hash_debug_str(obd->u.obt.obt_qctxt.lqc_lqs_hash, + page + c, count - c); +#endif return c; } diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index ea45293..ae306fd 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -61,6 +61,10 @@ #include #include "quota_internal.h" +static int hash_lqs_cur_bits = HASH_LQS_CUR_BITS; +CFS_MODULE_PARM(hash_lqs_cur_bits, "i", int, 0444, + "the current bits of lqs hash"); + #ifdef HAVE_QUOTA_SUPPORT static lustre_hash_ops_t lqs_hash_ops; @@ -1256,9 +1260,9 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler) spin_unlock(&qctxt->lqc_lock); qctxt->lqc_lqs_hash = lustre_hash_init("LQS_HASH", - HASH_LQS_CUR_BITS, - HASH_LQS_CUR_BITS, - &lqs_hash_ops, 0); + hash_lqs_cur_bits, + HASH_LQS_MAX_BITS, + &lqs_hash_ops, LH_REHASH); if (!qctxt->lqc_lqs_hash) CERROR("%s: initialize hash lqs failed\n", obd->obd_name); diff --git a/lustre/tests/cfg/local.sh b/lustre/tests/cfg/local.sh index 94232fd..a4f5512 100644 --- a/lustre/tests/cfg/local.sh +++ b/lustre/tests/cfg/local.sh @@ -44,6 +44,7 @@ L_GETGROUPS=${L_GETGROUPS:-`do_facet mds which l_getgroups || echo`} ENABLE_QUOTA=${ENABLE_QUOTA:-""} QUOTA_TYPE=${QUOTA_TYPE:-"ug3"} QUOTA_USERS=${QUOTA_USERS:-"quota_usr quota_2usr sanityusr sanityusr1"} +LQUOTAOPTS=${LQUOTAOPTS:-"hash_lqs_cur_bits=3"} MKFSOPT="" [ "x$MDSJOURNALSIZE" != "x" ] && diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 19c055e..08a9a7b 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -2236,6 +2236,76 @@ test_31() { } run_test_with_stat 31 "test duplicate quota releases ===" +# check hash_cur_bits +check_quota_hash_cur_bits() { + local bits=$1 + local ostcount=`lctl get_param -n lov.$LOVNAME.numobd` + + # check quota_hash_cur_bits on all obdfilters + for num in `seq $OSTCOUNT`; do + cb=`do_facet ost$num "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"` + if [ $cb -gt $bits ]; then + echo "hash_lqs_cur_bits of ost$num is too large(cur_bits=$cb)" + return 1; + fi + done + # check quota_hash_cur_bits on mds + cb=`do_facet mds "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"` + if [ $cb -gt $bits ]; then + echo "hash_lqs_cur_bits of mds is too large(cur_bits=$cb)" + return 1; + fi + return 0; +} + +# check lqs hash +check_lqs_hash() { + local ostcount=`lctl get_param -n lov.$LOVNAME.numobd` + + # check distribution of all obdfilters + for num in `seq $OSTCOUNT`; do + do_facet ost$num "lctl get_param obdfilter.${FSNAME}-OST*.hash_stats | grep LQS_HASH" | while read line; do + rehash_count=`echo $line | awk '{print $9}'` + if [ $rehash_count -eq 0 ]; then + echo -e "ost$num:\n $line" + error "Rehearsh didn't happen" + fi + done + done + # check distribution of mds + do_facet mds "lctl get_param mds.${FSNAME}-MDT*.hash_stats | grep LQS_HASH" | while read line; do + rehash_count=`echo $line | awk '{print $9}'` + if [ $rehash_count -eq 0 ]; then + echo -e "mdt:\n $line" + error "Rehearsh didn't happen" + fi + done +} + +test_32() +{ + for user in $SANITY_QUOTA_USERS; do + check_runas_id_ret $user quota_usr "runas -u $user -g quota_usr" >/dev/null 2>/dev/null || \ + missing_users="$missing_users $user" + done + [ -n "$missing_users" ] && { skip_env "the following users are missing: $missing_users" ; return 0 ; } + check_quota_hash_cur_bits 3 || { skip_env "hash_lqs_cur_bits isn't set properly"; return 0;} + + $LFS quotaoff -ug $DIR + $LFS quotacheck -ug $DIR + + for user in $SANITY_QUOTA_USERS; do + $LFS setquota -u $user --block-hardlimit 1048576 $DIR + done + + check_lqs_hash + + for user in $SANITY_QUOTA_USERS; do + resetquota -u $user + done +} +run_test 32 "check lqs hash(bug 21846) ==========================================" + # # run 98 at the end because of reformatall # diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 1913a05..c16c4b6 100644 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -274,7 +274,7 @@ load_modules_local() { load_module lvfs/lvfs load_module obdclass/obdclass load_module ptlrpc/ptlrpc - [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota + [ "$USE_QUOTA" = "yes" ] && load_module quota/lquota $LQUOTAOPTS load_module mdc/mdc load_module osc/osc load_module lov/lov -- 1.8.3.1