From 7d526560df250f1636de75cff5d4ff6e0f3a8e3e Mon Sep 17 00:00:00 2001 From: Kelvin Zhang Date: Mon, 4 Dec 2023 09:29:20 -0800 Subject: [PATCH] Allow Cow version v3 to be used This does not change the default cow version. Currently v2 is still the default. This CL only enables OEMs to set virtual_ab_cow_version to 3 for testing purposes. Test: th Bug: 313962438 Change-Id: I7a328fa32283560a48604ffe02edd2551ac49a83 --- fs_mgr/libsnapshot/include/libsnapshot/cow_format.h | 2 +- fs_mgr/libsnapshot/snapshot.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h index 1a7ec6195..717ad2dcb 100644 --- a/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h +++ b/fs_mgr/libsnapshot/include/libsnapshot/cow_format.h @@ -34,7 +34,7 @@ static constexpr uint32_t kCowVersionMinor = 0; static constexpr uint32_t kCowVersionManifest = 2; static constexpr uint32_t kMinCowVersion = 1; -static constexpr uint32_t kMaxCowVersion = 2; +static constexpr uint32_t kMaxCowVersion = 3; // Normally, this should be kMaxCowVersion. When a new version is under testing // it may be the previous value of kMaxCowVersion. diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index e91e3b73c..79cebab78 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -3642,6 +3642,9 @@ std::unique_ptr SnapshotManager::OpenCompressedSnapshotWriter( cow_options.max_blocks = {status.device_size() / cow_options.block_size}; cow_options.batch_write = status.batched_writes(); cow_options.num_compress_threads = status.enable_threading() ? 2 : 0; + // TODO(b/313962438) Improve op_count estimate. For now, use number of + // blocks as an upper bound. + cow_options.op_count_max = status.device_size() / cow_options.block_size; // Disable scratch space for vts tests if (device()->IsTestDevice()) { cow_options.scratch_space = false;