X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=dss.c;h=a895019a19bac91b7ca66d46a63373ead0123c97;hp=0bc891373bd7e6096063ebc45aa953582433d68c;hb=refs%2Fheads%2Fmaint;hpb=0f2b297697d2c5d0ab9ee71d51c2e47fb4508aba diff --git a/dss.c b/dss.c index 0bc8913..a895019 100644 --- a/dss.c +++ b/dss.c @@ -5,12 +5,14 @@ */ #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -303,7 +305,7 @@ static int64_t compute_next_snapshot_time(void) int64_t x = 0, now = get_current_time(), unit_interval = 24 * 3600 * conf.unit_interval_arg, ret; unsigned wanted = desired_number_of_snapshots(0, conf.num_intervals_arg), - num_complete_snapshots = 0; + num_complete = 0; int i; struct snapshot *s = NULL; struct snapshot_list sl; @@ -312,15 +314,15 @@ static int64_t compute_next_snapshot_time(void) FOR_EACH_SNAPSHOT(s, i, &sl) { if (!(s->flags & SS_COMPLETE)) continue; - num_complete_snapshots++; + num_complete++; x += s->completion_time - s->creation_time; } assert(x >= 0); ret = now; - if (num_complete_snapshots == 0) + if (num_complete == 0) goto out; - x /= num_complete_snapshots; /* avg time to create one snapshot */ + x /= num_complete; /* avg time to create one snapshot */ if (unit_interval < x * wanted) /* oops, no sleep at all */ goto out; ret = s->completion_time + unit_interval / wanted - x; @@ -635,6 +637,7 @@ static int try_to_free_disk_space(void) if (!low_disk_space) goto out; DSS_WARNING_LOG(("disk space low and nothing obvious to remove\n")); + why = "oldest"; victim = find_oldest_removable_snapshot(&sl); if (victim) goto remove; @@ -977,7 +980,7 @@ static int check_config(void) * Returns < 0 on errors, 0 if no config file is given and > 0 if the config * file was read successfully. */ -static int parse_config_file(int override) +static int parse_config_file(bool sighup) { int ret, config_file_exists; char *config_file = get_config_file_name(); @@ -985,7 +988,7 @@ static int parse_config_file(int override) char *old_logfile_arg = NULL; int old_daemon_given = 0; - if (override) { /* SIGHUP */ + if (sighup) { if (conf.logfile_given) old_logfile_arg = dss_strdup(conf.logfile_arg); old_daemon_given = conf.daemon_given; @@ -999,12 +1002,12 @@ static int parse_config_file(int override) } if (config_file_exists) { struct cmdline_parser_params params; - params.override = override; + params.override = sighup; params.initialize = 0; params.check_required = 1; params.check_ambiguity = 0; params.print_errors = 1; - if (override) { /* invalidate all rsync options */ + if (sighup) { /* invalidate all rsync options */ int i; for (i = 0; i < conf.rsync_option_given; i++) { @@ -1018,7 +1021,7 @@ static int parse_config_file(int override) ret = check_config(); if (ret < 0) goto out; - if (override) { + if (sighup) { /* don't change daemon mode on SIGHUP */ conf.daemon_given = old_daemon_given; close_log(logfile); @@ -1055,7 +1058,7 @@ static int handle_sighup(void) DSS_NOTICE_LOG(("SIGHUP, re-reading config\n")); dump_dss_config("old"); - ret = parse_config_file(1); + ret = parse_config_file(true /* SIGHUP */); if (ret < 0) return ret; dump_dss_config("reloaded"); @@ -1155,11 +1158,11 @@ static int rename_resume_snap(int64_t creation_time) s = find_orphaned_snapshot(&sl); out: if (s) { - DSS_INFO_LOG(("reusing %s snapshot %s\n", why, s->name)); + DSS_NOTICE_LOG(("recycling %s snapshot %s\n", why, s->name)); ret = dss_rename(s->name, new_name); } if (ret >= 0) - DSS_NOTICE_LOG(("creating new snapshot %s\n", new_name)); + DSS_NOTICE_LOG(("creating %s\n", new_name)); free(new_name); free_snapshot_list(&sl); return ret; @@ -1506,6 +1509,7 @@ int main(int argc, char **argv) cmdline_parser_ext(argc, argv, &conf, ¶ms); /* aborts on errors */ ret = parse_config_file(0); + ret = parse_config_file(false /* no SIGHUP */); if (ret < 0) goto out; if (ret == 0) { /* no config file given */ @@ -1513,7 +1517,6 @@ int main(int argc, char **argv) * Parse the command line options again, but this time check * that all required options are given. */ - struct cmdline_parser_params params; params.override = 1; params.initialize = 1; params.check_required = 1;