From: Andre Noll Date: Thu, 5 Mar 2009 09:13:12 +0000 (+0100) Subject: Never remove the snapshot that is currently being created. X-Git-Tag: v0.1.2~1 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=cce86977bf64eadfece9911a30577a692f007bba;hp=064b878216517a8482e285003e92066b25cb6143 Never remove the snapshot that is currently being created. Thanks to Sebastian Stark for pointing out this bug. --- 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); }