|
|
@ -261,8 +261,9 @@ bool cp_needsCheckpoint() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
namespace {
|
|
|
|
const std::string kSleepTimeProp = "ro.sys.cp_usleeptime";
|
|
|
|
const std::string kSleepTimeProp = "ro.sys.cp_msleeptime";
|
|
|
|
const uint32_t usleeptime_default = 1000000; // 1 s
|
|
|
|
const uint32_t msleeptime_default = 1000; // 1 s
|
|
|
|
|
|
|
|
const uint32_t max_msleeptime = 3600000; // 1 h
|
|
|
|
|
|
|
|
|
|
|
|
const std::string kMinFreeBytesProp = "ro.sys.cp_min_free_bytes";
|
|
|
|
const std::string kMinFreeBytesProp = "ro.sys.cp_min_free_bytes";
|
|
|
|
const uint64_t min_free_bytes_default = 100 * (1 << 20); // 100 MiB
|
|
|
|
const uint64_t min_free_bytes_default = 100 * (1 << 20); // 100 MiB
|
|
|
@ -273,11 +274,15 @@ const bool commit_on_full_default = true;
|
|
|
|
static void cp_healthDaemon(std::string mnt_pnt, std::string blk_device, bool is_fs_cp) {
|
|
|
|
static void cp_healthDaemon(std::string mnt_pnt, std::string blk_device, bool is_fs_cp) {
|
|
|
|
struct statvfs data;
|
|
|
|
struct statvfs data;
|
|
|
|
uint64_t free_bytes = 0;
|
|
|
|
uint64_t free_bytes = 0;
|
|
|
|
uint32_t usleeptime = GetUintProperty(kSleepTimeProp, usleeptime_default, (uint32_t)-1);
|
|
|
|
uint32_t msleeptime = GetUintProperty(kSleepTimeProp, msleeptime_default, max_msleeptime);
|
|
|
|
uint64_t min_free_bytes =
|
|
|
|
uint64_t min_free_bytes =
|
|
|
|
GetUintProperty(kMinFreeBytesProp, min_free_bytes_default, (uint64_t)-1);
|
|
|
|
GetUintProperty(kMinFreeBytesProp, min_free_bytes_default, (uint64_t)-1);
|
|
|
|
bool commit_on_full = GetBoolProperty(kCommitOnFullProp, commit_on_full_default);
|
|
|
|
bool commit_on_full = GetBoolProperty(kCommitOnFullProp, commit_on_full_default);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct timespec req;
|
|
|
|
|
|
|
|
req.tv_sec = msleeptime / 1000;
|
|
|
|
|
|
|
|
msleeptime %= 1000;
|
|
|
|
|
|
|
|
req.tv_nsec = msleeptime * 1000000;
|
|
|
|
while (isCheckpointing) {
|
|
|
|
while (isCheckpointing) {
|
|
|
|
if (is_fs_cp) {
|
|
|
|
if (is_fs_cp) {
|
|
|
|
statvfs(mnt_pnt.c_str(), &data);
|
|
|
|
statvfs(mnt_pnt.c_str(), &data);
|
|
|
@ -302,7 +307,7 @@ static void cp_healthDaemon(std::string mnt_pnt, std::string blk_device, bool is
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
usleep(usleeptime);
|
|
|
|
nanosleep(&req, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|