Whamcloud - gitweb
Branch HEAD
authorbobijam <bobijam>
Wed, 29 Apr 2009 02:07:28 +0000 (02:07 +0000)
committerbobijam <bobijam>
Wed, 29 Apr 2009 02:07:28 +0000 (02:07 +0000)
b=18690
o=adilger
i=johann
i=zhenyu.xu (bobijam)

Increase some hash table sizes.

lustre/include/class_hash.h
lustre/lov/lov_obd.c
lustre/obdclass/obd_config.c
lustre/ptlrpc/connection.c
lustre/quota/quota_context.c

index 37bd8d2..613060d 100644 (file)
@@ -223,8 +223,22 @@ __lustre_hash_bucket_del(lustre_hash_t *lh,
         return lh_put(lh, hnode);
 }
 
+/* Some hash init argument constants */
+#define HASH_POOLS_CUR_BITS 3
+#define HASH_POOLS_MAX_BITS 7
+#define HASH_UUID_CUR_BITS 7
+#define HASH_UUID_MAX_BITS 12
+#define HASH_NID_CUR_BITS 7
+#define HASH_NID_MAX_BITS 12
+#define HASH_NID_STATS_CUR_BITS 7
+#define HASH_NID_STATS_MAX_BITS 12
+#define HASH_LQS_CUR_BITS 7
+#define HASH_LQS_MAX_BITS 12
+#define HASH_CONN_CUR_BITS 5
+#define HASH_CONN_MAX_BITS 15
+
 /* Hash init/cleanup functions */
-lustre_hash_t *lustre_hash_init(char *name, unsigned int cur_bits, 
+lustre_hash_t *lustre_hash_init(char *name, unsigned int cur_bits,
                                 unsigned int max_bits,
                                 lustre_hash_ops_t *ops, int flags);
 void lustre_hash_exit(lustre_hash_t *lh);
@@ -250,9 +264,9 @@ void lustre_hash_for_each_empty(lustre_hash_t *lh, lh_for_each_cb, void *data);
 void lustre_hash_for_each_key(lustre_hash_t *lh, void *key,
                               lh_for_each_cb, void *data);
 
-/* 
+/*
  * Rehash - Theta is calculated to be the average chained
- * hash depth assuming a perfectly uniform hash funcion. 
+ * hash depth assuming a perfectly uniform hash funcion.
  */
 int lustre_hash_rehash(lustre_hash_t *lh, int bits);
 void lustre_hash_rehash_key(lustre_hash_t *lh, void *old_key,
@@ -270,7 +284,7 @@ static inline int __lustre_hash_theta_int(int theta)
 /* Return a fractional value between 0 and 999 */
 static inline int __lustre_hash_theta_frac(int theta)
 {
-        return ((theta * 1000) >> LH_THETA_BITS) - 
+        return ((theta * 1000) >> LH_THETA_BITS) -
                (__lustre_hash_theta_int(theta) * 1000);
 }
 
index d0b0d77..49dee08 100644 (file)
@@ -813,7 +813,9 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                 RETURN(-ENOMEM);
         cfs_waitq_init(&lov->lov_qos.lq_statfs_waitq);
 
-        lov->lov_pools_hash_body = lustre_hash_init("POOLS", 7, 7,
+        lov->lov_pools_hash_body = lustre_hash_init("POOLS",
+                                                    HASH_POOLS_CUR_BITS,
+                                                    HASH_POOLS_MAX_BITS,
                                                     &pool_hash_operations, 0);
         CFS_INIT_LIST_HEAD(&lov->lov_pool_list);
         lov->lov_pool_count = 0;
@@ -965,8 +967,8 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
 
                 rc = class_process_proc_param(PARAM_LOV, lvars.obd_vars,
                                               lcfg, obd);
-               if (rc > 0)
-                       rc = 0;
+                if (rc > 0)
+                        rc = 0;
                 GOTO(out, rc);
         }
         case LCFG_POOL_NEW:
index f5d7316..af30f03 100644 (file)
@@ -354,19 +354,25 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
         spin_unlock(&obd->obd_dev_lock);
 
         /* create an uuid-export lustre hash */
-        obd->obd_uuid_hash = lustre_hash_init("UUID_HASH", 7, 7,
+        obd->obd_uuid_hash = lustre_hash_init("UUID_HASH",
+                                              HASH_UUID_CUR_BITS,
+                                              HASH_UUID_MAX_BITS,
                                               &uuid_hash_ops, 0);
         if (!obd->obd_uuid_hash)
                 GOTO(err_hash, err = -ENOMEM);
+
         /* create a nid-export lustre hash */
-        obd->obd_nid_hash = lustre_hash_init("NID_HASH", 7, 7,
+        obd->obd_nid_hash = lustre_hash_init("NID_HASH",
+                                             HASH_NID_CUR_BITS,
+                                             HASH_NID_MAX_BITS,
                                              &nid_hash_ops, 0);
         if (!obd->obd_nid_hash)
                 GOTO(err_hash, err = -ENOMEM);
+
         /* create a nid-stats lustre hash */
-        obd->obd_nid_stats_hash = lustre_hash_init("NID_STATS", 7, 7,
+        obd->obd_nid_stats_hash = lustre_hash_init("NID_STATS",
+                                                   HASH_NID_STATS_CUR_BITS,
+                                                   HASH_NID_STATS_MAX_BITS,
                                                    &nid_stat_hash_ops, 0);
         if (!obd->obd_nid_stats_hash)
                 GOTO(err_hash, err = -ENOMEM);
@@ -1016,7 +1022,7 @@ int class_process_proc_param(char *prefix, struct lprocfs_vars *lvars,
                             RETURN(-ENOSYS);
                         CERROR("%s: unknown param %s\n",
                                (char *)lustre_cfg_string(lcfg, 0), key);
-                        /* rc = -EINVAL;       continue parsing other params */
+                        /* rc = -EINVAL;        continue parsing other params */
                         skip++;
                 } else if (rc < 0) {
                         CERROR("writing proc entry %s err %d\n",
@@ -1132,7 +1138,7 @@ static int class_config_llog_handler(struct llog_handle * handle,
                 {
                         char *typename = lustre_cfg_string(lcfg, 1);
                         char *index = lustre_cfg_string(lcfg, 2);
-                        
+
                         if ((lcfg->lcfg_command == LCFG_ATTACH && typename &&
                              strcmp(typename, "mds") == 0)) {
                                 CWARN("For 1.8 interoperability, rename obd "
index fb86c6c..1a38b4b 100644 (file)
@@ -71,11 +71,11 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
         if (uuid)
                 obd_str2uuid(&conn->c_remote_uuid, uuid->uuid);
 
-        /* 
+        /*
          * Add the newly created conn to the hash, on key collision we
          * lost a racing addition and must destroy our newly allocated
          * connection.  The object which exists in the has will be
-         * returned and may be compared against out object. 
+         * returned and may be compared against out object.
          */
         conn2 = lustre_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
         if (conn != conn2) {
@@ -85,31 +85,31 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
         EXIT;
 out:
         CDEBUG(D_INFO, "conn=%p refcount %d to %s\n",
-               conn, atomic_read(&conn->c_refcount), 
+               conn, atomic_read(&conn->c_refcount),
                libcfs_nid2str(conn->c_peer.nid));
         return conn;
 }
-  
+
 int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 {
         int rc = 0;
         ENTRY;
-  
+
         if (!conn)
                 RETURN(rc);
-  
+
         LASSERT(!hlist_unhashed(&conn->c_hash));
-  
+
         /*
-         * We do not remove connection from hashtable and 
+         * We do not remove connection from hashtable and
          * do not free it even if last caller released ref,
          * as we want to have it cached for the case it is
          * needed again.
          *
          * Deallocating it and later creating new connection
          * again would be wastful. This way we also avoid
-         * expensive locking to protect things from get/put 
-         * race when found cached connection is freed by 
+         * expensive locking to protect things from get/put
+         * race when found cached connection is freed by
          * ptlrpc_connection_put().
          *
          * It will be freed later in module unload time,
@@ -125,7 +125,7 @@ int ptlrpc_connection_put(struct ptlrpc_connection *conn)
 
         RETURN(rc);
 }
-  
+
 struct ptlrpc_connection *
 ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 {
@@ -138,19 +138,21 @@ ptlrpc_connection_addref(struct ptlrpc_connection *conn)
 
         RETURN(conn);
 }
-  
+
 int ptlrpc_connection_init(void)
 {
         ENTRY;
 
-        conn_hash = lustre_hash_init("CONN_HASH", 5, 15,
+        conn_hash = lustre_hash_init("CONN_HASH",
+                                     HASH_CONN_CUR_BITS,
+                                     HASH_CONN_MAX_BITS,
                                      &conn_hash_ops, LH_REHASH);
         if (!conn_hash)
                 RETURN(-ENOMEM);
-  
+
         RETURN(0);
 }
-  
+
 void ptlrpc_connection_fini(void) {
         ENTRY;
         lustre_hash_exit(conn_hash);
@@ -216,13 +218,13 @@ conn_exit(struct hlist_node *hnode)
         struct ptlrpc_connection *conn;
 
         conn = hlist_entry(hnode, struct ptlrpc_connection, c_hash);
-        /* 
+        /*
          * Nothing should be left. Connection user put it and
          * connection also was deleted from table by this time
          * so we should have 0 refs.
          */
-        LASSERTF(atomic_read(&conn->c_refcount) == 0, 
-                 "Busy connection with %d refs\n", 
+        LASSERTF(atomic_read(&conn->c_refcount) == 0,
+                 "Busy connection with %d refs\n",
                  atomic_read(&conn->c_refcount));
         OBD_FREE_PTR(conn);
 }
index 537f101..258b809 100644 (file)
@@ -1158,7 +1158,9 @@ qctxt_init(struct obd_device *obd, dqacq_handler_t handler)
         qctxt->lqc_sync_blk = 0;
         spin_unlock(&qctxt->lqc_lock);
 
-        qctxt->lqc_lqs_hash = lustre_hash_init("LQS_HASH", 7, 7,
+        qctxt->lqc_lqs_hash = lustre_hash_init("LQS_HASH",
+                                               HASH_LQS_CUR_BITS,
+                                               HASH_LQS_MAX_BITS,
                                                &lqs_hash_ops, 0);
         if (!qctxt->lqc_lqs_hash) {
                 CERROR("initialize hash lqs for %s error!\n", obd->obd_name);
@@ -1387,7 +1389,7 @@ lqs_compare(void *key, struct hlist_node *hnode)
 static void *
 lqs_get(struct hlist_node *hnode)
 {
-        struct lustre_qunit_size *q = 
+        struct lustre_qunit_size *q =
             hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
         ENTRY;
 
@@ -1401,7 +1403,7 @@ lqs_get(struct hlist_node *hnode)
 static void *
 lqs_put(struct hlist_node *hnode)
 {
-        struct lustre_qunit_size *q = 
+        struct lustre_qunit_size *q =
             hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
         ENTRY;
 
@@ -1420,12 +1422,12 @@ lqs_exit(struct hlist_node *hnode)
         ENTRY;
 
         q = hlist_entry(hnode, struct lustre_qunit_size, lqs_hash);
-        /* 
+        /*
          * Nothing should be left. User of lqs put it and
          * lqs also was deleted from table by this time
          * so we should have 0 refs.
          */
-        LASSERTF(atomic_read(&q->lqs_refcount) == 0, 
+        LASSERTF(atomic_read(&q->lqs_refcount) == 0,
                  "Busy lqs %p with %d refs\n", q,
                  atomic_read(&q->lqs_refcount));
         OBD_FREE_PTR(q);