]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
DVR: config - replace cleanup threshold low/high with free/used
authorJaroslav Kysela <perex@perex.cz>
Thu, 3 Dec 2015 09:26:51 +0000 (10:26 +0100)
committerJaroslav Kysela <perex@perex.cz>
Thu, 3 Dec 2015 09:26:51 +0000 (10:26 +0100)
src/dvr/dvr.h
src/dvr/dvr_config.c
src/dvr/dvr_vfsmgr.c

index 70ed2cfd4f6c577266ae41b0830882c2d3455bf4..2fba8abee20d5ede975f482a3d968e9a8d83e971 100644 (file)
@@ -54,8 +54,8 @@ typedef struct dvr_config {
   uint32_t dvr_extra_time_post;
   uint32_t dvr_update_window;
   int dvr_running;
-  uint32_t dvr_cleanup_threshold_low;
-  uint32_t dvr_cleanup_threshold_high;
+  uint32_t dvr_cleanup_threshold_free;
+  uint32_t dvr_cleanup_threshold_used;
 
   muxer_config_t dvr_muxcnf;
 
index 08ed465628015951c9a703e7e01b9e2a3dc38566..b7f2bf60102a7684690668d8633b6c4ca64d1da9 100644 (file)
@@ -186,8 +186,8 @@ dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf)
   cfg->dvr_warm_time = 30;
   cfg->dvr_update_window = 24 * 3600;
   cfg->dvr_pathname = strdup("$t$n.$x");
-  cfg->dvr_cleanup_threshold_low = 200;
-  cfg->dvr_cleanup_threshold_high = 2000;
+  cfg->dvr_cleanup_threshold_free = 200;
+  cfg->dvr_cleanup_threshold_used = 2000;
 
   /* Muxer config */
   cfg->dvr_muxcnf.m_cache  = MC_CACHE_DONTKEEP;
@@ -517,10 +517,10 @@ dvr_config_save(dvr_config_t *cfg)
   lock_assert(&global_lock);
 
   dvr_config_storage_check(cfg);
-  if (cfg->dvr_cleanup_threshold_low < 50)
-    cfg->dvr_cleanup_threshold_low = 50; // as checking is only periodically, lower is not save
-  if (cfg->dvr_cleanup_threshold_high < cfg->dvr_cleanup_threshold_high)
-    cfg->dvr_cleanup_threshold_high = cfg->dvr_cleanup_threshold_low + 50;
+  if (cfg->dvr_cleanup_threshold_free < 50)
+    cfg->dvr_cleanup_threshold_free = 50; // as checking is only periodically, lower is not save
+  if (cfg->dvr_cleanup_threshold_used < cfg->dvr_cleanup_threshold_used)
+    cfg->dvr_cleanup_threshold_used = cfg->dvr_cleanup_threshold_free + 50;
   if (cfg->dvr_removal_days != DVR_RET_FOREVER &&
       cfg->dvr_removal_days > cfg->dvr_retention_days)
     cfg->dvr_retention_days = DVR_RET_ONREMOVE;
@@ -984,17 +984,17 @@ const idclass_t dvr_config_class = {
     },
     {
       .type     = PT_U32,
-      .id       = "storage-cleanup-low",
+      .id       = "storage-mfree",
       .name     = N_("Maintain free storage space (MiB)"),
-      .off      = offsetof(dvr_config_t, dvr_cleanup_threshold_low),
+      .off      = offsetof(dvr_config_t, dvr_cleanup_threshold_free),
       .def.i    = 200,
       .group    = 2,
     },
     {
       .type     = PT_U32,
-      .id       = "storage-cleanup-high",
+      .id       = "storage-mused",
       .name     = N_("Maintain used storage space (MiB)"),
-      .off      = offsetof(dvr_config_t, dvr_cleanup_threshold_high),
+      .off      = offsetof(dvr_config_t, dvr_cleanup_threshold_used),
       .def.i    = 2000,
       .group    = 2,
     },
index 7a13576c46ed9677aa06e1b1e11fb901e1dc8c83..e44fed591eb9a2c3eabb10ead5b39bc4cdf24215 100644 (file)
@@ -73,10 +73,10 @@ dvr_disk_space_cleanup(dvr_config_t *cfg)
 
   filesystemId  = diskdata.f_fsid;
   availBytes    = diskdata.f_bsize * (int64_t)diskdata.f_bavail;
-  requiredBytes = MIB(cfg->dvr_cleanup_threshold_low);
+  requiredBytes = MIB(cfg->dvr_cleanup_threshold_free);
   diskBytes     = diskdata.f_bsize * (int64_t)diskdata.f_blocks;
   usedBytes     = diskBytes - availBytes;
-  maximalBytes  = MIB(cfg->dvr_cleanup_threshold_high);
+  maximalBytes  = MIB(cfg->dvr_cleanup_threshold_used);
   configName    = cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile";
 
   /* When deleting a file from the disk, the system needs some time to actually do this */
@@ -192,8 +192,8 @@ dvr_disk_space_check()
     {
       availBytes = diskdata.f_bsize * (int64_t)diskdata.f_bavail;
       usedBytes = (diskdata.f_bsize * (int64_t)diskdata.f_blocks) - availBytes;
-      requiredBytes = MIB(cfg->dvr_cleanup_threshold_low);
-      maximalBytes = MIB(cfg->dvr_cleanup_threshold_high);
+      requiredBytes = MIB(cfg->dvr_cleanup_threshold_free);
+      maximalBytes = MIB(cfg->dvr_cleanup_threshold_used);
 
       if (availBytes < requiredBytes || maximalBytes > usedBytes) {
         LIST_FOREACH(de, &dvrentries, de_global_link) {