From df0f43097725cb92fd1e80fac88fcf8e45d09266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Tue, 26 Nov 2013 17:26:46 +0100 Subject: [PATCH] Feature #2494: Change the meaning of limit_mb, add it to oned Now limit_mb does not replace total_mb. It is the max amount of storage that OpenNebula will use, regardless of the total disk or the usage of the disk outside the DS dir (cherry picked from commit 37af594b979bd5abf57cdd41b2abfc77c937dd6e) --- src/datastore/Datastore.cc | 16 ++++++++++++---- src/scheduler/src/pool/DatastoreXML.cc | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) 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) {