]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Fix off-by-one bug in find_outdated_snapshot().
authorAndre Noll <maan@systemlinux.org>
Thu, 27 Aug 2009 12:55:02 +0000 (14:55 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 27 Aug 2009 12:55:02 +0000 (14:55 +0200)
The man page sayeth:

"dss removes any snapshots older than n times u",

where n is the number of unit intervals and u is the duration of
a unit interval. As intervals count from zero, this means that a
snapshot should be considered outdated if its interval number
is greater _or equal_ than n.

However, the current code only removes snapshots in intervals
strictly greater than n. Fix this bug and clarify the documentation.

dss.c
dss.ggo

diff --git a/dss.c b/dss.c
index 6101f17742c7ba8ef6e3a57a1878dfccb7227feb..f04be8f95595a41b33478a1823ea77f53389ca35 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -385,14 +385,14 @@ static struct snapshot *find_outdated_snapshot(struct snapshot_list *sl)
        int i;
        struct snapshot *s;
 
-       DSS_DEBUG_LOG("looking for snapshots belonging to intervals greater than %d\n",
+       DSS_DEBUG_LOG("looking for snapshots belonging to intervals >= %d\n",
                conf.num_intervals_arg);
        FOR_EACH_SNAPSHOT(s, i, sl) {
                if (snapshot_is_being_created(s))
                        continue;
                if (is_reference_snapshot(s))
                        continue;
-               if (s->interval <= conf.num_intervals_arg)
+               if (s->interval < conf.num_intervals_arg)
                        continue;
                return s;
        }
diff --git a/dss.ggo b/dss.ggo
index 23f268580313a6d3437ef75f1ab8a4cf9fa6c839..506fbf105433fed61631ad965e5b8295068cbfe7 100644 (file)
--- a/dss.ggo
+++ b/dss.ggo
@@ -110,11 +110,17 @@ groupoption "prune" P
 "Remove redundant and outdated snapshots"
 group="command"
 details="
-       A snapshot is considered outdated if it belongs to an interval
-       greater than the maximum number of intervals. It is said to be
-       redundant if it belongs to an interval that already contains
-       more than the desired number of snapshots. This command gets
-       rid of such snapshots.
+       A snapshot is considered outdated if its interval number
+       is greater or equal than the specified number of unit
+       intervals. See the \"Intervals\" section below for the precise
+       definition of these terms.
+
+       A snapshot is said to be redundant if it belongs to an
+       interval that already contains more than the desired number
+       of snapshots.
+
+       The prune command gets rid of both outdated and redundant
+       snapshots.
 "
 
 groupoption "ls" L