mirror of
https://github.com/schoebel/mars
synced 2025-01-19 22:10:47 +00:00
infra: move dent transfer prototypes to strategy
This commit is contained in:
parent
7d55e6f02a
commit
1e5be3d1b9
@ -181,9 +181,6 @@ extern int _mars_recv_cmd(struct mars_socket *msock, struct mars_cmd *cmd, int l
|
|||||||
_mars_recv_cmd(_sock_, _cmd_, __LINE__); \
|
_mars_recv_cmd(_sock_, _cmd_, __LINE__); \
|
||||||
})
|
})
|
||||||
|
|
||||||
extern int mars_send_dent_list(struct mars_socket *msock, struct list_head *anchor);
|
|
||||||
extern int mars_recv_dent_list(struct mars_socket *msock, struct list_head *anchor);
|
|
||||||
|
|
||||||
extern int mars_send_mref(struct mars_socket *msock, struct mref_object *mref, bool cork);
|
extern int mars_send_mref(struct mars_socket *msock, struct mref_object *mref, bool cork);
|
||||||
extern int mars_recv_mref(struct mars_socket *msock, struct mref_object *mref, struct mars_cmd *cmd);
|
extern int mars_recv_mref(struct mars_socket *msock, struct mref_object *mref, struct mars_cmd *cmd);
|
||||||
extern int mars_send_cb(struct mars_socket *msock, struct mref_object *mref, bool cork);
|
extern int mars_send_cb(struct mars_socket *msock, struct mref_object *mref, bool cork);
|
||||||
|
@ -528,7 +528,7 @@ int handler_thread(void *data)
|
|||||||
old_proto_level = sock->s_common_proto_level;
|
old_proto_level = sock->s_common_proto_level;
|
||||||
|
|
||||||
down(&brick->socket_sem);
|
down(&brick->socket_sem);
|
||||||
status = mars_send_dent_list(sock, &handler_global->dent_anchor);
|
status = mars_send_dent_list(handler_global, sock);
|
||||||
up(&brick->socket_sem);
|
up(&brick->socket_sem);
|
||||||
|
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
|
@ -2617,7 +2617,7 @@ int peer_action_dent_list(struct mars_global *tmp_global,
|
|||||||
MARS_DBG("fetching remote dentries from '%s' '%s'\n",
|
MARS_DBG("fetching remote dentries from '%s' '%s'\n",
|
||||||
peer->peer, paths);
|
peer->peer, paths);
|
||||||
|
|
||||||
status = mars_recv_dent_list(&peer->socket, &tmp_global->dent_anchor);
|
status = mars_recv_dent_list(tmp_global, &peer->socket);
|
||||||
if (unlikely(status < 0))
|
if (unlikely(status < 0))
|
||||||
goto free;
|
goto free;
|
||||||
|
|
||||||
|
@ -209,6 +209,12 @@ extern void mars_kill_dent(struct mars_global *global, struct mars_dent *dent);
|
|||||||
extern void mars_free_dent(struct mars_global *global, struct mars_dent *dent);
|
extern void mars_free_dent(struct mars_global *global, struct mars_dent *dent);
|
||||||
extern void mars_free_dent_all(struct mars_global *global, struct list_head *anchor);
|
extern void mars_free_dent_all(struct mars_global *global, struct list_head *anchor);
|
||||||
|
|
||||||
|
/* network transfer of dents */
|
||||||
|
|
||||||
|
struct mars_socket;
|
||||||
|
extern int mars_send_dent_list(struct mars_global *global, struct mars_socket *msock);
|
||||||
|
extern int mars_recv_dent_list(struct mars_global *global, struct mars_socket *msock);
|
||||||
|
|
||||||
// low-level brick instantiation
|
// low-level brick instantiation
|
||||||
|
|
||||||
int mars_connect(struct mars_input *a, struct mars_output *b);
|
int mars_connect(struct mars_input *a, struct mars_output *b);
|
||||||
|
@ -66,12 +66,15 @@ done:
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mars_send_dent_list(struct mars_socket *sock, struct list_head *anchor)
|
int mars_send_dent_list(struct mars_global *global, struct mars_socket *sock)
|
||||||
{
|
{
|
||||||
|
struct list_head *anchor;
|
||||||
struct list_head *tmp;
|
struct list_head *tmp;
|
||||||
struct mars_dent *dent;
|
struct mars_dent *dent;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
|
down_read(&global->dent_mutex);
|
||||||
|
anchor = &global->dent_anchor;
|
||||||
for (tmp = anchor->next; tmp != anchor; tmp = tmp->next) {
|
for (tmp = anchor->next; tmp != anchor; tmp = tmp->next) {
|
||||||
dent = container_of(tmp, struct mars_dent, dent_link);
|
dent = container_of(tmp, struct mars_dent, dent_link);
|
||||||
dent->d_proto = MARS_PROTO_LEVEL;
|
dent->d_proto = MARS_PROTO_LEVEL;
|
||||||
@ -82,15 +85,21 @@ int mars_send_dent_list(struct mars_socket *sock, struct list_head *anchor)
|
|||||||
if (status >= 0) { // send EOR
|
if (status >= 0) { // send EOR
|
||||||
status = mars_send_struct(sock, NULL, mars_dent_meta, false);
|
status = mars_send_struct(sock, NULL, mars_dent_meta, false);
|
||||||
}
|
}
|
||||||
|
up_read(&global->dent_mutex);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mars_send_dent_list);
|
EXPORT_SYMBOL_GPL(mars_send_dent_list);
|
||||||
|
|
||||||
int mars_recv_dent_list(struct mars_socket *sock, struct list_head *anchor)
|
int mars_recv_dent_list(struct mars_global *global, struct mars_socket *sock)
|
||||||
{
|
{
|
||||||
|
struct list_head *anchor;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
down_write(&global->dent_mutex);
|
||||||
|
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));
|
||||||
|
|
||||||
if (!dent)
|
if (!dent)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -112,6 +121,7 @@ int mars_recv_dent_list(struct mars_socket *sock, struct list_head *anchor)
|
|||||||
list_add_tail(&dent->dent_link, anchor);
|
list_add_tail(&dent->dent_link, anchor);
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
up_write(&global->dent_mutex);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(mars_recv_dent_list);
|
EXPORT_SYMBOL_GPL(mars_recv_dent_list);
|
||||||
|
Loading…
Reference in New Issue
Block a user