From 569e70eb902bf48c066a94060c59170a6665b5be Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Tue, 13 Nov 2012 10:59:00 +0100 Subject: [PATCH] light: delay shutdown if buffer memory is in use --- mars_trans_logger.c | 6 ++++-- mars_trans_logger.h | 2 ++ sy_old/mars_light.c | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/mars_trans_logger.c b/mars_trans_logger.c index eb34379d..e8e71225 100644 --- a/mars_trans_logger.c +++ b/mars_trans_logger.c @@ -500,8 +500,10 @@ err: ////////////////// own brick / input / output operations ////////////////// -static atomic_t global_mshadow_count = ATOMIC_INIT(0); -static atomic64_t global_mshadow_used = ATOMIC64_INIT(0); +atomic_t global_mshadow_count = ATOMIC_INIT(0); +EXPORT_SYMBOL_GPL(global_mshadow_count); +atomic64_t global_mshadow_used = ATOMIC64_INIT(0); +EXPORT_SYMBOL_GPL(global_mshadow_used); static noinline int trans_logger_get_info(struct trans_logger_output *output, struct mars_info *info) diff --git a/mars_trans_logger.h b/mars_trans_logger.h index 208dc9a2..b1b8dc4f 100644 --- a/mars_trans_logger.h +++ b/mars_trans_logger.h @@ -18,6 +18,8 @@ ///////////////////////// global tuning //////////////////////// extern int trans_logger_mem_usage; // in KB +extern atomic_t global_mshadow_count; +extern atomic64_t global_mshadow_used; struct writeback_group { rwlock_t lock; diff --git a/sy_old/mars_light.c b/sy_old/mars_light.c index 3a2b5d72..51f693ab 100644 --- a/sy_old/mars_light.c +++ b/sy_old/mars_light.c @@ -3877,11 +3877,15 @@ static int light_thread(void *data) rest_space = _global.remaining_space - EXHAUSTED_LIMIT(_global.total_space); _make_alivelink("rest-space", rest_space); -#if 1 if (!_global.global_power.button) { - mars_kill_brick_all(&_global, &_global.server_anchor, false); + int used = atomic_read(&global_mshadow_count); + if (used > 0) { + MARS_INF("global shutdown delayed: there are %d buffers in use, occupying %ld bytes\n", used, atomic64_read(&global_mshadow_used)); + } else { + MARS_INF("global shutdown of all bricks...\n"); + mars_kill_brick_all(&_global, &_global.server_anchor, false); + } } -#endif MARS_DBG("-------- start worker ---------\n"); _global.deleted_min = 0;