summaryrefslogtreecommitdiffstats
path: root/dump_manager.cpp
diff options
context:
space:
mode:
authorJayanth Othayoth <ojayanth@in.ibm.com>2017-08-09 06:19:32 -0500
committerPatrick Williams <patrick@stwcx.xyz>2017-08-22 20:48:18 +0000
commit104f57cf9c9067c8e431923406e6bc0bd67a5e5c (patch)
treea09f7128f131bc54bd67b66c896d6b4e25c3a9b9 /dump_manager.cpp
parentab7f920942ff0b6337b641b6f80ad6025e120220 (diff)
downloadphosphor-debug-collector-104f57cf9c9067c8e431923406e6bc0bd67a5e5c.tar.gz
phosphor-debug-collector-104f57cf9c9067c8e431923406e6bc0bd67a5e5c.zip
Enhancement of Dump cap algorithm
Added support for collecting mini dump data incase available dump size is less than maximum dump size. Introduced minimum dump size to achieve this. Change-Id: I266ff6ea71443974a99f6f5fe54fb9f12c90f2ab Signed-off-by: Jayanth Othayoth <ojayanth@in.ibm.com>
Diffstat (limited to 'dump_manager.cpp')
-rw-r--r--dump_manager.cpp37
1 files changed, 21 insertions, 16 deletions
diff --git a/dump_manager.cpp b/dump_manager.cpp
index 80e117b..ef840f3 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -81,17 +81,11 @@ uint32_t Manager::captureDump(
elog<InternalFailure>();
}
- //Increment active dump count.
- activeDumpCount++;
-
return ++lastEntryId;
}
void Manager::createEntry(const fs::path& file)
{
- //Decrement the Dump in progress counter.
- activeDumpCount = (activeDumpCount == 0 ? 0 : activeDumpCount - 1);
-
//Dump File Name format obmcdump_ID_EPOCHTIME.EXT
static constexpr auto ID_POS = 1;
static constexpr auto EPOCHTIME_POS = 2;
@@ -214,22 +208,33 @@ size_t Manager::getAllowedSize()
auto size = 0;
- // Maximum number of dump is based on total dump size
- // and individual dump Max size configured in the system.
- // Set the new dump size to max, in case sum of available
- // dump and active dumps is less than maximum number of dumps.
-
- constexpr auto dumpCount = BMC_DUMP_TOTAL_SIZE / BMC_DUMP_MAX_SIZE;
-
- if ((entries.size() + activeDumpCount) < dumpCount)
+ //Get current size of the dump directory.
+ for (const auto& p : fs::recursive_directory_iterator(BMC_DUMP_PATH))
{
- size = BMC_DUMP_MAX_SIZE;
+ if (!fs::is_directory(p))
+ {
+ size += fs::file_size(p);
+ }
}
- else
+
+ //Convert size into KB
+ size = size / 1024;
+
+ //Set the Dump size to Maximum if the free space is greater than
+ //Dump max size otherwise return the available size.
+
+ size = (size > BMC_DUMP_TOTAL_SIZE ? 0 : BMC_DUMP_TOTAL_SIZE - size);
+
+ if (size < BMC_DUMP_MIN_SPACE_REQD)
{
//Reached to maximum limit
elog<QuotaExceeded>(Reason("Not enough space: Delete old dumps"));
}
+ if (size > BMC_DUMP_MAX_SIZE)
+ {
+ size = BMC_DUMP_MAX_SIZE;
+ }
+
return size;
}
OpenPOWER on IntegriCloud