mirror of https://github.com/schoebel/mars
added brick_version, fixed endless instantion/removal loops
This commit is contained in:
parent
be4aab45a2
commit
ab3f9f6a00
1
mars.h
1
mars.h
|
@ -163,6 +163,7 @@ struct mars_info {
|
||||||
struct list_head dent_brick_link; \
|
struct list_head dent_brick_link; \
|
||||||
const char *brick_path; \
|
const char *brick_path; \
|
||||||
struct mars_global *global; \
|
struct mars_global *global; \
|
||||||
|
int brick_version; \
|
||||||
void (*show_status)(struct mars_brick *brick, bool shutdown); \
|
void (*show_status)(struct mars_brick *brick, bool shutdown); \
|
||||||
|
|
||||||
struct mars_brick {
|
struct mars_brick {
|
||||||
|
|
|
@ -2947,7 +2947,7 @@ static int light_thread(void *data)
|
||||||
_show_statist(&_global);
|
_show_statist(&_global);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
msleep(500);
|
msleep(1000);
|
||||||
|
|
||||||
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, 10 * HZ);
|
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, 10 * HZ);
|
||||||
_global.main_trigger = false;
|
_global.main_trigger = false;
|
||||||
|
|
|
@ -54,7 +54,7 @@ struct mars_global {
|
||||||
struct list_head server_anchor;
|
struct list_head server_anchor;
|
||||||
volatile bool main_trigger;
|
volatile bool main_trigger;
|
||||||
wait_queue_head_t main_event;
|
wait_queue_head_t main_event;
|
||||||
//void *private;
|
int global_version;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef int (*mars_dent_checker)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial);
|
typedef int (*mars_dent_checker)(struct mars_dent *parent, const char *name, int namlen, unsigned int d_type, int *prefix, int *serial);
|
||||||
|
|
|
@ -500,6 +500,7 @@ int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mar
|
||||||
/* Initialize the flat dent list
|
/* Initialize the flat dent list
|
||||||
*/
|
*/
|
||||||
version++;
|
version++;
|
||||||
|
global->global_version = version;
|
||||||
total_status = _mars_readdir(&cookie);
|
total_status = _mars_readdir(&cookie);
|
||||||
|
|
||||||
if (total_status || !worker) {
|
if (total_status || !worker) {
|
||||||
|
@ -685,7 +686,7 @@ void mars_free_dent(struct mars_dent *dent)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
MARS_DBG("%p path='%s'\n", dent, dent->d_path);
|
MARS_IO("%p path='%s'\n", dent, dent->d_path);
|
||||||
|
|
||||||
mars_kill_dent(dent);
|
mars_kill_dent(dent);
|
||||||
|
|
||||||
|
@ -999,12 +1000,23 @@ int mars_kill_brick_when_possible(struct mars_global *global, struct list_head *
|
||||||
} else {
|
} else {
|
||||||
brick = container_of(tmp, struct mars_brick, global_brick_link);
|
brick = container_of(tmp, struct mars_brick, global_brick_link);
|
||||||
}
|
}
|
||||||
|
// only kill the right brick types
|
||||||
if (brick->type != type) {
|
if (brick->type != type) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
// only kill unconnected bricks
|
||||||
if (brick->outputs[0]->nr_connected > 0) {
|
if (brick->outputs[0]->nr_connected > 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
#if 1
|
||||||
|
/* optimization:
|
||||||
|
* only kill bricks which have not been touched during the current mars_dent_work() round.
|
||||||
|
* disable this for stress-testing the allocation/deallocation logic.
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
if (global && global->global_version == brick->brick_version) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
list_del_init(tmp);
|
list_del_init(tmp);
|
||||||
if (global) {
|
if (global) {
|
||||||
up_write(&global->brick_mutex);
|
up_write(&global->brick_mutex);
|
||||||
|
@ -1255,6 +1267,9 @@ struct mars_brick *make_brick_all(
|
||||||
}
|
}
|
||||||
|
|
||||||
do_switch:
|
do_switch:
|
||||||
|
if (global) {
|
||||||
|
brick->brick_version = global->global_version;
|
||||||
|
}
|
||||||
// call setup function
|
// call setup function
|
||||||
if (setup_fn) {
|
if (setup_fn) {
|
||||||
int setup_status = setup_fn(brick, private);
|
int setup_status = setup_fn(brick, private);
|
||||||
|
|
Loading…
Reference in New Issue