X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=dss.c;h=bdbdd043ef8c4651bf921a72050526b84c968a6d;hp=07a60425170ddab063ee6071d4901993a9db8c62;hb=59a00ae47578272f3ca9cf882ebeb5dfe16ba6c6;hpb=01ed0597ca37173df783d9a6816cf13d7a1435f9 diff --git a/dss.c b/dss.c index 07a6042..bdbdd04 100644 --- a/dss.c +++ b/dss.c @@ -606,9 +606,18 @@ static int try_to_free_disk_space(void) if (next_snapshot_is_due()) return 0; } + /* + * Idle and --keep_redundant not given, or low disk space. Look at + * existing snapshots. + */ dss_get_snapshot_list(&sl); ret = 0; - if (!low_disk_space && sl.num_snapshots <= 1) + /* + * Don't remove anything if there is free space and we have fewer + * snapshots than configured, plus one. This way there is always one + * snapshot that can be recycled. + */ + if (!low_disk_space && sl.num_snapshots <= 1 << conf.num_intervals_arg) goto out; why = "outdated"; victim = find_outdated_snapshot(&sl); @@ -618,13 +627,13 @@ static int try_to_free_disk_space(void) victim = find_redundant_snapshot(&sl); if (victim) goto remove; - /* try harder only if disk space is low */ - if (!low_disk_space) - goto out; why = "orphaned"; victim = find_orphaned_snapshot(&sl); if (victim) goto remove; + /* try harder only if disk space is low */ + if (!low_disk_space) + goto out; DSS_WARNING_LOG(("disk space low and nothing obvious to remove\n")); victim = find_oldest_removable_snapshot(&sl); if (victim) @@ -1480,12 +1489,6 @@ static int setup_signal_handling(void) return install_sighandler(SIGCHLD); } -/** - * The main function of dss. - * - * \param argc Usual argument count. - * \param argv Usual argument vector. - */ int main(int argc, char **argv) { int ret;