Whamcloud - gitweb
b=21846 add a test for testing rehash in sanity.sh
authorFan Yong <Yong.Fan@sun.com>
Fri, 6 Aug 2010 02:22:50 +0000 (06:22 +0400)
committerMikhail Pershin <tappro@sun.com>
Fri, 13 Aug 2010 05:18:16 +0000 (09:18 +0400)
1. enable rehash on lqs
2. if long is 64bit, __fls() is wrong. Fix it.

i=landen
i=tappro

libcfs/include/libcfs/user-bitops.h
lustre/include/obd.h
lustre/obdclass/lprocfs_status.c
lustre/quota/quota_context.c
lustre/tests/cfg/local.sh
lustre/tests/sanity-quota.sh
lustre/tests/test-framework.sh

index 97eeaf9..4ce7bdf 100644 (file)
@@ -84,11 +84,11 @@ static __inline__ unsigned long __cfs_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
 
index 2c7da99..32e35be 100644 (file)
@@ -495,6 +495,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;
index f310c6d..ad145c8 100644 (file)
@@ -2128,6 +2128,11 @@ int lprocfs_obd_rd_hash(char *page, char **start, off_t off,
         c += cfs_hash_debug_str(obd->obd_uuid_hash, page + c, count - c);
         c += cfs_hash_debug_str(obd->obd_nid_hash, page + c, count - c);
         c += cfs_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 += cfs_hash_debug_str(obd->u.obt.obt_qctxt.lqc_lqs_hash,
+                                        page + c, count - c);
+#endif
 
         return c;
 }
index 5a1ebc2..f143ae6 100644 (file)
 #include <lprocfs_status.h>
 #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 cfs_hash_ops_t lqs_hash_ops;
@@ -1267,7 +1271,7 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
         cfs_spin_unlock(&qctxt->lqc_lock);
 
         qctxt->lqc_lqs_hash = cfs_hash_create("LQS_HASH",
-                                              HASH_LQS_CUR_BITS,
+                                              hash_lqs_cur_bits,
                                               HASH_LQS_MAX_BITS,
                                               &lqs_hash_ops, CFS_HASH_REHASH);
         if (!qctxt->lqc_lqs_hash) {
index 7b013ad..a00f8fb 100644 (file)
@@ -53,6 +53,7 @@ SUBSYSTEM=${SUBSYSTEM:- 0xffb7e3ff}
 ENABLE_QUOTA=${ENABLE_QUOTA:-""}
 QUOTA_TYPE="ug3"
 QUOTA_USERS=${QUOTA_USERS:-"quota_usr quota_2usr sanityusr sanityusr1"}
+LQUOTAOPTS=${LQUOTAOPTS:-"hash_lqs_cur_bits=3"}
 
 MKFSOPT=""
 [ "x$MDSJOURNALSIZE" != "x" ] &&
index 45c830c..1f6e328 100644 (file)
@@ -44,6 +44,11 @@ BUNIT_SZ=${BUNIT_SZ:-1024}   # min block quota unit(kB)
 IUNIT_SZ=${IUNIT_SZ:-10}       # min inode quota unit
 MAX_DQ_TIME=604800
 MAX_IQ_TIME=604800
+SANITY_QUOTA_USERS="quota15_1 quota15_2 quota15_3 quota15_4 quota15_5 quota15_6 \
+                    quota15_7 quota15_8 quota15_9 quota15_10 quota15_11 quota15_12 \
+                    quota15_13 quota15_14 quota15_15 quota15_16 quota15_17 quota15_18 \
+                    quota15_19 quota15_20 quota15_21 quota15_22 quota15_23 quota15_24 \
+                    quota15_25 quota15_26 quota15_27 quota15_28 quota15_29 quota15_30"
 
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
@@ -2228,6 +2233,80 @@ test_31() {
 }
 run_test_with_stat 31 "test duplicate quota releases ==="
 
+# check hash_cur_bits
+check_quota_hash_cur_bits() {
+        local bits=$1
+
+        # 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 $SINGLEMDS "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() {
+        # 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 $SINGLEMDS "lctl get_param mdt.${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()
+{
+        # reset system so that quota_hash_cur_bits==3
+        echo "Reset system ..."
+        local LMR_orig=$LOAD_MODULES_REMOTE
+        LOAD_MODULES_REMOTE=true
+        cleanup_and_setup_lustre
+        LOAD_MODULES_REMOTE=$LMR_orig
+
+        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) =========================================="
+
 # turn off quota
 quota_fini()
 {
index c2300ff..194cbf3 100644 (file)
@@ -329,7 +329,7 @@ load_modules_local() {
     load_module obdclass/obdclass
     load_module ptlrpc/ptlrpc
     load_module ptlrpc/gss/ptlrpc_gss
-    [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota
+    [ "$USE_QUOTA" = "yes" -a "$LQUOTA" != "no" ] && load_module quota/lquota $LQUOTAOPTS
     load_module fld/fld
     load_module fid/fid
     load_module lmv/lmv