From: Andre Noll Date: Wed, 26 Aug 2009 11:24:12 +0000 (+0200) Subject: Make snapshot creation trump snapshot removal. X-Git-Tag: v0.1.4~23 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=0ba29646cbd80a8bb7bdf827352bd1332217c398;p=dss.git Make snapshot creation trump snapshot removal. This patch changes the behaviour of dss in case the following three conditions are all met: (1) There is at least one snapshot which could be deleted (orphaned, redundant, outdated). (2) Disk space is not low. (3) A new snapshot is due. A common case where these conditions are fulfilled is when dss is started after it was not running for some time, for example due to a server crash on Friday evening... In this situation the old code created a new snapshot only after all orphaned/redundant/outdated have been removed, which can take hours and is not what one usually wants to happen in the above mentioned scenario. Instead, it is desirable to create a new snapshot ASAP, and only after this snapshot has been created, the removal of old snapshots should take place. This patch implements this behaviour and goes even one step further: If disk space is not low and a new snapshot is due or being created, dss won't trigger snapshot removal any more. Another positive side effect of this change is that snapshot creation times become more stable since the rsync process will only be interrupted by a rm process if disk space is low. --- diff --git a/dss.c b/dss.c index d7d3e16..6101f17 100644 --- a/dss.c +++ b/dss.c @@ -449,8 +449,14 @@ static int try_to_free_disk_space(void) gettimeofday(&now, NULL); if (tv_diff(&next_removal_check, &now, NULL) > 0) return 0; - if (!low_disk_space && conf.keep_redundant_given) - return 0; + if (!low_disk_space) { + if (conf.keep_redundant_given) + return 0; + if (snapshot_creation_status != HS_READY) + return 0; + if (next_snapshot_is_due()) + return 0; + } dss_get_snapshot_list(&sl); ret = 0; if (!low_disk_space && sl.num_snapshots <= 1)