From 3ab97f26b55c3d030d3d307828cc0bddf7681027 Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 26 Feb 2020 11:24:37 +0100 Subject: [PATCH] infra: allow fetching full dent info from peers --- kernel/mars.h | 7 +++++-- kernel/mars_generic.c | 2 +- kernel/sy_old/mars_main.c | 29 +++++++++++++++++++++++++++++ kernel/sy_old/mars_proc.c | 4 +++- kernel/sy_old/strategy.h | 1 + kernel/sy_old/sy_generic.c | 3 ++- 6 files changed, 41 insertions(+), 5 deletions(-) diff --git a/kernel/mars.h b/kernel/mars.h index b9f6bc40..bbb9efd4 100644 --- a/kernel/mars.h +++ b/kernel/mars.h @@ -346,9 +346,12 @@ extern void mars_power_led_on(struct mars_brick *brick, bool val); extern void mars_power_led_off(struct mars_brick *brick, bool val); /* this should disappear! */ -extern void (*_mars_trigger)(void); +extern void (*_mars_trigger)(int mode); extern void (*_mars_remote_trigger)(bool do_all); -#define mars_trigger() do { if (_mars_trigger) { MARS_DBG("trigger...\n"); _mars_trigger(); } } while (0) +#define mars_trigger() \ + do { if (_mars_trigger) { MARS_DBG("trigger...\n"); _mars_trigger(0); } } while (0) +#define mars_full_trigger(mode) \ + do { if (_mars_trigger) { MARS_DBG("full trigger %d...\n", mode); _mars_trigger(mode); } } while (0) #define mars_remote_trigger() do { if (_mars_remote_trigger) { MARS_DBG("remote_trigger...\n"); _mars_remote_trigger(false); } } while (0) #define mars_remote_trigger_all() do { if (_mars_remote_trigger) { MARS_DBG("remote_trigger_all...\n"); _mars_remote_trigger(true); } } while (0) diff --git a/kernel/mars_generic.c b/kernel/mars_generic.c index 4d832acf..32824412 100644 --- a/kernel/mars_generic.c +++ b/kernel/mars_generic.c @@ -354,7 +354,7 @@ EXPORT_SYMBOL_GPL(mars_power_led_off); // init stuff -void (*_mars_trigger)(void) = NULL; +void (*_mars_trigger)(int) = NULL; EXPORT_SYMBOL_GPL(_mars_trigger); struct mm_struct *mm_fake = NULL; diff --git a/kernel/sy_old/mars_main.c b/kernel/sy_old/mars_main.c index 74362299..bcd9e4af 100644 --- a/kernel/sy_old/mars_main.c +++ b/kernel/sy_old/mars_main.c @@ -1785,6 +1785,7 @@ struct mars_peerinfo { bool from_remote_trigger; bool do_communicate; bool do_additional; + bool do_entire_once; bool doing_additional; }; @@ -2428,6 +2429,7 @@ int peer_thread(void *data) peer->to_remote_trigger = false; cmd.cmd_code = CMD_GETENTS; if ((!peer->do_additional || peer->do_communicate) && + !peer->do_entire_once && mars_resource_list) { char *dir_list; @@ -2439,6 +2441,7 @@ int peer_thread(void *data) cmd.cmd_str1 = dir_list; } else { cmd.cmd_str1 = brick_strdup("/mars"); + peer->do_entire_once = false; } MARS_DBG("fetching dents from '%s' paths '%s'\n", peer->peer, cmd.cmd_str1); @@ -2632,6 +2635,26 @@ void __mars_remote_trigger(bool do_all) wake_up_interruptible_all(&remote_event); } +static +void __mars_full_trigger(int mode) +{ + struct list_head *tmp; + int count = 0; + + down_read(&peer_lock); + for (tmp = peer_anchor.next; tmp != &peer_anchor; tmp = tmp->next) { + struct mars_peerinfo *peer = container_of(tmp, struct mars_peerinfo, peer_head); + + if (mode & 8) + peer->do_entire_once = true; + count++; + } + up_read(&peer_lock); + + MARS_DBG("full trigger %d peers\n", count); + wake_up_interruptible_all(&remote_event); +} + static bool is_shutdown(void) { @@ -6170,6 +6193,7 @@ static int _main_thread(void *data) while (_global.global_power.button || !list_empty(&_global.brick_anchor)) { struct list_head *tmp; + int trigger_mode; int status; loff_t memlimit; @@ -6264,6 +6288,11 @@ static int _main_thread(void *data) _global.main_trigger = false; additional_peers(mars_run_additional_peers - mars_running_additional_peers); + trigger_mode = _global.trigger_mode; + _global.trigger_mode = 0; + if (trigger_mode) { + __mars_full_trigger(trigger_mode); + } } done: diff --git a/kernel/sy_old/mars_proc.c b/kernel/sy_old/mars_proc.c index 46321a6a..dec50866 100644 --- a/kernel/sy_old/mars_proc.c +++ b/kernel/sy_old/mars_proc.c @@ -118,7 +118,9 @@ int trigger_sysctl_handler( int code = 0; sscanf(tmp, "%d", &code); - if (code > 0) { + if (code >= 8) { + mars_full_trigger(code); + } else if (code > 0) { mars_trigger(); } if (code > 2) { diff --git a/kernel/sy_old/strategy.h b/kernel/sy_old/strategy.h index 224c4171..087e04e9 100644 --- a/kernel/sy_old/strategy.h +++ b/kernel/sy_old/strategy.h @@ -121,6 +121,7 @@ struct mars_global { int old_deleted_my_border; int deleted_border; int deleted_min; + int trigger_mode; bool main_trigger; }; diff --git a/kernel/sy_old/sy_generic.c b/kernel/sy_old/sy_generic.c index 81c74701..f0a7d039 100644 --- a/kernel/sy_old/sy_generic.c +++ b/kernel/sy_old/sy_generic.c @@ -1023,9 +1023,10 @@ struct mars_global *mars_global = NULL; EXPORT_SYMBOL_GPL(mars_global); static -void __mars_trigger(void) +void __mars_trigger(int mode) { if (mars_global) { + mars_global->trigger_mode |= mode; mars_global->main_trigger = true; wake_up_interruptible_all(&mars_global->main_event); }