From: bobijam Date: Tue, 17 Mar 2009 02:35:22 +0000 (+0000) Subject: Branch b1_8 X-Git-Tag: v1_8_0_110~179 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=6618f2b47d4292af0e1d3a1624945d738db84978;p=fs%2Flustre-release.git Branch b1_8 o=adilger i=johann i=zhenyu.xu (bobijam) Increase some hash table sizes. --- diff --git a/lustre/include/class_hash.h b/lustre/include/class_hash.h index 980e784..495b979 100644 --- a/lustre/include/class_hash.h +++ b/lustre/include/class_hash.h @@ -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); } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 276de7d..83ebeec 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -874,7 +874,9 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf) 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; @@ -2921,7 +2923,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen, int stripe; LASSERT(*vallen == sizeof(__u64)); - stripe = lov_stripe_number(lsm, *offset); + stripe = lov_stripe_number(lsm, *offset); loi = lsm->lsm_oinfo[stripe]; tgt = lov->lov_tgts[loi->loi_ost_idx]; if (!tgt || !tgt->ltd_active) @@ -3050,7 +3052,7 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, __u32 ssize = lsm->lsm_stripe_size; if (cmd & OBD_CALC_STRIPE_RPC_ALIGN) - ssize = ssize > PTLRPC_MAX_BRW_SIZE ? + ssize = ssize > PTLRPC_MAX_BRW_SIZE ? PTLRPC_MAX_BRW_SIZE : ssize; start = *offset; @@ -3059,11 +3061,11 @@ static int lov_extent_calc(struct obd_export *exp, struct lov_stripe_md *lsm, CDEBUG(D_DLMTRACE, "offset "LPU64", stripe %u, start "LPU64 ", end "LPU64"\n", *offset, ssize, start, start + ssize - 1); - if (cmd & OBD_CALC_STRIPE_END) + if (cmd & OBD_CALC_STRIPE_END) *offset = start + ssize - 1; else if (cmd & OBD_CALC_STRIPE_START) *offset = start; - else + else LBUG(); RETURN(0); diff --git a/lustre/obdclass/obd_config.c b/lustre/obdclass/obd_config.c index d30b84c..fd2d3b4 100644 --- a/lustre/obdclass/obd_config.c +++ b/lustre/obdclass/obd_config.c @@ -305,19 +305,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); @@ -812,7 +818,7 @@ int class_process_config(struct lustre_cfg *lcfg) ldlm_timeout = max(lcfg->lcfg_num, 1U); if (ldlm_timeout >= obd_timeout) ldlm_timeout = max(obd_timeout / 3, 1U); - + GOTO(out, err = 0); } case LCFG_SET_UPCALL: { diff --git a/lustre/ptlrpc/connection.c b/lustre/ptlrpc/connection.c index fb86c6c..1a38b4b 100644 --- a/lustre/ptlrpc/connection.c +++ b/lustre/ptlrpc/connection.c @@ -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); } diff --git a/lustre/quota/quota_context.c b/lustre/quota/quota_context.c index 0d3f33c..c3065ed 100644 --- a/lustre/quota/quota_context.c +++ b/lustre/quota/quota_context.c @@ -1145,7 +1145,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); @@ -1365,7 +1367,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; @@ -1379,7 +1381,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; @@ -1398,12 +1400,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);