From 34dac0689b8d8a206519f18b5bbbcec11adcd8cb Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 22 Jan 2013 12:10:12 +0100 Subject: [PATCH] infra: make killing of useless bricks selectable --- mars.h | 1 + mars_server.c | 4 ++++ sy_old/mars_light.c | 5 +++++ sy_old/sy_generic.c | 6 +++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mars.h b/mars.h index 56b7e95a..3e49c796 100644 --- a/mars.h +++ b/mars.h @@ -176,6 +176,7 @@ struct mars_info { const char *brick_path; \ struct mars_global *global; \ int brick_version; \ + bool killme; \ void (*show_status)(struct mars_brick *brick, bool shutdown); \ struct mars_brick { diff --git a/mars_server.c b/mars_server.c index 2d6450d3..d767d680 100644 --- a/mars_server.c +++ b/mars_server.c @@ -408,6 +408,10 @@ int handler_thread(void *data) 0); if (likely(prev)) { status = generic_connect((void*)brick->inputs[0], (void*)prev->outputs[0]); + if (unlikely(status < 0)) { + MARS_ERR("#%d cannot connect to '%s'\n", sock->s_debug_nr, path); + } + prev->killme = true; } else { MARS_ERR("#%d cannot find brick '%s'\n", sock->s_debug_nr, path); } diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index d3ac952f..ed769bd9 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -211,6 +211,7 @@ int _set_client_params(struct mars_brick *_brick, void *private) struct client_cookie *clc = private; client_brick->io_timeout = 0; client_brick->limit_mode = clc ? clc->limit_mode : false; + client_brick->killme = true; MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path); return 1; } @@ -228,6 +229,7 @@ int _set_sio_params(struct mars_brick *_brick, void *private) } sio_brick->o_direct = false; // important! sio_brick->o_fdsync = true; + sio_brick->killme = true; MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path); return 1; } @@ -250,6 +252,7 @@ int _set_aio_params(struct mars_brick *_brick, void *private) aio_brick->o_creat = clc && clc->create_mode; aio_brick->o_direct = false; // important! aio_brick->o_fdsync = true; + aio_brick->killme = true; MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path); return 1; } @@ -276,6 +279,7 @@ int _set_bio_params(struct mars_brick *_brick, void *private) bio_brick->do_noidle = BIO_NOIDLE; bio_brick->do_sync = BIO_SYNC; bio_brick->do_unplug = BIO_UNPLUG; + bio_brick->killme = true; MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path); return 1; } @@ -325,6 +329,7 @@ int _set_copy_params(struct mars_brick *_brick, void *private) copy_brick->io_prio = COPY_PRIO; copy_brick->verify_mode = cc->verify_mode; copy_brick->repair_mode = true; + copy_brick->killme = true; MARS_INF("name = '%s' path = '%s'\n", _brick->brick_name, _brick->brick_path); /* Determine the copy area, switch on/off when necessary diff --git a/sy_old/sy_generic.c b/sy_old/sy_generic.c index e9dd79c1..3e333099 100644 --- a/sy_old/sy_generic.c +++ b/sy_old/sy_generic.c @@ -1216,7 +1216,11 @@ restart: brick = container_of(tmp, struct mars_brick, global_brick_link); } // only kill the right brick types - if (brick->type != type) { + if (type && brick->type != type) { + continue; + } + // only kill marked bricks + if (!brick->killme) { continue; } // only kill unconnected bricks