Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
DVR: config - replace cleanup threshold low/high with free/used
  • Loading branch information
perexg committed Dec 3, 2015
1 parent 7040074 commit 11c5330
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/dvr/dvr.h
Expand Up @@ -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;

Expand Down
20 changes: 10 additions & 10 deletions src/dvr/dvr_config.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
},
Expand Down
8 changes: 4 additions & 4 deletions src/dvr/dvr_vfsmgr.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 11c5330

Please sign in to comment.