infra: prepare dent quick_list speedup

This commit is contained in:
Thomas Schoebel-Theuer 2019-03-12 14:25:04 +01:00
parent 0c1d47b955
commit 930d33e338
4 changed files with 9 additions and 0 deletions

View File

@ -2244,6 +2244,7 @@ int peer_thread(void *data)
while (peer_thead_should_run(peer)) {
struct mars_global tmp_global = {
.dent_anchor = LIST_HEAD_INIT(tmp_global.dent_anchor),
.dent_quick_anchor = LIST_HEAD_INIT(tmp_global.dent_quick_anchor),
.brick_anchor = LIST_HEAD_INIT(tmp_global.brick_anchor),
.global_power = {
.button = true,
@ -5897,6 +5898,7 @@ static int main_worker(struct mars_global *global, struct mars_dent *dent, bool
static struct mars_global _global = {
.dent_anchor = LIST_HEAD_INIT(_global.dent_anchor),
.dent_quick_anchor = LIST_HEAD_INIT(_global.dent_quick_anchor),
.brick_anchor = LIST_HEAD_INIT(_global.brick_anchor),
.global_power = {
.button = true,

View File

@ -68,6 +68,7 @@ extern char *my_id(void);
#define MARS_DENT(TYPE) \
struct list_head dent_link; \
struct list_head dent_quick_link; \
struct list_head brick_list; \
struct TYPE *d_parent; \
char *d_argv[MARS_ARGV_MAX]; /* for internal use, will be automatically deallocated*/ \
@ -107,6 +108,7 @@ struct mars_global {
struct rw_semaphore brick_mutex;
struct generic_switch global_power;
struct list_head dent_anchor;
struct list_head dent_quick_anchor;
struct list_head brick_anchor;
wait_queue_head_t main_event;
int global_version;

View File

@ -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_quick_link);
INIT_LIST_HEAD(&dent->brick_list);
list_add(&dent->dent_link, start);
@ -1684,6 +1685,7 @@ void mars_free_dent(struct mars_dent *dent)
mars_kill_dent(dent);
CHECK_HEAD_EMPTY(&dent->dent_link);
CHECK_HEAD_EMPTY(&dent->dent_quick_link);
CHECK_HEAD_EMPTY(&dent->brick_list);
for (i = 0; i < MARS_ARGV_MAX; i++) {
@ -1723,8 +1725,10 @@ void mars_free_dent_all(struct mars_global *global, struct list_head *anchor)
MARS_DBG("is_empty=%d\n", list_empty(&tmp_list));
while (!list_empty(&tmp_list)) {
struct mars_dent *dent;
dent = container_of(tmp_list.prev, struct mars_dent, dent_link);
list_del_init(&dent->dent_link);
list_del_init(&dent->dent_quick_link);
MARS_IO("freeing dent %p\n", dent);
mars_free_dent(dent);
}

View File

@ -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_quick_link);
INIT_LIST_HEAD(&dent->brick_list);
status = mars_recv_struct(sock, dent, mars_dent_meta);