From 3f96053b3895f09b2887ee08ceda2bfcb857053d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 3 May 2023 11:26:13 -0700 Subject: [PATCH] DO NOT MERGE: libsnapshot: Fix test failures on certain configurations. Due to how CF is built and tested, VABC is enabled even when not supported by the kernel. To work around this add some logic in libsnapshot and the test harness to recognize this situation and silently flip off the VABC flag. This also fixes the -force_mode option to vts_libsnapshot_test, so that it will skip tests that aren't supported by the device. Bug: 264279496 Test: vts_libsnapshot_test on android13-gsi with 11-5.4 kernel Change-Id: I9279d8d400cac5cd504a7ae91f254aae57fa856d --- fs_mgr/libsnapshot/snapshot.cpp | 3 ++- fs_mgr/libsnapshot/snapshot_test.cpp | 4 ++-- fs_mgr/libsnapshot/utility.cpp | 7 +++++++ fs_mgr/libsnapshot/utility.h | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 019b64a44..cd4c56048 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -3166,7 +3166,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife << " writer.GetCowVersion(): " << writer.GetCowVersion(); bool use_compression = IsCompressionEnabled() && dap_metadata.vabc_enabled() && - !device_->IsRecovery() && cow_format_support; + !device_->IsRecovery() && cow_format_support && + KernelSupportsCompressedSnapshots(); std::string compression_algorithm; if (use_compression) { diff --git a/fs_mgr/libsnapshot/snapshot_test.cpp b/fs_mgr/libsnapshot/snapshot_test.cpp index e7ffb1600..a741134b8 100644 --- a/fs_mgr/libsnapshot/snapshot_test.cpp +++ b/fs_mgr/libsnapshot/snapshot_test.cpp @@ -2760,7 +2760,7 @@ bool IsDaemonRequired() { return true; } - return IsUserspaceSnapshotsEnabled(); + return IsUserspaceSnapshotsEnabled() && KernelSupportsCompressedSnapshots(); } bool ShouldUseCompression() { @@ -2770,7 +2770,7 @@ bool ShouldUseCompression() { if (FLAGS_force_config == "vabc") { return true; } - return IsCompressionEnabled(); + return IsCompressionEnabled() && KernelSupportsCompressedSnapshots(); } } // namespace snapshot diff --git a/fs_mgr/libsnapshot/utility.cpp b/fs_mgr/libsnapshot/utility.cpp index f01bec938..841acf459 100644 --- a/fs_mgr/libsnapshot/utility.cpp +++ b/fs_mgr/libsnapshot/utility.cpp @@ -26,7 +26,9 @@ #include #include #include +#include +using android::dm::DeviceMapper; using android::dm::kSectorSize; using android::fiemap::FiemapStatus; using android::fs_mgr::EnsurePathMounted; @@ -208,5 +210,10 @@ bool IsDmSnapshotTestingEnabled() { return android::base::GetBoolProperty("snapuserd.test.dm.snapshots", false); } +bool KernelSupportsCompressedSnapshots() { + auto& dm = DeviceMapper::Instance(); + return dm.GetTargetByName("user", nullptr); +} + } // namespace snapshot } // namespace android diff --git a/fs_mgr/libsnapshot/utility.h b/fs_mgr/libsnapshot/utility.h index 0ef3234fd..0794154c0 100644 --- a/fs_mgr/libsnapshot/utility.h +++ b/fs_mgr/libsnapshot/utility.h @@ -129,6 +129,7 @@ std::ostream& operator<<(std::ostream& os, const Now&); void AppendExtent(google::protobuf::RepeatedPtrField* extents, uint64_t start_block, uint64_t num_blocks); +bool KernelSupportsCompressedSnapshots(); bool IsCompressionEnabled(); bool IsUserspaceSnapshotsEnabled();