mirror of
https://github.com/schoebel/mars
synced 2024-12-29 18:32:47 +00:00
speedup overall handling a lot
This commit is contained in:
parent
6ebf3147a1
commit
e3bfbab1a9
14
Kconfig
14
Kconfig
@ -40,6 +40,20 @@ config MARS_USE_SYSLOG
|
||||
in other cases). Thus we recommend to prefer file logging.
|
||||
When this option is off, the logfile will be used (if one exists).
|
||||
|
||||
config MARS_SCAN_INTERVAL
|
||||
int "re-scanning of symlinks in /mars/ (in seconds)"
|
||||
depends on MARS
|
||||
default 10
|
||||
---help---
|
||||
May influence the system load; dont use too low nubmers.
|
||||
|
||||
config MARS_FAST_TRIGGER
|
||||
bool "fast internal triggering"
|
||||
depends on MARS
|
||||
default y
|
||||
---help---
|
||||
Normally ON. Switch off in case of endless trigger loops
|
||||
|
||||
config MARS_MEM_PREALLOC
|
||||
bool "avoid memory fragmentation by preallocation"
|
||||
depends on MARS
|
||||
|
2
mars.h
2
mars.h
@ -267,7 +267,7 @@ extern void mars_power_led_off(struct mars_brick *brick, bool val);
|
||||
/* this should disappear!
|
||||
*/
|
||||
extern void (*_mars_trigger)(void);
|
||||
#define mars_trigger() do { MARS_INF("trigger...\n"); if (_mars_trigger) _mars_trigger(); } while (0)
|
||||
#define mars_trigger() do { if (_mars_trigger) { MARS_INF("trigger...\n"); _mars_trigger(); } } while (0)
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -231,12 +231,12 @@ int handler_thread(void *data)
|
||||
wake_up_interruptible(&brick->startup_event);
|
||||
|
||||
MARS_DBG("--------------- handler_thread starting on socket %p\n", sock);
|
||||
while (brick->cb_running && !kthread_should_stop()) {
|
||||
while (brick->cb_running && !sock->s_dead && !kthread_should_stop()) {
|
||||
struct mars_cmd cmd = {};
|
||||
|
||||
status = mars_recv_struct(sock, &cmd, mars_cmd_meta);
|
||||
if (status < 0) {
|
||||
MARS_WRN("bad command status = %d\n", status);
|
||||
if (unlikely(status < 0 || sock->s_dead)) {
|
||||
MARS_WRN("dead = %d recv cmd status = %d\n", sock->s_dead, status);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -976,7 +976,7 @@ int run_bones(struct mars_peerinfo *peer)
|
||||
//MARS_DBG("path = '%s' worker status = %d\n", remote_dent->d_path, status);
|
||||
}
|
||||
mars_free_dent_all(NULL, &tmp_list);
|
||||
#if 0
|
||||
#ifdef CONFIG_MARS_FAST_TRIGGER
|
||||
if (run_trigger) {
|
||||
mars_trigger();
|
||||
}
|
||||
@ -1901,14 +1901,19 @@ int _make_logging_status(struct mars_rotate *rot)
|
||||
if (_check_versionlink(global, parent->d_path, dent->d_serial, end_pos) > 0) {
|
||||
MARS_DBG("switching over from '%s' to next relevant transaction log '%s'\n", dent->d_path, rot->next_relevant_log->d_path);
|
||||
_update_all_links(global, parent->d_path, trans_brick, rot->next_relevant_log->d_rest, dent->d_serial + 1, true, true);
|
||||
#ifdef CONFIG_MARS_FAST_TRIGGER
|
||||
mars_trigger();
|
||||
#endif
|
||||
}
|
||||
} else if (rot->todo_primary) {
|
||||
MARS_DBG("preparing new transaction log '%s' from version %d to %d\n", dent->d_path, dent->d_serial, dent->d_serial + 1);
|
||||
_update_all_links(global, parent->d_path, trans_brick, my_id(), dent->d_serial + 1, false, true);
|
||||
#ifdef CONFIG_MARS_FAST_TRIGGER
|
||||
mars_trigger();
|
||||
#endif
|
||||
} else {
|
||||
MARS_DBG("nothing to do on last transaction log '%s'\n", dent->d_path);
|
||||
}
|
||||
//mars_trigger();
|
||||
}
|
||||
status = -EAGAIN;
|
||||
goto done;
|
||||
@ -3243,9 +3248,10 @@ static int light_worker(struct mars_global *global, struct mars_dent *dent, bool
|
||||
}
|
||||
if (worker) {
|
||||
int status;
|
||||
//MARS_DBG("working %s on '%s' rest='%s'\n", direction ? "backward" : "forward", dent->d_path, dent->d_rest);
|
||||
if (!direction)
|
||||
MARS_DBG("--- start working %s on '%s' rest='%s'\n", direction ? "backward" : "forward", dent->d_path, dent->d_rest);
|
||||
status = worker(global, (void*)dent);
|
||||
MARS_DBG("worked %s on '%s', status = %d\n", direction ? "backward" : "forward", dent->d_path, status);
|
||||
MARS_DBG("--- done, worked %s on '%s', status = %d\n", direction ? "backward" : "forward", dent->d_path, status);
|
||||
return status;
|
||||
}
|
||||
return 0;
|
||||
@ -3366,6 +3372,10 @@ static int light_thread(void *data)
|
||||
|
||||
while (_global.global_power.button || !list_empty(&_global.brick_anchor)) {
|
||||
int status;
|
||||
|
||||
MARS_DBG("-------- NEW ROUND ---------\n");
|
||||
msleep(100);
|
||||
|
||||
_global.global_power.button = !kthread_should_stop();
|
||||
_global.remaining_space = mars_remaining_space("/mars");
|
||||
if (EXHAUSTED(_global.remaining_space))
|
||||
@ -3379,8 +3389,9 @@ static int light_thread(void *data)
|
||||
}
|
||||
#endif
|
||||
|
||||
MARS_DBG("-------- start worker ---------\n");
|
||||
status = mars_dent_work(&_global, "/mars", sizeof(struct mars_dent), light_checker, light_worker, &_global, 3);
|
||||
MARS_DBG("worker status = %d\n", status);
|
||||
MARS_DBG("-------- worker status = %d\n", status);
|
||||
|
||||
if (!_global.global_power.button) {
|
||||
status = mars_kill_brick_when_possible(&_global, &_global.brick_anchor, false, (void*)©_brick_type, false);
|
||||
@ -3398,9 +3409,9 @@ static int light_thread(void *data)
|
||||
_show_statist(&_global);
|
||||
#endif
|
||||
|
||||
msleep(1000);
|
||||
msleep(500);
|
||||
|
||||
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, 10 * HZ);
|
||||
wait_event_interruptible_timeout(_global.main_event, _global.main_trigger, CONFIG_MARS_SCAN_INTERVAL * HZ);
|
||||
_global.main_trigger = false;
|
||||
}
|
||||
|
||||
@ -3462,9 +3473,9 @@ static void __exit exit_light(void)
|
||||
main_thread = NULL;
|
||||
MARS_DBG("=== stopping light thread...\n");
|
||||
MARS_INF("stopping thread...\n");
|
||||
mars_trigger();
|
||||
kthread_stop(thread);
|
||||
put_task_struct(thread);
|
||||
mars_trigger();
|
||||
}
|
||||
|
||||
brick_allow_freelist = false;
|
||||
|
@ -261,7 +261,7 @@ void __mars_trigger(void)
|
||||
{
|
||||
if (mars_global) {
|
||||
mars_global->main_trigger = true;
|
||||
wake_up_interruptible(&mars_global->main_event);
|
||||
wake_up_interruptible_all(&mars_global->main_event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -560,6 +560,7 @@ int mars_dent_work(struct mars_global *global, char *dirname, int allocsize, mar
|
||||
down_write(&global->dent_mutex);
|
||||
|
||||
restart:
|
||||
MARS_IO("at restart\n");
|
||||
found_dir = false;
|
||||
|
||||
/* First, get all the inode information in a separate pass
|
||||
@ -575,9 +576,11 @@ restart:
|
||||
continue;
|
||||
dent->d_version = version;
|
||||
|
||||
#ifdef CONFIG_MARS_USE_SYSLOG
|
||||
msleep(10); // yield
|
||||
#endif
|
||||
|
||||
MARS_IO("reading inode '%s'\n", dent->d_path);
|
||||
//MARS_IO("reading inode '%s'\n", dent->d_path);
|
||||
status = get_inode(dent->d_path, dent);
|
||||
total_status |= status;
|
||||
|
||||
@ -609,18 +612,23 @@ restart:
|
||||
* Here is a chance to mark some dents for removal
|
||||
* (or other types of non-destructive operations)
|
||||
*/
|
||||
MARS_IO("prep pass\n");
|
||||
for (tmp = global->dent_anchor.next, next = tmp->next; tmp != &global->dent_anchor; tmp = next, next = next->next) {
|
||||
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
#ifdef CONFIG_MARS_USE_SYSLOG
|
||||
msleep(10); // yield
|
||||
MARS_IO("forward prepare '%s'\n", dent->d_path);
|
||||
#endif
|
||||
//MARS_IO("forward prepare '%s'\n", dent->d_path);
|
||||
status = worker(buf, dent, true, false);
|
||||
if (status)
|
||||
MARS_IO("forward treat '%s' status = %d\n", dent->d_path, status);
|
||||
if (status) {
|
||||
//MARS_IO("forward treat '%s' status = %d\n", dent->d_path, status);
|
||||
}
|
||||
total_status |= status;
|
||||
}
|
||||
|
||||
/* Remove all dents marked for removal.
|
||||
*/
|
||||
MARS_IO("removal pass\n");
|
||||
for (tmp = global->dent_anchor.next, next = tmp->next; tmp != &global->dent_anchor; tmp = next, next = next->next) {
|
||||
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
if (!dent->d_killme)
|
||||
@ -635,28 +643,36 @@ restart:
|
||||
/* Forward pass.
|
||||
*/
|
||||
down_read(&global->dent_mutex);
|
||||
MARS_IO("forward pass\n");
|
||||
for (tmp = global->dent_anchor.next, next = tmp->next; tmp != &global->dent_anchor; tmp = next, next = next->next) {
|
||||
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
up_read(&global->dent_mutex);
|
||||
#ifdef CONFIG_MARS_USE_SYSLOG
|
||||
msleep(10); // yield
|
||||
MARS_IO("forward treat '%s'\n", dent->d_path);
|
||||
#endif
|
||||
//MARS_IO("forward treat '%s'\n", dent->d_path);
|
||||
status = worker(buf, dent, false, false);
|
||||
if (status)
|
||||
MARS_IO("forward treat '%s' status = %d\n", dent->d_path, status);
|
||||
if (status) {
|
||||
//MARS_IO("forward treat '%s' status = %d\n", dent->d_path, status);
|
||||
}
|
||||
down_read(&global->dent_mutex);
|
||||
total_status |= status;
|
||||
}
|
||||
|
||||
/* Backward pass.
|
||||
*/
|
||||
MARS_IO("forward pass\n");
|
||||
for (tmp = global->dent_anchor.prev, next = tmp->prev; tmp != &global->dent_anchor; tmp = next, next = next->prev) {
|
||||
struct mars_dent *dent = container_of(tmp, struct mars_dent, dent_link);
|
||||
up_read(&global->dent_mutex);
|
||||
#ifdef CONFIG_MARS_USE_SYSLOG
|
||||
msleep(10); // yield
|
||||
MARS_IO("backward treat '%s'\n", dent->d_path);
|
||||
#endif
|
||||
//MARS_IO("backward treat '%s'\n", dent->d_path);
|
||||
status = worker(buf, dent, false, true);
|
||||
if (status)
|
||||
MARS_IO("backward treat '%s' status = %d\n", dent->d_path, status);
|
||||
if (status) {
|
||||
//MARS_IO("backward treat '%s' status = %d\n", dent->d_path, status);
|
||||
}
|
||||
down_read(&global->dent_mutex);
|
||||
total_status |= status;
|
||||
if (status < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user