Merge changes from topic "change_period" am: c0de6d8184 am: 3d81e0ba06
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2043104
Change-Id: I473b88c8b3b1e8dd6ee80fe56f513269fd997a4c
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/IdleMaint.cpp b/IdleMaint.cpp
index 3efcb50..2bfe3d9 100644
--- a/IdleMaint.cpp
+++ b/IdleMaint.cpp
@@ -547,7 +547,9 @@
std::string dirtySegmentsPath = f2fsSysfsPath + "/dirty_segments";
std::string gcSleepTimePath = f2fsSysfsPath + "/gc_urgent_sleep_time";
std::string gcUrgentModePath = f2fsSysfsPath + "/gc_urgent";
- std::string freeSegmentsStr, dirtySegmentsStr;
+ std::string ovpSegmentsPath = f2fsSysfsPath + "/ovp_segments";
+ std::string reservedBlocksPath = f2fsSysfsPath + "/reserved_blocks";
+ std::string freeSegmentsStr, dirtySegmentsStr, ovpSegmentsStr, reservedBlocksStr;
if (!ReadFileToString(freeSegmentsPath, &freeSegmentsStr)) {
PLOG(WARNING) << "Reading failed in " << freeSegmentsPath;
@@ -559,9 +561,21 @@
return;
}
+ if (!ReadFileToString(ovpSegmentsPath, &ovpSegmentsStr)) {
+ PLOG(WARNING) << "Reading failed in " << ovpSegmentsPath;
+ return;
+ }
+
+ if (!ReadFileToString(reservedBlocksPath, &reservedBlocksStr)) {
+ PLOG(WARNING) << "Reading failed in " << reservedBlocksPath;
+ return;
+ }
+
int32_t freeSegments = std::stoi(freeSegmentsStr);
int32_t dirtySegments = std::stoi(dirtySegmentsStr);
+ int32_t reservedBlocks = std::stoi(ovpSegmentsStr) + std::stoi(reservedBlocksStr);
+ freeSegments = freeSegments > reservedBlocks ? freeSegments - reservedBlocks : 0;
neededSegments *= reclaimWeight;
if (freeSegments >= neededSegments) {
LOG(INFO) << "Enough free segments: " << freeSegments