vold: add gc period in setGCUrgentPace
To make gc period changable, added a new gcPeriod parameter to
setGCUrgentPace.
Test: adb shell device_config put storage_native_boot smart_idle_maint_period 10
Bug: 202283480
Bug: 181079477
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Change-Id: I4e44a80ea5b51d9a7cde69d25e129dd0673b271f
diff --git a/IdleMaint.cpp b/IdleMaint.cpp
index 2fc0d4b..597d609 100644
--- a/IdleMaint.cpp
+++ b/IdleMaint.cpp
@@ -87,7 +87,7 @@
static const int DEVGC_TIMEOUT_SEC = 120;
static const int KBYTES_IN_SEGMENT = 2048;
static const int MIN_GC_URGENT_SLEEP_TIME = 500;
-static const int ONE_HOUR_IN_MS = 3600000;
+static const int ONE_MINUTE_IN_MS = 60000;
static const int GC_NORMAL_MODE = 0;
static const int GC_URGENT_MID_MODE = 3;
@@ -531,7 +531,7 @@
}
void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate,
- float reclaimWeight) {
+ float reclaimWeight, int32_t gcPeriod) {
std::list<std::string> paths;
bool needGC = true;
@@ -586,7 +586,7 @@
if (neededSegments == 0) {
sleepTime = MIN_GC_URGENT_SLEEP_TIME;
} else {
- sleepTime = ONE_HOUR_IN_MS / neededSegments;
+ sleepTime = gcPeriod * ONE_MINUTE_IN_MS / neededSegments;
if (sleepTime < MIN_GC_URGENT_SLEEP_TIME) {
sleepTime = MIN_GC_URGENT_SLEEP_TIME;
}
diff --git a/IdleMaint.h b/IdleMaint.h
index ae70b63..9a2af4a 100644
--- a/IdleMaint.h
+++ b/IdleMaint.h
@@ -27,7 +27,7 @@
int AbortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
int32_t GetStorageLifeTime();
void SetGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold, float dirtyReclaimRate,
- float reclaimWeight);
+ float reclaimWeight, int32_t gcPeriod);
void RefreshLatestWrite();
int32_t GetWriteAmount();
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index f5fb908..71eaddc 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -494,11 +494,12 @@
binder::Status VoldNativeService::setGCUrgentPace(int32_t neededSegments,
int32_t minSegmentThreshold,
- float dirtyReclaimRate, float reclaimWeight) {
+ float dirtyReclaimRate, float reclaimWeight,
+ int32_t gcPeriod) {
ENFORCE_SYSTEM_OR_ROOT;
ACQUIRE_LOCK;
- SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight);
+ SetGCUrgentPace(neededSegments, minSegmentThreshold, dirtyReclaimRate, reclaimWeight, gcPeriod);
return Ok();
}
diff --git a/VoldNativeService.h b/VoldNativeService.h
index 88fc9e7..1a85296 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -90,7 +90,7 @@
binder::Status abortIdleMaint(const android::sp<android::os::IVoldTaskListener>& listener);
binder::Status getStorageLifeTime(int32_t* _aidl_return);
binder::Status setGCUrgentPace(int32_t neededSegments, int32_t minSegmentThreshold,
- float dirtyReclaimRate, float reclaimWeight);
+ float dirtyReclaimRate, float reclaimWeight, int32_t gcPeriod);
binder::Status refreshLatestWrite();
binder::Status getWriteAmount(int32_t* _aidl_return);
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index aee75f5..9508d91 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -68,7 +68,8 @@
void abortIdleMaint(IVoldTaskListener listener);
int getStorageLifeTime();
void setGCUrgentPace(int neededSegments, int minSegmentThreshold,
- float dirtyReclaimRate, float reclaimWeight);
+ float dirtyReclaimRate, float reclaimWeight,
+ int gcPeriod);
void refreshLatestWrite();
int getWriteAmount();