Merge "Enable dynamic read logs buffer sizing for incfs"

This commit is contained in:
Treehugger Robot 2021-10-28 23:01:58 +00:00 committed by Gerrit Code Review
commit 2a89e7c577

View file

@ -1039,16 +1039,30 @@ binder::Status VoldNativeService::setIncFsMountOptions(
}; };
auto cleanup = auto cleanup =
std::unique_ptr<incfs::Control, decltype(cleanupFunc)>(&incfsControl, cleanupFunc); std::unique_ptr<incfs::Control, decltype(cleanupFunc)>(&incfsControl, cleanupFunc);
if (auto error = incfs::setOptions(
incfsControl, constexpr auto minReadLogBufferPages = INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES;
{.defaultReadTimeoutMs = constexpr auto maxReadLogBufferPages = 8 * INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES;
auto options = incfs::MountOptions{
.defaultReadTimeoutMs =
enableReadTimeouts ? INCFS_DEFAULT_READ_TIMEOUT_MS : kIncFsReadNoTimeoutMs, enableReadTimeouts ? INCFS_DEFAULT_READ_TIMEOUT_MS : kIncFsReadNoTimeoutMs,
.readLogBufferPages = enableReadLogs ? INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES : 0, .readLogBufferPages = enableReadLogs ? maxReadLogBufferPages : 0,
.sysfsName = sysfsName.c_str()}); .sysfsName = sysfsName.c_str()};
error < 0) {
for (;;) {
const auto error = incfs::setOptions(incfsControl, options);
if (!error) {
return Ok();
}
if (!enableReadLogs || error != -ENOMEM) {
return binder::Status::fromServiceSpecificError(error); return binder::Status::fromServiceSpecificError(error);
} }
// In case of memory allocation error retry with a smaller buffer.
options.readLogBufferPages /= 2;
if (options.readLogBufferPages < minReadLogBufferPages) {
return binder::Status::fromServiceSpecificError(error);
}
}
// unreachable, but makes the compiler happy
return Ok(); return Ok();
} }