diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 795571370d..29a5940ff6 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -712,19 +712,27 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str) bool Datastore::get_avail_mb(long long &avail) { - long long max_used_size; + long long limit_mb; + long long free_limited; bool check; avail = free_mb; - if (get_template_attribute("MAX_USED_SIZE", max_used_size)) + if (get_template_attribute("LIMIT_MB", limit_mb)) { - if (used_mb >= max_used_size) + free_limited = limit_mb - used_mb; + + if (free_limited < free_mb) { - avail = 0; + avail = free_limited; } } + if (avail < 0) + { + avail = 0; + } + if (!get_template_attribute("DATASTORE_CAPACITY_CHECK", check)) { Nebula& nd = Nebula::instance(); diff --git a/src/scheduler/src/pool/DatastoreXML.cc b/src/scheduler/src/pool/DatastoreXML.cc index 51af194018..1f1cef16c4 100644 --- a/src/scheduler/src/pool/DatastoreXML.cc +++ b/src/scheduler/src/pool/DatastoreXML.cc @@ -48,7 +48,7 @@ void DatastoreXML::init_attributes() if (!strings.empty()) { long long limit_mb = atoll(strings[0].c_str()); - long long free_limited = limit_mb - (total_mb - free_mb); + long long free_limited = limit_mb - used_mb; if (free_limited < free_mb) {