From 0ba29646cbd80a8bb7bdf827352bd1332217c398 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Wed, 26 Aug 2009 13:24:12 +0200 Subject: [PATCH] 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. --- dss.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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) -- 2.39.5