all: make CONFIG_* constants tunable in /proc/sys/mars/

This commit is contained in:
Thomas Schoebel-Theuer 2013-04-05 09:27:59 +02:00
parent c58417d271
commit 795e931e1f
6 changed files with 70 additions and 58 deletions

View File

@ -89,6 +89,13 @@ config MARS_LOGDIR
by .status, and they are created automatically. Their content by .status, and they are created automatically. Their content
is however limited to a few seconds or minutes. is however limited to a few seconds or minutes.
config MARS_ROLLOVER_INTERVAL
int "rollover time of logging status files (in seconds)"
depends on MARS
default 3
---help---
May influence the system load; dont use too low nubmers.
config MARS_SCAN_INTERVAL config MARS_SCAN_INTERVAL
int "re-scanning of symlinks in /mars/ (in seconds)" int "re-scanning of symlinks in /mars/ (in seconds)"
depends on MARS depends on MARS
@ -190,16 +197,9 @@ config MARS_LOGROT_AUTO
Thus it is highly recommended to limit the logfile size to some Thus it is highly recommended to limit the logfile size to some
reasonable maximum size. Switch only off for experiments! reasonable maximum size. Switch only off for experiments!
config MARS_MIN_SPACE
bool "check for filesystem overflow in /mars"
depends on MARS
default y
---help---
Normally ON. Switch off only for EXPERIMENTS!
config MARS_MIN_SPACE_BASE config MARS_MIN_SPACE_BASE
int "free space in /mars/ (hard limit in gigabytes)" int "free space in /mars/ (hard limit in gigabytes)"
depends on MARS_MIN_SPACE depends on MARS
default 8 default 8
---help--- ---help---
when this limit is exceeded, transaction logging to /mars/ when this limit is exceeded, transaction logging to /mars/
@ -215,14 +215,14 @@ config MARS_MIN_SPACE_BASE
config MARS_MIN_SPACE_PERCENT config MARS_MIN_SPACE_PERCENT
int "free space in /mars/ (hard limit in percent)" int "free space in /mars/ (hard limit in percent)"
depends on MARS_MIN_SPACE depends on MARS
default 0 default 0
---help--- ---help---
this limit is in addition to CONFIG_MARS_MIN_SPACE_BASE. this limit is in addition to CONFIG_MARS_MIN_SPACE_BASE.
config MARS_LOGDELETE_AUTO config MARS_LOGDELETE_AUTO
int "automatic log-delete when space in /mars/ gets short (in GB)" int "automatic log-delete when space in /mars/ gets short (in GB)"
depends on MARS_MIN_SPACE depends on MARS
default 8 default 8
---help--- ---help---
This limit is in addition to CONFIG_MARS_MIN_SPACE_BASE This limit is in addition to CONFIG_MARS_MIN_SPACE_BASE

View File

@ -304,8 +304,6 @@ extern struct banning mars_global_ban;
extern atomic_t mars_global_io_flying; extern atomic_t mars_global_io_flying;
extern int rollover_time;
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
/* Some special brick types for avoidance of cyclic references. /* Some special brick types for avoidance of cyclic references.

View File

@ -22,8 +22,6 @@ struct banning mars_global_ban = {};
EXPORT_SYMBOL_GPL(mars_global_ban); EXPORT_SYMBOL_GPL(mars_global_ban);
atomic_t mars_global_io_flying = ATOMIC_INIT(0); atomic_t mars_global_io_flying = ATOMIC_INIT(0);
EXPORT_SYMBOL_GPL(mars_global_io_flying); EXPORT_SYMBOL_GPL(mars_global_io_flying);
int rollover_time = 3;
EXPORT_SYMBOL_GPL(rollover_time);
static char *id = NULL; static char *id = NULL;

View File

@ -51,6 +51,39 @@
#define inline __attribute__((__noinline__)) #define inline __attribute__((__noinline__))
#endif #endif
int global_logrot_auto = CONFIG_MARS_LOGROT_AUTO;
EXPORT_SYMBOL_GPL(global_logrot_auto);
int global_logdel_auto = CONFIG_MARS_LOGDELETE_AUTO;
EXPORT_SYMBOL_GPL(global_logdel_auto);
int global_free_space_base = CONFIG_MARS_MIN_SPACE_BASE;
EXPORT_SYMBOL_GPL(global_free_space_base);
int global_free_space_percent = CONFIG_MARS_MIN_SPACE_PERCENT;
EXPORT_SYMBOL_GPL(global_free_space_percent);
int mars_rollover_interval = CONFIG_MARS_ROLLOVER_INTERVAL;
EXPORT_SYMBOL_GPL(mars_rollover_interval);
int mars_scan_interval = CONFIG_MARS_SCAN_INTERVAL;
EXPORT_SYMBOL_GPL(mars_scan_interval);
int mars_propagate_interval = CONFIG_MARS_PROPAGATE_INTERVAL;
EXPORT_SYMBOL_GPL(mars_propagate_interval);
int mars_sync_flip_interval = CONFIG_MARS_SYNC_FLIP_INTERVAL;
EXPORT_SYMBOL_GPL(mars_sync_flip_interval);
int mars_fast_fullsync =
#ifdef CONFIG_MARS_FAST_FULLSYNC
1
#else
0
#endif
;
EXPORT_SYMBOL_GPL(mars_fast_fullsync);
static struct task_struct *main_thread = NULL; static struct task_struct *main_thread = NULL;
typedef int (*light_worker_fn)(void *buf, struct mars_dent *dent); typedef int (*light_worker_fn)(void *buf, struct mars_dent *dent);
@ -157,13 +190,8 @@ EXPORT_SYMBOL_GPL(mars_mem_percent);
//#define COPY_APPEND_MODE 1 // FIXME: does not work yet //#define COPY_APPEND_MODE 1 // FIXME: does not work yet
#define COPY_PRIO MARS_PRIO_LOW #define COPY_PRIO MARS_PRIO_LOW
#ifdef CONFIG_MARS_MIN_SPACE #define EXHAUSTED_LIMIT(max) ((long long)(max) * global_free_space_percent / 100 + (long long)global_free_space_base * 1024 * 1024)
#define EXHAUSTED_LIMIT(max) ((max) / 100 * CONFIG_MARS_MIN_SPACE_PERCENT + global_free_space * 1024 * 1024)
#define EXHAUSTED(x,max) ((x) <= EXHAUSTED_LIMIT(max)) #define EXHAUSTED(x,max) ((x) <= EXHAUSTED_LIMIT(max))
#else
#define EXHAUSTED_LIMIT(max) 0
#define EXHAUSTED(x,max) (false)
#endif
#define JAMMED(x) ((x) <= 1024 * 1024) #define JAMMED(x) ((x) <= 1024 * 1024)
@ -1287,12 +1315,10 @@ int run_bone(struct mars_peerinfo *peer, struct mars_dent *remote_dent)
struct mars_dent *local_dent = mars_find_dent(peer->global, remote_dent->d_path); struct mars_dent *local_dent = mars_find_dent(peer->global, remote_dent->d_path);
if (unlikely(!parent)) { if (unlikely(!parent)) {
MARS_IO("ignoring non-existing local resource '%s'\n", parent_path); MARS_IO("ignoring non-existing local resource '%s'\n", parent_path);
#if defined(CONFIG_MARS_LOGDELETE_AUTO)
// don't copy old / outdated logfiles // don't copy old / outdated logfiles
} else if (parent->d_private && } else if (parent->d_private &&
((struct mars_rotate *)parent->d_private)->relevant_serial > remote_dent->d_serial) { ((struct mars_rotate *)parent->d_private)->relevant_serial > remote_dent->d_serial) {
MARS_IO("ignoring outdated remote logfile '%s'\n", remote_dent->d_path); MARS_IO("ignoring outdated remote logfile '%s'\n", remote_dent->d_path);
#endif
} else { } else {
status = check_logfile(peer->peer, remote_dent, local_dent, parent, local_stat.size); status = check_logfile(peer->peer, remote_dent, local_dent, parent, local_stat.size);
} }
@ -1480,7 +1506,7 @@ int peer_thread(void *data)
brick_msleep(1000); brick_msleep(1000);
if (!brick_thread_should_stop()) { if (!brick_thread_should_stop()) {
if (pause_time < CONFIG_MARS_PROPAGATE_INTERVAL) if (pause_time < mars_propagate_interval)
pause_time++; pause_time++;
wait_event_interruptible_timeout(remote_event, wait_event_interruptible_timeout(remote_event,
atomic_read(&remote_trigger_count) > 0 || atomic_read(&remote_trigger_count) > 0 ||
@ -2021,9 +2047,9 @@ int make_log_init(void *buf, struct mars_dent *dent)
} }
MARS_DBG("logfile '%s' size = %lld\n", aio_path, rot->aio_info.current_size); MARS_DBG("logfile '%s' size = %lld\n", aio_path, rot->aio_info.current_size);
#if defined(CONFIG_MARS_LOGROT_AUTO) && CONFIG_MARS_LOGROT_AUTO > 0
if (rot->is_primary && if (rot->is_primary &&
unlikely(rot->aio_info.current_size >= (loff_t)CONFIG_MARS_LOGROT_AUTO * 1024 * 1024 * 1024)) { global_logrot_auto > 0 &&
unlikely(rot->aio_info.current_size >= (loff_t)global_logrot_auto * 1024 * 1024 * 1024)) {
char *new_path = path_make("%s/log-%09d-%s", parent_path, aio_dent->d_serial + 1, my_id()); char *new_path = path_make("%s/log-%09d-%s", parent_path, aio_dent->d_serial + 1, my_id());
if (likely(new_path && !mars_find_dent(global, new_path))) { if (likely(new_path && !mars_find_dent(global, new_path))) {
MARS_INF("old logfile size = %lld, creating new logfile '%s'\n", rot->aio_info.current_size, new_path); MARS_INF("old logfile size = %lld, creating new logfile '%s'\n", rot->aio_info.current_size, new_path);
@ -2031,7 +2057,6 @@ int make_log_init(void *buf, struct mars_dent *dent)
} }
brick_string_free(new_path); brick_string_free(new_path);
} }
#endif
// check whether attach is allowed // check whether attach is allowed
switch_path = path_make("%s/todo-%s/attach", parent_path, my_id()); switch_path = path_make("%s/todo-%s/attach", parent_path, my_id());
@ -2354,7 +2379,6 @@ void _init_trans_input(struct trans_logger_input *trans_input, struct mars_dent
MARS_DBG("initialized '%s' %d\n", trans_input->inf.inf_host, trans_input->inf.inf_sequence); MARS_DBG("initialized '%s' %d\n", trans_input->inf.inf_host, trans_input->inf.inf_sequence);
} }
#ifdef CONFIG_MARS_LOGROT
static static
int _get_free_input(struct trans_logger_brick *trans_brick) int _get_free_input(struct trans_logger_brick *trans_brick)
{ {
@ -2457,7 +2481,6 @@ void _rotate_trans(struct mars_rotate *rot)
} }
done: ; done: ;
} }
#endif
static static
void _change_trans(struct mars_rotate *rot) void _change_trans(struct mars_rotate *rot)
@ -2470,9 +2493,7 @@ void _change_trans(struct mars_rotate *rot)
trans_brick->replay_start_pos = rot->start_pos; trans_brick->replay_start_pos = rot->start_pos;
trans_brick->replay_end_pos = rot->end_pos; trans_brick->replay_end_pos = rot->end_pos;
} else { } else {
#ifdef CONFIG_MARS_LOGROT
_rotate_trans(rot); _rotate_trans(rot);
#endif
} }
} }
@ -2706,7 +2727,6 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
rot->copy_next_is_available = 0; rot->copy_next_is_available = 0;
} }
#if defined(CONFIG_MARS_LOGDELETE_AUTO)
#define LIMIT1 ((loff_t)EXHAUSTED_LIMIT(rot->total_space)) #define LIMIT1 ((loff_t)EXHAUSTED_LIMIT(rot->total_space))
#define LIMIT2 ((loff_t)global_logdel_auto * 1024 * 1024) #define LIMIT2 ((loff_t)global_logdel_auto * 1024 * 1024)
if (rot->remaining_space <= LIMIT1 + LIMIT2) { if (rot->remaining_space <= LIMIT1 + LIMIT2) {
@ -2717,7 +2737,6 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
rot->first_log->d_killme = true; rot->first_log->d_killme = true;
} }
} }
#endif
/* Stopping is also possible in case of errors /* Stopping is also possible in case of errors
*/ */
@ -2735,10 +2754,8 @@ int make_log_finalize(struct mars_global *global, struct mars_dent *dent)
if (do_stop) { if (do_stop) {
status = _stop_trans(rot, parent->d_path); status = _stop_trans(rot, parent->d_path);
#ifdef CONFIG_MARS_LOGROT
} else { } else {
_change_trans(rot); _change_trans(rot);
#endif
} }
goto done; goto done;
} }
@ -3219,20 +3236,19 @@ static int make_sync(void *buf, struct mars_dent *dent)
rot->forbid_replay = true; rot->forbid_replay = true;
} }
#if defined(CONFIG_MARS_SYNC_FLIP_INTERVAL) && CONFIG_MARS_SYNC_FLIP_INTERVAL > 0
/* Flip between replay and sync /* Flip between replay and sync
*/ */
if (do_start && rot->replay_mode && rot->end_pos > rot->start_pos) { if (do_start && rot->replay_mode && rot->end_pos > rot->start_pos &&
mars_sync_flip_interval >= 8) {
if (!rot->flip_start) { if (!rot->flip_start) {
rot->flip_start = jiffies; rot->flip_start = jiffies;
} else if ((long long)jiffies - rot->flip_start > CONFIG_MARS_SYNC_FLIP_INTERVAL * HZ) { } else if ((long long)jiffies - rot->flip_start > CONFIG_MARS_SYNC_FLIP_INTERVAL * HZ) {
do_start = false; do_start = false;
rot->flip_start = jiffies + CONFIG_MARS_SYNC_FLIP_INTERVAL * HZ; rot->flip_start = jiffies + mars_sync_flip_interval * HZ;
} }
} else { } else {
rot->flip_start = 0; rot->flip_start = 0;
} }
#endif
/* Start copy /* Start copy
*/ */
@ -3251,12 +3267,7 @@ static int make_sync(void *buf, struct mars_dent *dent)
{ {
const char *argv[2] = { src, dst }; const char *argv[2] = { src, dst };
#ifdef CONFIG_MARS_FAST_FULLSYNC status = __make_copy(global, dent, do_start ? switch_path : "", copy_path, dent->d_parent->d_path, argv, start_pos, mars_fast_fullsync > 0, true, &copy);
# define VERIFY_MODE true
#else
# define VERIFY_MODE false
#endif
status = __make_copy(global, dent, do_start ? switch_path : "", copy_path, dent->d_parent->d_path, argv, start_pos, VERIFY_MODE, true, &copy);
if (copy) if (copy)
copy->copy_limiter = &rot->sync_limiter; copy->copy_limiter = &rot->sync_limiter;
rot->sync_brick = copy; rot->sync_brick = copy;
@ -4041,7 +4052,7 @@ static int light_thread(void *data)
status = mars_kill_brick_when_possible(&_global, &_global.brick_anchor, false, (void*)&sio_brick_type, false); status = mars_kill_brick_when_possible(&_global, &_global.brick_anchor, false, (void*)&sio_brick_type, false);
MARS_DBG("kill sio bricks (when possible) = %d\n", status); MARS_DBG("kill sio bricks (when possible) = %d\n", status);
if ((long long)jiffies + rollover_time * HZ >= last_rollover) { if ((long long)jiffies + mars_rollover_interval * HZ >= last_rollover) {
last_rollover = jiffies; last_rollover = jiffies;
rollover_all(); rollover_all();
} }
@ -4053,7 +4064,8 @@ static int light_thread(void *data)
brick_msleep(500); brick_msleep(500);
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, CONFIG_MARS_SCAN_INTERVAL * HZ); wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, mars_scan_interval * HZ);
_global.main_trigger = false; _global.main_trigger = false;
} }
@ -4125,15 +4137,6 @@ static void __exit exit_light(void)
printk(KERN_INFO "stopped MARS\n"); printk(KERN_INFO "stopped MARS\n");
} }
int global_logrot_auto = CONFIG_MARS_LOGROT_AUTO;
EXPORT_SYMBOL_GPL(global_logrot_auto);
int global_logdel_auto = CONFIG_MARS_LOGDELETE_AUTO;
EXPORT_SYMBOL_GPL(global_logdel_auto);
int global_free_space = CONFIG_MARS_MIN_SPACE_BASE;
EXPORT_SYMBOL_GPL(global_free_space);
static int __init init_light(void) static int __init init_light(void)
{ {
extern int min_free_kbytes; extern int min_free_kbytes;

View File

@ -215,10 +215,15 @@ ctl_table mars_table[] = {
INT_ENTRY("mem_used_raw_kb", brick_global_block_used,0400), INT_ENTRY("mem_used_raw_kb", brick_global_block_used,0400),
INT_ENTRY("io_flying_count", mars_global_io_flying, 0400), INT_ENTRY("io_flying_count", mars_global_io_flying, 0400),
INT_ENTRY("copy_overlap", mars_copy_overlap, 0600), INT_ENTRY("copy_overlap", mars_copy_overlap, 0600),
INT_ENTRY("statusfiles_rollover_sec", rollover_time, 0600), INT_ENTRY("statusfiles_rollover_sec", mars_rollover_interval, 0600),
INT_ENTRY("scan_interval_sec", mars_scan_interval, 0600),
INT_ENTRY("propagate_interval_sec", mars_propagate_interval, 0600),
INT_ENTRY("sync_flip_interval_sec", mars_sync_flip_interval, 0600),
INT_ENTRY("do_fast_fullsync", mars_fast_fullsync, 0600),
INT_ENTRY("logrot_auto_gb", global_logrot_auto, 0600), INT_ENTRY("logrot_auto_gb", global_logrot_auto, 0600),
INT_ENTRY("logdel_auto_gb", global_logdel_auto, 0600), INT_ENTRY("logdel_auto_gb", global_logdel_auto, 0600),
INT_ENTRY("free_space_mb", global_free_space, 0600), INT_ENTRY("required_free_space_mb", global_free_space_base, 0600),
INT_ENTRY("required_free_space_percent", global_free_space_percent, 0600),
#ifdef CONFIG_MARS_LOADAVG_LIMIT #ifdef CONFIG_MARS_LOADAVG_LIMIT
INT_ENTRY("loadavg_limit", mars_max_loadavg, 0600), INT_ENTRY("loadavg_limit", mars_max_loadavg, 0600),
#endif #endif

View File

@ -12,7 +12,15 @@
extern int global_logrot_auto; extern int global_logrot_auto;
extern int global_logdel_auto; extern int global_logdel_auto;
extern int global_free_space; extern int global_free_space_base;
extern int global_free_space_percent;
extern int mars_rollover_interval;
extern int mars_scan_interval;
extern int mars_propagate_interval;
extern int mars_sync_flip_interval;
extern int mars_fast_fullsync;
extern char *my_id(void); extern char *my_id(void);