Adding an option to shorten the read timeout.
E.g. during installation to protect the system.
Ignore-AOSP-First: this depends on changes to framework and/or incfs and does not make sense without them. We'll merge it at a single large scale merge later.
Bug: 160635296
Test: atest PackageManagerShellCommandTest PackageManagerShellCommandIncrementalTest IncrementalServiceTest PackageManagerServiceTest ChecksumsTest
Change-Id: I5851e1e9dbc8e8c2b331c407002cf7133bf6e35a
diff --git a/VoldNativeService.cpp b/VoldNativeService.cpp
index a61d615..4cf1952 100644
--- a/VoldNativeService.cpp
+++ b/VoldNativeService.cpp
@@ -54,6 +54,7 @@
namespace {
constexpr const char* kDump = "android.permission.DUMP";
+constexpr auto kIncFsReadNoTimeoutMs = 100;
static binder::Status error(const std::string& msg) {
PLOG(ERROR) << msg;
@@ -955,6 +956,7 @@
auto control = incfs::mount(backingPath, targetDir,
{.flags = IncFsMountFlags(flags),
+ // Mount with read timeouts.
.defaultReadTimeoutMs = INCFS_DEFAULT_READ_TIMEOUT_MS,
// Mount with read logs disabled.
.readLogBufferPages = 0});
@@ -981,7 +983,7 @@
binder::Status VoldNativeService::setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
- bool enableReadLogs) {
+ bool enableReadLogs, bool enableReadTimeouts) {
ENFORCE_SYSTEM_OR_ROOT;
auto incfsControl =
@@ -996,7 +998,8 @@
std::unique_ptr<incfs::Control, decltype(cleanupFunc)>(&incfsControl, cleanupFunc);
if (auto error = incfs::setOptions(
incfsControl,
- {.defaultReadTimeoutMs = INCFS_DEFAULT_READ_TIMEOUT_MS,
+ {.defaultReadTimeoutMs =
+ enableReadTimeouts ? INCFS_DEFAULT_READ_TIMEOUT_MS : kIncFsReadNoTimeoutMs,
.readLogBufferPages = enableReadLogs ? INCFS_DEFAULT_PAGE_READ_BUFFER_PAGES : 0});
error < 0) {
return binder::Status::fromServiceSpecificError(error);
diff --git a/VoldNativeService.h b/VoldNativeService.h
index 123f127..8da91c0 100644
--- a/VoldNativeService.h
+++ b/VoldNativeService.h
@@ -165,7 +165,7 @@
binder::Status unmountIncFs(const std::string& dir) override;
binder::Status setIncFsMountOptions(
const ::android::os::incremental::IncrementalFileSystemControlParcel& control,
- bool enableReadLogs) override;
+ bool enableReadLogs, bool enableReadTimeouts) override;
binder::Status bindMount(const std::string& sourceDir, const std::string& targetDir) override;
binder::Status destroyDsuMetadataKey(const std::string& dsuSlot) override;
diff --git a/binder/android/os/IVold.aidl b/binder/android/os/IVold.aidl
index fd134c5..f09f1da 100644
--- a/binder/android/os/IVold.aidl
+++ b/binder/android/os/IVold.aidl
@@ -141,7 +141,7 @@
boolean incFsEnabled();
IncrementalFileSystemControlParcel mountIncFs(@utf8InCpp String backingPath, @utf8InCpp String targetDir, int flags);
void unmountIncFs(@utf8InCpp String dir);
- void setIncFsMountOptions(in IncrementalFileSystemControlParcel control, boolean enableReadLogs);
+ void setIncFsMountOptions(in IncrementalFileSystemControlParcel control, boolean enableReadLogs, boolean enableReadTimeouts);
void bindMount(@utf8InCpp String sourceDir, @utf8InCpp String targetDir);
void destroyDsuMetadataKey(@utf8InCpp String dsuSlot);