added brick_version, fixed endless instantion/removal loops

This commit is contained in:
Thomas Schoebel-Theuer 2011-10-10 15:03:10 +02:00 committed by Thomas Schoebel-Theuer
parent be4aab45a2
commit ab3f9f6a00
4 changed files with 19 additions and 3 deletions

1
mars.h
View File

@ -163,6 +163,7 @@ struct mars_info {
struct list_head dent_brick_link; \
const char *brick_path; \
struct mars_global *global; \
int brick_version; \
void (*show_status)(struct mars_brick *brick, bool shutdown); \
struct mars_brick {

View File

@ -2947,7 +2947,7 @@ static int light_thread(void *data)
_show_statist(&_global);
#endif
msleep(500);
msleep(1000);
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, 10 * HZ);
_global.main_trigger = false;

View File

@ -54,7 +54,7 @@ struct mars_global {
struct list_head server_anchor;
volatile bool main_trigger;
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);

View File

@ -500,6 +500,7 @@ int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mar
/* Initialize the flat dent list
*/
version++;
global->global_version = version;
total_status = _mars_readdir(&cookie);
if (total_status || !worker) {
@ -685,7 +686,7 @@ void mars_free_dent(struct mars_dent *dent)
{
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);
@ -999,12 +1000,23 @@ int mars_kill_brick_when_possible(struct mars_global *global, struct list_head *
} else {
brick = container_of(tmp, struct mars_brick, global_brick_link);
}
// only kill the right brick types
if (brick->type != type) {
continue;
}
// only kill unconnected bricks
if (brick->outputs[0]->nr_connected > 0) {
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);
if (global) {
up_write(&global->brick_mutex);
@ -1255,6 +1267,9 @@ struct mars_brick *make_brick_all(
}
do_switch:
if (global) {
brick->brick_version = global->global_version;
}
// call setup function
if (setup_fn) {
int setup_status = setup_fn(brick, private);