From 3a3ce9f2b287333e6a3032caee1588cf42ab72be Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 14 Sep 2022 18:20:38 -0700 Subject: [PATCH] scheduler: calculate max disk usage based on user prefs correctly. If max_used_gb or max_used_pct are zero (in client prefs) treat as "no limit". --- sched/sched_config.cpp | 6 +----- sched/sched_config.h | 2 -- sched/sched_send.cpp | 41 ++++++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/sched/sched_config.cpp b/sched/sched_config.cpp index 2f1a5bf9bf..e3a0c71ee9 100644 --- a/sched/sched_config.cpp +++ b/sched/sched_config.cpp @@ -83,9 +83,7 @@ int SCHED_CONFIG::parse(FILE* f) { locality_scheduling_workunit_file = new vector; locality_scheduling_sticky_file = new vector; max_wus_to_send = 10; - default_disk_max_used_gb = 100.; - default_disk_max_used_pct = 50.; - default_disk_min_free_gb = .001; + default_disk_min_free_gb = 1; sched_debug_level = MSG_NORMAL; fuh_debug_level = MSG_NORMAL; fuh_set_initial_permission = -1; @@ -224,8 +222,6 @@ int SCHED_CONFIG::parse(FILE* f) { continue; } if (xp.parse_int("daily_result_quota", daily_result_quota)) continue; - if (xp.parse_double("default_disk_max_used_gb", default_disk_max_used_gb)) continue; - if (xp.parse_double("default_disk_max_used_pct", default_disk_max_used_pct)) continue; if (xp.parse_double("default_disk_min_free_gb", default_disk_min_free_gb)) continue; if (xp.parse_bool("dont_store_success_stderr", dont_store_success_stderr)) continue; if (xp.parse_int("file_deletion_strategy", file_deletion_strategy)) continue; diff --git a/sched/sched_config.h b/sched/sched_config.h index 96ec0b6489..c4333b7c16 100644 --- a/sched/sched_config.h +++ b/sched/sched_config.h @@ -111,8 +111,6 @@ struct SCHED_CONFIG { int daily_result_quota; // max results per day is this * mult char debug_req_reply_dir[256]; // keep sched_request and sched_reply in files in this directory - double default_disk_max_used_gb; - double default_disk_max_used_pct; double default_disk_min_free_gb; vector dont_search_host_for_userid; bool dont_store_success_stderr; diff --git a/sched/sched_send.cpp b/sched/sched_send.cpp index 1974e3b8eb..223fd87fc4 100644 --- a/sched/sched_send.cpp +++ b/sched/sched_send.cpp @@ -348,20 +348,12 @@ static void get_reliability_and_trust() { double max_allowable_disk() { HOST host = g_request->host; GLOBAL_PREFS prefs = g_request->global_prefs; - double x1, x2, x3, x; + double x, x1=0, x2=0, x3; // defaults are from config.xml // if not there these are used: - // -default_max_used_gb= 100 - // -default_max_used_pct = 50 - // -default_min_free_gb = .001 + // default_disk_min_free_gb = 1 // - if (prefs.disk_max_used_gb == 0) { - prefs.disk_max_used_gb = config.default_disk_max_used_gb; - } - if (prefs.disk_max_used_pct == 0) { - prefs.disk_max_used_pct = config.default_disk_max_used_pct; - } if (prefs.disk_min_free_gb < config.default_disk_min_free_gb) { prefs.disk_min_free_gb = config.default_disk_min_free_gb; } @@ -374,17 +366,32 @@ double max_allowable_disk() { // The post 4 oct 2005 case. // Compute the max allowable additional disk usage based on prefs // - x1 = prefs.disk_max_used_gb*GIGA - host.d_boinc_used_total; - x2 = host.d_total * prefs.disk_max_used_pct / 100.0 - - host.d_boinc_used_total; - x3 = host.d_free - prefs.disk_min_free_gb*GIGA; // may be negative - x = std::min(x1, std::min(x2, x3)); + x3 = host.d_free - prefs.disk_min_free_gb*GIGA; + // may be negative + x = x3; + int which = 3; + if (prefs.disk_max_used_pct > 0) { + x2 = host.d_total * prefs.disk_max_used_pct / 100.0 + - host.d_boinc_used_total; + if (x2 < x) { + x = x2; + which = 2; + } + } + if (prefs.disk_max_used_gb > 0) { + x1 = prefs.disk_max_used_gb*GIGA - host.d_boinc_used_total; + if (x1 < x) { + x = x1; + which = 1; + } + } // see which bound is the most stringent + // (for client notification in sched_locality.cpp) // - if (x==x1) { + if (which == 1) { g_reply->disk_limits.max_used = x; - } else if (x==x2) { + } else if (which == 2) { g_reply->disk_limits.max_frac = x; } else { g_reply->disk_limits.min_free = x;