diff options
author | Daeho Jeong <daehojeong@google.com> | 2022-03-25 10:02:57 -0700 |
---|---|---|
committer | Daeho Jeong <daehojeong@google.com> | 2022-03-25 10:06:13 -0700 |
commit | 3ccdeb3fbbb1bf6177ae550b882e6a7bdb24cd74 (patch) | |
tree | 7c8ebd2e85380ca9814fe992cacb63f4d73d7b68 | |
parent | 0b5f397e2b8b392379483553ea0b45cb3f0715e2 (diff) | |
download | vold-3ccdeb3fbbb1bf6177ae550b882e6a7bdb24cd74.tar.gz |
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
-rw-r--r-- | IdleMaint.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/IdleMaint.cpp b/IdleMaint.cpp index 3efcb504..2bfe3d9a 100644 --- a/IdleMaint.cpp +++ b/IdleMaint.cpp @@ -547,7 +547,9 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float 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 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float 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 |