From: Andre Noll Date: Thu, 27 Aug 2009 12:55:02 +0000 (+0200) Subject: Fix off-by-one bug in find_outdated_snapshot(). X-Git-Tag: v0.1.4~22 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=676f0d8d399ade79ff579e28787a63f00bdf2ce3 Fix off-by-one bug in find_outdated_snapshot(). 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. --- diff --git a/dss.c b/dss.c index 6101f17..f04be8f 100644 --- 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 23f2685..506fbf1 100644 --- 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