X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=blobdiff_plain;f=dss.c;h=c64156188bc753f7ee264f7434db1e254bbbc8f2;hp=0ad7a35989a75e893fe40e30d84d1ff18f4d94ff;hb=31638f52b0fe420f4881dca4afdecf7132d1ab91;hpb=8daf8f3836e745ba07f1aa01252279588574c95a diff --git a/dss.c b/dss.c index 0ad7a35..c641561 100644 --- a/dss.c +++ b/dss.c @@ -531,17 +531,25 @@ static struct snapshot *find_outdated_snapshot(struct snapshot_list *sl) static struct snapshot *find_oldest_removable_snapshot(struct snapshot_list *sl) { - int i; - struct snapshot *s; + int i, num_complete; + struct snapshot *s, *ref = NULL; + + num_complete = num_complete_snapshots(sl); + if (num_complete <= conf.min_complete_arg) + return NULL; FOR_EACH_SNAPSHOT(s, i, sl) { if (snapshot_is_being_created(s)) continue; - if (is_reference_snapshot(s)) + if (is_reference_snapshot(s)) { /* avoid this one */ + ref = s; continue; + } DSS_INFO_LOG(("oldest removable snapshot: %s\n", s->name)); return s; } - return NULL; + assert(ref); + DSS_WARNING_LOG(("removing reference snapshot %s\n", ref->name)); + return ref; } static int rename_incomplete_snapshot(int64_t start) @@ -1512,6 +1520,7 @@ int main(int argc, char **argv) if (ret < 0) goto out; ret = call_command_handler(); + signal_shutdown(); out: if (ret < 0) DSS_EMERG_LOG(("%s\n", dss_strerror(-ret)));