summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Noll <maan@systemlinux.org>2009-03-05 10:13:12 +0100
committerAndre Noll <maan@systemlinux.org>2009-03-05 10:13:12 +0100
commitcce86977bf64eadfece9911a30577a692f007bba (patch)
tree741fe8f0efd3b8e1abed11628e261aece510b705
parent064b878216517a8482e285003e92066b25cb6143 (diff)
Never remove the snapshot that is currently being created.
Thanks to Sebastian Stark for pointing out this bug.
-rw-r--r--dss.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/dss.c b/dss.c
index d57daba..82cdc94 100644
--- a/dss.c
+++ b/dss.c
@@ -209,6 +209,11 @@ out:
return ret;
}
+static int snapshot_is_being_created(struct snapshot *s)
+{
+ return s->creation_time == current_snapshot_creation_time;
+}
+
/*
* return: 0: no redundant snapshots, 1: rm process started, negative: error
*/
@@ -235,6 +240,8 @@ static int remove_redundant_snapshot(struct snapshot_list *sl)
FOR_EACH_SNAPSHOT(s, i, sl) {
int64_t this_score;
+ if (snapshot_is_being_created(s))
+ continue;
//DSS_DEBUG_LOG("checking %s\n", s->name);
if (s->interval > interval) {
prev = s;
@@ -278,6 +285,8 @@ static int remove_outdated_snapshot(struct snapshot_list *sl)
DSS_DEBUG_LOG("looking for snapshots belonging to intervals greater than %d\n",
conf.num_intervals_arg);
FOR_EACH_SNAPSHOT(s, i, sl) {
+ if (snapshot_is_being_created(s))
+ continue;
if (s->interval <= conf.num_intervals_arg)
continue;
if (conf.dry_run_given) {
@@ -300,8 +309,8 @@ static int remove_oldest_snapshot(struct snapshot_list *sl)
if (!s) /* no snapshot found */
return 0;
DSS_INFO_LOG("oldest snapshot: %s\n", s->name);
- if (s->creation_time == current_snapshot_creation_time)
- return 0; /* do not remove the snapshot currently being created */
+ if (snapshot_is_being_created(s))
+ return 0;
return remove_snapshot(s);
}