server: lockless dent shipping

This commit is contained in:
Thomas Schoebel-Theuer 2012-12-18 06:31:24 +01:00 committed by Thomas Schoebel-Theuer
parent 2d225065c8
commit ce41cdee2b
3 changed files with 28 additions and 5 deletions

View File

@ -279,6 +279,12 @@ struct task_struct *_grab_handler(struct server_brick *brick)
return res; return res;
} }
static
int dummy_worker(struct mars_global *global, struct mars_dent *dent, bool prepare, bool direction)
{
return 0;
}
static static
int handler_thread(void *data) int handler_thread(void *data)
{ {
@ -335,19 +341,34 @@ int handler_thread(void *data)
} }
case CMD_GETENTS: case CMD_GETENTS:
{ {
struct mars_global local = {
.dent_anchor = LIST_HEAD_INIT(local.dent_anchor),
.brick_anchor = LIST_HEAD_INIT(local.brick_anchor),
.server_anchor = LIST_HEAD_INIT(local.server_anchor),
.global_power = {
.button = true,
},
.main_event = __WAIT_QUEUE_HEAD_INITIALIZER(local.main_event),
};
status = -EINVAL; status = -EINVAL;
if (unlikely(!cmd.cmd_str1 || !mars_global)) if (unlikely(!cmd.cmd_str1))
break; break;
init_rwsem(&local.dent_mutex);
init_rwsem(&local.brick_mutex);
status = mars_dent_work(&local, "/mars", sizeof(struct mars_dent), light_checker, dummy_worker, &local, 3);
down(&brick->socket_sem); down(&brick->socket_sem);
down_read(&mars_global->dent_mutex); status = mars_send_dent_list(sock, &local.dent_anchor);
status = mars_send_dent_list(sock, &mars_global->dent_anchor);
up_read(&mars_global->dent_mutex);
up(&brick->socket_sem); up(&brick->socket_sem);
if (status < 0) { if (status < 0) {
MARS_WRN("#%d could not send dentry information, status = %d\n", sock->s_debug_nr, status); MARS_WRN("#%d could not send dentry information, status = %d\n", sock->s_debug_nr, status);
} }
mars_free_dent_all(&local, &local.dent_anchor);
break; break;
} }
case CMD_CONNECT: case CMD_CONNECT:

View File

@ -3574,7 +3574,7 @@ static const struct light_class light_classes[] = {
/* Helper routine to pre-determine the relevance of a name from the filesystem. /* Helper routine to pre-determine the relevance of a name from the filesystem.
*/ */
static int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel) int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel)
{ {
int class; int class;
int status = -2; int status = -2;

View File

@ -160,6 +160,8 @@ extern int mars_max_loadavg;
extern int mars_mem_percent; extern int mars_mem_percent;
extern int light_checker(struct mars_dent *parent, const char *_name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel);
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// init // init