Fix return value of remove_oldest_snapshot().
authorAndre Noll <maan@systemlinux.org>
Tue, 5 May 2009 08:53:43 +0000 (10:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Tue, 5 May 2009 08:53:43 +0000 (10:53 +0200)
We _must_ return non-zero if the remove was initiated. The old code
would exit with

try_to_free_disk_space: uhuhu: not enough disk space for a single snapshot

even though there are plenty of snapshots available that can be deleted.

dss.c

diff --git a/dss.c b/dss.c
index c0597f3..27c14b6 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -367,6 +367,7 @@ static int remove_outdated_snapshot(struct snapshot_list *sl)
 
 static int remove_oldest_snapshot(struct snapshot_list *sl)
 {
+       int ret;
        struct snapshot *s = get_oldest_snapshot(sl);
 
        if (!s) /* no snapshot found */
@@ -374,7 +375,10 @@ static int remove_oldest_snapshot(struct snapshot_list *sl)
        DSS_INFO_LOG("oldest snapshot: %s\n", s->name);
        if (snapshot_is_being_created(s))
                return 0;
-       return pre_remove_hook(s, "oldest");
+       ret = pre_remove_hook(s, "oldest");
+       if (ret < 0)
+               return ret;
+       return 1;
 }
 
 static int rename_incomplete_snapshot(int64_t start)