infra: allow fetching full dent info from peers

This commit is contained in:
Thomas Schoebel-Theuer 2020-02-26 11:24:37 +01:00 committed by Thomas Schoebel-Theuer
parent 5b8c0d50a3
commit 3ab97f26b5
6 changed files with 41 additions and 5 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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:

View File

@ -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) {

View File

@ -121,6 +121,7 @@ struct mars_global {
int old_deleted_my_border;
int deleted_border;
int deleted_min;
int trigger_mode;
bool main_trigger;
};

View File

@ -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);
}