vold: remove overprovision area from free segments
overprovision space and reserved area should be subtracted when we
calculate free segments count in GC for data blocks.
Test: check Vold setGCUrgentPace log
Bug: 202283480
Bug: 181079477
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Change-Id: I7b749588ff794ff0429e17a787d83bcc19af0ec1
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