]> git.tuebingen.mpg.de Git - dss.git/blobdiff - dss.c
Introduce --min-complete.
[dss.git] / dss.c
diff --git a/dss.c b/dss.c
index 3a2f46886c310f23b987665854c99e75334e44b0..9f39324500ffa915af5e0c593ae7d56d40eb5062 100644 (file)
--- 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)