]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Make snapshot creation trump snapshot removal.
authorAndre Noll <maan@systemlinux.org>
Wed, 26 Aug 2009 11:24:12 +0000 (13:24 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 26 Aug 2009 11:24:12 +0000 (13:24 +0200)
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

diff --git a/dss.c b/dss.c
index d7d3e1649d69b849e99cf221ecead9e5a8e61daa..6101f17742c7ba8ef6e3a57a1878dfccb7227feb 100644 (file)
--- 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;
        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)
        dss_get_snapshot_list(&sl);
        ret = 0;
        if (!low_disk_space && sl.num_snapshots <= 1)