mirror of
https://github.com/schoebel/mars
synced 2025-01-12 09:40:07 +00:00
infra: introduce hash_table and hash_link
This commit is contained in:
parent
b1861be0a9
commit
ee08ab587e
@ -385,10 +385,13 @@ int handler_thread(void *data)
|
||||
bool ok = mars_get_socket(sock);
|
||||
unsigned long statist_jiffies = jiffies;
|
||||
int debug_nr;
|
||||
int i;
|
||||
int status = -EINVAL;
|
||||
|
||||
init_rwsem(&handler_global.dent_mutex);
|
||||
init_rwsem(&handler_global.brick_mutex);
|
||||
for (i = 0; i < MARS_GLOBAL_HASH; i++)
|
||||
INIT_LIST_HEAD(&handler_global.dent_hash_anchor[i]);
|
||||
|
||||
MARS_DBG("#%d --------------- handler_thread starting on socket %p\n", sock->s_debug_nr, sock);
|
||||
if (!ok)
|
||||
|
@ -2255,9 +2255,12 @@ int peer_thread(void *data)
|
||||
struct mars_cmd cmd = {
|
||||
.cmd_int1 = peer->maxdepth,
|
||||
};
|
||||
int i;
|
||||
|
||||
init_rwsem(&tmp_global.dent_mutex);
|
||||
init_rwsem(&tmp_global.brick_mutex);
|
||||
for (i = 0; i < MARS_GLOBAL_HASH; i++)
|
||||
INIT_LIST_HEAD(&tmp_global.dent_hash_anchor[i]);
|
||||
|
||||
if (likely(repeated)) {
|
||||
report_peer_connection(peer_pairs, !peer->do_communicate);
|
||||
@ -5911,10 +5914,13 @@ static int _main_thread(void *data)
|
||||
{
|
||||
long long last_rollover = jiffies;
|
||||
char *id = my_id();
|
||||
int i;
|
||||
int status = 0;
|
||||
|
||||
init_rwsem(&_global.dent_mutex);
|
||||
init_rwsem(&_global.brick_mutex);
|
||||
for (i = 0; i < MARS_GLOBAL_HASH; i++)
|
||||
INIT_LIST_HEAD(&_global.dent_hash_anchor[i]);
|
||||
|
||||
mars_global = &_global;
|
||||
|
||||
|
@ -68,6 +68,7 @@ extern char *my_id(void);
|
||||
|
||||
#define MARS_DENT(TYPE) \
|
||||
struct list_head dent_link; \
|
||||
struct list_head dent_hash_link; \
|
||||
struct list_head dent_quick_link; \
|
||||
struct list_head brick_list; \
|
||||
struct TYPE *d_parent; \
|
||||
@ -103,6 +104,8 @@ struct mars_dent {
|
||||
extern const struct meta mars_kstat_meta[];
|
||||
extern const struct meta mars_dent_meta[];
|
||||
|
||||
#define MARS_GLOBAL_HASH 32
|
||||
|
||||
struct mars_global {
|
||||
struct rw_semaphore dent_mutex;
|
||||
struct rw_semaphore brick_mutex;
|
||||
@ -111,6 +114,7 @@ struct mars_global {
|
||||
struct list_head dent_quick_anchor;
|
||||
struct list_head brick_anchor;
|
||||
wait_queue_head_t main_event;
|
||||
struct list_head dent_hash_anchor[MARS_GLOBAL_HASH];
|
||||
int global_version;
|
||||
int deleted_my_border;
|
||||
int old_deleted_my_border;
|
||||
|
@ -1339,6 +1339,7 @@ int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
|
||||
newpath = NULL;
|
||||
|
||||
INIT_LIST_HEAD(&dent->dent_link);
|
||||
INIT_LIST_HEAD(&dent->dent_hash_link);
|
||||
INIT_LIST_HEAD(&dent->dent_quick_link);
|
||||
INIT_LIST_HEAD(&dent->brick_list);
|
||||
|
||||
@ -1691,6 +1692,7 @@ void mars_kill_dent(struct mars_global *global, struct mars_dent *dent)
|
||||
if (global)
|
||||
down_write(&global->dent_mutex);
|
||||
list_del_init(&dent->dent_link);
|
||||
list_del_init(&dent->dent_hash_link);
|
||||
list_del_init(&dent->dent_quick_link);
|
||||
if (global)
|
||||
up_write(&global->dent_mutex);
|
||||
@ -1708,6 +1710,7 @@ void mars_free_dent(struct mars_global *global, struct mars_dent *dent)
|
||||
mars_kill_dent(global, dent);
|
||||
|
||||
CHECK_HEAD_EMPTY(&dent->dent_link);
|
||||
CHECK_HEAD_EMPTY(&dent->dent_hash_link);
|
||||
CHECK_HEAD_EMPTY(&dent->dent_quick_link);
|
||||
CHECK_HEAD_EMPTY(&dent->brick_list);
|
||||
|
||||
@ -1753,6 +1756,7 @@ void mars_free_dent_all(struct mars_global *global, struct list_head *anchor)
|
||||
|
||||
dent = container_of(tmp_list.prev, struct mars_dent, dent_link);
|
||||
list_del_init(&dent->dent_link);
|
||||
list_del_init(&dent->dent_hash_link);
|
||||
list_del_init(&dent->dent_quick_link);
|
||||
MARS_IO("freeing dent %p\n", dent);
|
||||
mars_free_dent(global, dent);
|
||||
|
@ -95,6 +95,7 @@ int mars_recv_dent_list(struct mars_socket *sock, struct list_head *anchor)
|
||||
//MARS_IO("\n");
|
||||
|
||||
INIT_LIST_HEAD(&dent->dent_link);
|
||||
INIT_LIST_HEAD(&dent->dent_hash_link);
|
||||
INIT_LIST_HEAD(&dent->dent_quick_link);
|
||||
INIT_LIST_HEAD(&dent->brick_list);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user