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);
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,
/* 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);
}
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;
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)
__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;
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);
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);
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: {
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) {
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,
RETURN(rc);
}
-
+
struct ptlrpc_connection *
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);
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);
}
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);
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;
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;
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);