net: also hash remote dentries

This commit is contained in:
Thomas Schoebel-Theuer 2020-09-17 18:06:09 +02:00
parent ec962406c6
commit a93cfb06f4
2 changed files with 9 additions and 0 deletions

View File

@ -100,6 +100,7 @@ const struct meta mars_dent_meta[] = {
META_INI(d_corr_A, struct mars_dent, FIELD_INT), META_INI(d_corr_A, struct mars_dent, FIELD_INT),
META_INI(d_corr_B, struct mars_dent, FIELD_INT), META_INI(d_corr_B, struct mars_dent, FIELD_INT),
META_INI(d_proto, struct mars_dent, FIELD_INT), META_INI(d_proto, struct mars_dent, FIELD_INT),
META_INI(d_unordered, struct mars_dent, FIELD_INT),
META_INI_SUB(new_stat,struct mars_dent, mars_kstat_meta), META_INI_SUB(new_stat,struct mars_dent, mars_kstat_meta),
META_INI_SUB(old_stat,struct mars_dent, mars_kstat_meta), META_INI_SUB(old_stat,struct mars_dent, mars_kstat_meta),
META_INI(new_link, struct mars_dent, FIELD_STRING), META_INI(new_link, struct mars_dent, FIELD_STRING),

View File

@ -99,6 +99,8 @@ int mars_recv_dent_list(struct mars_global *global, struct mars_socket *sock)
anchor = &global->dent_anchor; anchor = &global->dent_anchor;
for (;;) { for (;;) {
struct mars_dent *dent = brick_zmem_alloc(sizeof(struct mars_dent)); struct mars_dent *dent = brick_zmem_alloc(sizeof(struct mars_dent));
struct list_head *hash_anchor;
unsigned int hash;
if (!dent) if (!dent)
return -ENOMEM; return -ENOMEM;
@ -119,6 +121,12 @@ int mars_recv_dent_list(struct mars_global *global, struct mars_socket *sock)
sock->s_common_proto_level = min(dent->d_proto, MARS_PROTO_LEVEL); sock->s_common_proto_level = min(dent->d_proto, MARS_PROTO_LEVEL);
} }
list_add_tail(&dent->dent_link, anchor); list_add_tail(&dent->dent_link, anchor);
if (!dent->d_path || dent->d_unordered)
continue;
hash = dent_hash(dent->d_path, strlen(dent->d_path));
dent->d_hash = hash;
hash_anchor = DENT_HASH_ANCHOR(global, hash);
list_add_tail(&dent->dent_hash_link, hash_anchor);
} }
done: done:
up_write(&global->dent_mutex); up_write(&global->dent_mutex);