snapuserd: skip verification
verification can be disabled as a property configurable through
vabc_features.mk
Bug: 332255580
Test: th
Change-Id: I48a6e5d20fee40cf1a90a8c35d29a5ca5c367572
diff --git a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
index 8bd120d..94d8e9f 100644
--- a/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
+++ b/fs_mgr/libsnapshot/android/snapshot/snapshot.proto
@@ -233,6 +233,9 @@
// Default value is 3, configures threads to do verification phase
uint32 num_verification_threads = 16;
+
+ // Skips verification of partitions
+ bool skip_verification = 17;
}
message SnapshotMergeReport {
diff --git a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
index 02e5f66..4520b21 100644
--- a/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
+++ b/fs_mgr/libsnapshot/include/libsnapshot/snapshot.h
@@ -859,6 +859,9 @@
// Check if direct reads are enabled for the source image
bool UpdateUsesODirect(LockedFile* lock);
+ // Check if we skip the verification of the target image
+ bool UpdateUsesSkipVerification(LockedFile* lock);
+
// Get value of maximum cow op merge size
uint32_t GetUpdateCowOpMergeSize(LockedFile* lock);
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index 8c11800..fa2f569 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -2234,6 +2234,11 @@
return update_status.o_direct();
}
+bool SnapshotManager::UpdateUsesSkipVerification(LockedFile* lock) {
+ SnapshotUpdateStatus update_status = ReadSnapshotUpdateStatus(lock);
+ return update_status.skip_verification();
+}
+
uint32_t SnapshotManager::GetUpdateCowOpMergeSize(LockedFile* lock) {
SnapshotUpdateStatus update_status = ReadSnapshotUpdateStatus(lock);
return update_status.cow_op_merge_size();
@@ -3244,6 +3249,7 @@
status.set_io_uring_enabled(old_status.io_uring_enabled());
status.set_legacy_snapuserd(old_status.legacy_snapuserd());
status.set_o_direct(old_status.o_direct());
+ status.set_skip_verification(old_status.skip_verification());
status.set_cow_op_merge_size(old_status.cow_op_merge_size());
status.set_num_worker_threads(old_status.num_worker_threads());
status.set_verify_block_size(old_status.verify_block_size());
@@ -3626,6 +3632,10 @@
status.set_o_direct(true);
LOG(INFO) << "o_direct for source image enabled";
}
+ if (GetSkipVerificationProperty()) {
+ status.set_skip_verification(true);
+ LOG(INFO) << "skipping verification of images";
+ }
if (is_legacy_snapuserd) {
status.set_legacy_snapuserd(true);
LOG(INFO) << "Setting legacy_snapuserd to true";
@@ -4073,6 +4083,7 @@
ss << "Using userspace snapshots: " << update_status.userspace_snapshots() << std::endl;
ss << "Using io_uring: " << update_status.io_uring_enabled() << std::endl;
ss << "Using o_direct: " << update_status.o_direct() << std::endl;
+ ss << "Using skip_verification: " << update_status.skip_verification() << std::endl;
ss << "Cow op merge size (0 for uncapped): " << update_status.cow_op_merge_size() << std::endl;
ss << "Worker thread count: " << update_status.num_worker_threads() << std::endl;
ss << "Num verification threads: " << update_status.num_verification_threads() << std::endl;
diff --git a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
index cc08a07..d29223e 100644
--- a/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/snapuserd_daemon.cpp
@@ -35,6 +35,7 @@
DEFINE_bool(user_snapshot, false, "If true, user-space snapshots are used");
DEFINE_bool(io_uring, false, "If true, io_uring feature is enabled");
DEFINE_bool(o_direct, false, "If true, enable direct reads on source device");
+DEFINE_bool(skip_verification, false, "If true, skip verification of partitions");
DEFINE_int32(cow_op_merge_size, 0, "number of operations to be processed at once");
DEFINE_int32(worker_count, android::snapshot::kNumWorkerThreads,
"number of worker threads used to serve I/O requests to dm-user");
@@ -123,6 +124,7 @@
.num_worker_threads = FLAGS_worker_count,
.use_iouring = FLAGS_io_uring,
.o_direct = FLAGS_o_direct,
+ .skip_verification = FLAGS_skip_verification,
.cow_op_merge_size = static_cast<uint32_t>(FLAGS_cow_op_merge_size),
.verify_block_size = static_cast<uint32_t>(FLAGS_verify_block_size),
.num_verification_threads = static_cast<uint32_t>(FLAGS_num_verify_threads),
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/handler_manager.h b/fs_mgr/libsnapshot/snapuserd/user-space-merge/handler_manager.h
index 31f8f32..d10d8e8 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/handler_manager.h
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/handler_manager.h
@@ -31,6 +31,7 @@
int num_worker_threads{};
bool use_iouring{};
bool o_direct{};
+ bool skip_verification{};
uint32_t cow_op_merge_size{};
uint32_t verify_block_size{};
uint32_t num_verification_threads{};
diff --git a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
index 227b23c..b21189c 100644
--- a/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
+++ b/fs_mgr/libsnapshot/snapuserd/user-space-merge/snapuserd_server.cpp
@@ -367,8 +367,8 @@
options.num_worker_threads = 1;
}
- if (android::base::EndsWith(misc_name, "-init") || is_socket_present_ ||
- (access(kBootSnapshotsWithoutSlotSwitch, F_OK) == 0)) {
+ if (options.skip_verification || android::base::EndsWith(misc_name, "-init") ||
+ is_socket_present_ || (access(kBootSnapshotsWithoutSlotSwitch, F_OK) == 0)) {
handlers_->DisableVerification();
}
diff --git a/fs_mgr/libsnapshot/utility.cpp b/fs_mgr/libsnapshot/utility.cpp
index 30510d0..04ee069 100644
--- a/fs_mgr/libsnapshot/utility.cpp
+++ b/fs_mgr/libsnapshot/utility.cpp
@@ -199,7 +199,7 @@
}
std::ostream& operator<<(std::ostream& os, const Now&) {
- struct tm now{};
+ struct tm now {};
time_t t = time(nullptr);
localtime_r(&t, &now);
return os << std::put_time(&now, "%Y%m%d-%H%M%S");
@@ -293,6 +293,11 @@
return fetcher->GetBoolProperty("ro.virtual_ab.o_direct.enabled", false);
}
+bool GetSkipVerificationProperty() {
+ auto fetcher = IPropertyFetcher::GetInstance();
+ return fetcher->GetBoolProperty("ro.virtual_ab.skip_verification", false);
+}
+
std::string GetOtherPartitionName(const std::string& name) {
auto suffix = android::fs_mgr::GetPartitionSlotSuffix(name);
CHECK(suffix == "_a" || suffix == "_b");
diff --git a/fs_mgr/libsnapshot/utility.h b/fs_mgr/libsnapshot/utility.h
index 30c75c0..eaf51c1 100644
--- a/fs_mgr/libsnapshot/utility.h
+++ b/fs_mgr/libsnapshot/utility.h
@@ -136,6 +136,7 @@
bool GetIouringEnabledProperty();
bool GetXorCompressionEnabledProperty();
bool GetODirectEnabledProperty();
+bool GetSkipVerificationProperty();
bool CanUseUserspaceSnapshots();
bool IsDmSnapshotTestingEnabled();