added automatic killing of unused client/aio bricks

This commit is contained in:
Thomas Schoebel-Theuer 2011-10-10 13:38:55 +02:00 committed by Thomas Schoebel-Theuer
parent c8f9b792be
commit be4aab45a2
3 changed files with 50 additions and 0 deletions

View File

@ -2937,6 +2937,11 @@ static int light_thread(void *data)
status = mars_dent_work(&_global, "/mars", sizeof(struct mars_dent), light_checker, light_worker, &_global, 3);
MARS_DBG("worker status = %d\n", status);
status = mars_kill_brick_when_possible(&_global, &_global.brick_anchor, false, (void*)&client_brick_type);
MARS_DBG("kill client bricks (when possible) = %d\n", status);
status = mars_kill_brick_when_possible(&_global, &_global.brick_anchor, false, (void*)&aio_brick_type);
MARS_DBG("kill aio bricks (when possible) = %d\n", status);
_show_status_all(&_global);
#ifdef STAT_DEBUGGING
_show_statist(&_global);

View File

@ -74,6 +74,7 @@ extern struct mars_brick *mars_make_brick(struct mars_global *global, struct mar
extern int mars_free_brick(struct mars_brick *brick);
extern int mars_kill_brick(struct mars_brick *brick);
extern int mars_kill_brick_all(struct mars_global *global, struct list_head *anchor, bool use_dent_link);
extern int mars_kill_brick_when_possible(struct mars_global *global, struct list_head *anchor, bool use_dent_link, const struct mars_brick_type *type);
// mid-level brick instantiation (identity is based on path strings)

View File

@ -983,6 +983,50 @@ int mars_kill_brick_all(struct mars_global *global, struct list_head *anchor, bo
}
EXPORT_SYMBOL_GPL(mars_kill_brick_all);
int mars_kill_brick_when_possible(struct mars_global *global, struct list_head *anchor, bool use_dent_link, const struct mars_brick_type *type)
{
int return_status = 0;
struct list_head *tmp;
struct list_head *next;
if (global) {
down_write(&global->brick_mutex);
}
for (tmp = anchor->next, next = tmp->next; tmp != anchor; tmp = next, next = next->next) {
struct mars_brick *brick;
int status;
if (use_dent_link) {
brick = container_of(tmp, struct mars_brick, dent_brick_link);
} else {
brick = container_of(tmp, struct mars_brick, global_brick_link);
}
if (brick->type != type) {
continue;
}
if (brick->outputs[0]->nr_connected > 0) {
continue;
}
list_del_init(tmp);
if (global) {
up_write(&global->brick_mutex);
}
status = mars_kill_brick(brick);
if (global) {
down_write(&global->brick_mutex);
}
if (status >= 0) {
return_status++;
} else {
return_status = status;
break;
}
}
if (global) {
up_write(&global->brick_mutex);
}
return return_status;
}
EXPORT_SYMBOL_GPL(mars_kill_brick_when_possible);
/////////////////////////////////////////////////////////////////////