]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Introduce prune --disk-space.
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 7 Feb 2019 22:05:34 +0000 (23:05 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 21 Sep 2019 13:11:09 +0000 (15:11 +0200)
The new option takes a mandatory argument of the set {check, high,
low}. The latter two make the command act as if disk space was
high/low without actually performing the check. This is mostly useful
for debugging.

dss.c
dss.suite

diff --git a/dss.c b/dss.c
index e2ee7dd66e511199c42821cbc32cf0a8ddf727ad..4396e6e5975c79d2806aa39625fea99d23a2ee90 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1660,14 +1660,21 @@ static int com_prune(void)
        struct snapshot *victim;
        struct disk_space ds;
        char *why;
+       bool try_hard;
 
        lock_dss_or_die();
-       ret = get_disk_space(".", &ds);
-       if (ret < 0)
-               return ret;
-       log_disk_space(&ds);
+       switch (OPT_UINT32_VAL(PRUNE, DISK_SPACE)) {
+       case FDS_LOW: try_hard = true; break;
+       case FDS_HIGH: try_hard = false; break;
+       default:
+               ret = get_disk_space(".", &ds);
+               if (ret < 0)
+                       return ret;
+               log_disk_space(&ds);
+               try_hard = disk_space_low(&ds);
+       }
        dss_get_snapshot_list(&sl);
-       victim = find_removable_snapshot(&sl, disk_space_low(&ds), &why);
+       victim = find_removable_snapshot(&sl, try_hard, &why);
        if (!victim) {
                dss_msg("nothing to prune\n");
                ret = 0;
index 2719827700a33809b8bf2714f58518b550c4a104..f9cf8af5993345452fddc7b3d9790d0d7e6d7a13 100644 (file)
--- a/dss.suite
+++ b/dss.suite
@@ -466,6 +466,22 @@ caption = Subcommands
 
                The subcommand fails if there is another dss "run" process.
        [/description]
+       [option disk-space]
+               summary = act as if free disk space was high/low
+               arg_info = required_arg
+               arg_type = string
+               typestr = mode
+               values = {
+                       FDS_CHECK = "check",
+                       FDS_HIGH = "high",
+                       FDS_LOW = "low"
+               }
+               default_val = check
+               [help]
+                       By default, free disk space is checked and even regular snapshots
+                       become candidates for removal if disk space is low. This option
+                       overrides the result of the check.
+               [/help]
 [subcommand ls]
        purpose = print the list of all snapshots
        [description]