vold: do not set gc sleep time with zero dirty segments am: 0b5f397e2b
Original change: https://android-review.googlesource.com/c/platform/system/vold/+/2033123 Change-Id: I30d462858c6b3acc8e7aebc9bed55deb4716db14 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
f605ac329b
1 changed files with 13 additions and 12 deletions
|
@ -534,6 +534,7 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float
|
||||||
float reclaimWeight, int32_t gcPeriod) {
|
float reclaimWeight, int32_t gcPeriod) {
|
||||||
std::list<std::string> paths;
|
std::list<std::string> paths;
|
||||||
bool needGC = true;
|
bool needGC = true;
|
||||||
|
int32_t sleepTime;
|
||||||
|
|
||||||
addFromFstab(&paths, PathTypes::kBlkDevice, true);
|
addFromFstab(&paths, PathTypes::kBlkDevice, true);
|
||||||
if (paths.empty()) {
|
if (paths.empty()) {
|
||||||
|
@ -570,6 +571,18 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float
|
||||||
LOG(INFO) << "The sum of free segments: " << freeSegments
|
LOG(INFO) << "The sum of free segments: " << freeSegments
|
||||||
<< ", dirty segments: " << dirtySegments << " is under " << minSegmentThreshold;
|
<< ", dirty segments: " << dirtySegments << " is under " << minSegmentThreshold;
|
||||||
needGC = false;
|
needGC = false;
|
||||||
|
} else {
|
||||||
|
neededSegments -= freeSegments;
|
||||||
|
neededSegments = std::min(neededSegments, (int32_t)(dirtySegments * dirtyReclaimRate));
|
||||||
|
if (neededSegments == 0) {
|
||||||
|
LOG(INFO) << "Low dirty segments: " << dirtySegments;
|
||||||
|
needGC = false;
|
||||||
|
} else {
|
||||||
|
sleepTime = gcPeriod * ONE_MINUTE_IN_MS / neededSegments;
|
||||||
|
if (sleepTime < MIN_GC_URGENT_SLEEP_TIME) {
|
||||||
|
sleepTime = MIN_GC_URGENT_SLEEP_TIME;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!needGC) {
|
if (!needGC) {
|
||||||
|
@ -579,18 +592,6 @@ void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t sleepTime;
|
|
||||||
|
|
||||||
neededSegments -= freeSegments;
|
|
||||||
neededSegments = std::min(neededSegments, (int32_t)(dirtySegments * dirtyReclaimRate));
|
|
||||||
if (neededSegments == 0) {
|
|
||||||
sleepTime = MIN_GC_URGENT_SLEEP_TIME;
|
|
||||||
} else {
|
|
||||||
sleepTime = gcPeriod * ONE_MINUTE_IN_MS / neededSegments;
|
|
||||||
if (sleepTime < MIN_GC_URGENT_SLEEP_TIME) {
|
|
||||||
sleepTime = MIN_GC_URGENT_SLEEP_TIME;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!WriteStringToFile(std::to_string(sleepTime), gcSleepTimePath)) {
|
if (!WriteStringToFile(std::to_string(sleepTime), gcSleepTimePath)) {
|
||||||
PLOG(WARNING) << "Writing failed in " << gcSleepTimePath;
|
PLOG(WARNING) << "Writing failed in " << gcSleepTimePath;
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue