brick_say: separate logfiles for each resource

This commit is contained in:
Thomas Schoebel-Theuer 2012-11-14 10:46:36 +01:00 committed by Thomas Schoebel-Theuer
parent fdd3b251c0
commit f88c3c12ad
3 changed files with 68 additions and 4 deletions

View File

@ -60,6 +60,7 @@ struct light_class {
char cl_type;
bool cl_hostcontext;
bool cl_serial;
bool cl_use_channel;
int cl_father;
light_worker_fn cl_prepare;
light_worker_fn cl_forward;
@ -3306,6 +3307,7 @@ static const struct light_class light_classes[] = {
.cl_name = "resource-",
.cl_len = 9,
.cl_type = 'd',
.cl_use_channel = true,
.cl_father = CL_ROOT,
},
@ -3570,7 +3572,7 @@ static const struct light_class light_classes[] = {
/* 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)
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 class;
int status = -2;
@ -3636,6 +3638,7 @@ static int light_checker(struct mars_dent *parent, const char *_name, int namlen
// all ok
status = class;
*use_channel = test->cl_use_channel;
}
#ifdef MARS_DEBUGGING
@ -3902,7 +3905,7 @@ static int light_thread(void *data)
status = mars_kill_brick_when_possible(&_global, &_global.server_anchor, false, (void*)&sio_brick_type, false);
MARS_DBG("kill server sio bricks (when possible) = %d\n", status);
rollover_channel(default_channel);
rollover_all();
_show_status_all(&_global);
#ifdef STAT_DEBUGGING

View File

@ -25,6 +25,7 @@ extern char *my_id(void);
char *d_name; /* current path component */ \
char *d_rest; /* some "meaningful" rest of d_name*/ \
char *d_path; /* full absolute path */ \
struct say_channel *d_say_channel; /* for messages */ \
int d_namelen; \
int d_pathlen; \
int d_depth; \
@ -34,6 +35,7 @@ extern char *my_id(void);
int d_version; /* dynamic programming per call of mars_ent_work() */ \
char d_once_error; \
bool d_killme; \
bool d_use_channel; \
struct kstat new_stat; \
struct kstat old_stat; \
char *new_link; \
@ -66,7 +68,9 @@ struct mars_global {
bool jammed;
};
typedef int (*mars_dent_checker_fn)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial);
extern void bind_to_dent(struct mars_dent *dent, struct say_channel **ch);
typedef int (*mars_dent_checker_fn)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial, bool *use_channel);
typedef int (*mars_dent_worker_fn)(struct mars_global *global, struct mars_dent *dent, bool prepare, bool direction);
extern int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mars_dent_checker_fn checker, mars_dent_worker_fn worker, void *buf, int maxdepth);

View File

@ -264,6 +264,44 @@ EXPORT_SYMBOL_GPL(mars_remaining_space);
//////////////////////////////////////////////////////////////
// thread binding
void bind_to_dent(struct mars_dent *dent, struct say_channel **ch)
{
if (!dent) {
if (*ch) {
remove_binding_from(*ch, current);
*ch = NULL;
}
return;
}
// Memoize the channel. This is executed only once for each dent.
if (unlikely(!dent->d_say_channel)) {
struct mars_dent *test = dent->d_parent;
for (;;) {
if (!test) {
dent->d_say_channel = default_channel;
break;
}
if (test->d_use_channel && test->d_path) {
dent->d_say_channel = make_channel(test->d_path);
break;
}
test = test->d_parent;
}
}
if (dent->d_say_channel != *ch) {
if (*ch)
remove_binding_from(*ch, current);
*ch = dent->d_say_channel;
if (*ch)
bind_to_channel(*ch, current);
}
}
EXPORT_SYMBOL_GPL(bind_to_dent);
//////////////////////////////////////////////////////////////
// infrastructure
struct mars_global *mars_global = NULL;
@ -423,6 +461,7 @@ int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
int pathlen;
int class;
int serial = 0;
bool use_channel = false;
MARS_IO("ino = %llu len = %d offset = %lld type = %u\n", ino, namlen, offset, d_type);
@ -430,7 +469,7 @@ int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
return 0;
}
class = cookie->checker(cookie->parent, name, namlen, d_type, &prefix, &serial);
class = cookie->checker(cookie->parent, name, namlen, d_type, &prefix, &serial, &use_channel);
if (class < 0)
return 0;
@ -504,6 +543,7 @@ found:
dent->d_depth = cookie->depth;
dent->d_global = global;
dent->d_killme = false;
dent->d_use_channel = use_channel;
brick_string_free(newpath);
return 0;
@ -554,6 +594,7 @@ int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mar
.allocsize = allocsize,
.depth = 0,
};
struct say_channel *say_channel = NULL;
struct list_head *tmp;
struct list_head *next;
int rounds = 0;
@ -590,6 +631,8 @@ restart:
continue;
dent->d_version = version;
bind_to_dent(dent, &say_channel);
//MARS_IO("reading inode '%s'\n", dent->d_path);
status = get_inode(dent->d_path, dent);
total_status |= status;
@ -613,6 +656,7 @@ restart:
}
}
}
bind_to_dent(NULL, &say_channel);
if (found_dir && ++rounds < 10) {
schedule();
@ -629,6 +673,8 @@ restart:
schedule();
bind_to_dent(dent, &say_channel);
//MARS_IO("forward prepare '%s'\n", dent->d_path);
status = worker(buf, dent, true, false);
if (status) {
@ -636,6 +682,7 @@ restart:
}
total_status |= status;
}
bind_to_dent(NULL, &say_channel);
/* Remove all dents marked for removal.
*/
@ -644,10 +691,14 @@ restart:
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
if (!dent->d_killme)
continue;
bind_to_dent(dent, &say_channel);
MARS_DBG("killing dent '%s'\n", dent->d_path);
list_del_init(tmp);
mars_free_dent(dent);
}
bind_to_dent(NULL, &say_channel);
up_write(&global->dent_mutex);
@ -661,6 +712,8 @@ restart:
schedule();
bind_to_dent(dent, &say_channel);
//MARS_IO("forward treat '%s'\n", dent->d_path);
status = worker(buf, dent, false, false);
if (status) {
@ -669,6 +722,7 @@ restart:
down_read(&global->dent_mutex);
total_status |= status;
}
bind_to_dent(NULL, &say_channel);
/* Backward pass.
*/
@ -679,6 +733,8 @@ restart:
schedule();
bind_to_dent(dent, &say_channel);
//MARS_IO("backward treat '%s'\n", dent->d_path);
status = worker(buf, dent, false, true);
if (status) {
@ -691,6 +747,7 @@ restart:
}
}
up_read(&global->dent_mutex);
bind_to_dent(NULL, &say_channel);
done:
MARS_IO("total_status = %d\n", total_status);