From fadce1ee1f891232ed9f0ce460db983b5d5fee8d Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 12 Aug 2019 19:13:58 -0700 Subject: [PATCH] liblp: Don't halve super partition for virtual a/b devices For Virtual A/B devices, we snapshot the partitions. Hence there is no need to prioritize using the second half of super partition for _b partitions. Test: liblp_test_static Bug: 135752105 Change-Id: I8bd669e6ffa0a4d114a1b386133179bd2819099b --- fs_mgr/liblp/builder.cpp | 8 ++++---- fs_mgr/liblp/include/liblp/builder.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp index e789524f5..6dc288e1e 100644 --- a/fs_mgr/liblp/builder.cpp +++ b/fs_mgr/liblp/builder.cpp @@ -583,8 +583,7 @@ bool MetadataBuilder::GrowPartition(Partition* partition, uint64_t aligned_size) CHECK_NE(sectors_per_block, 0); CHECK(sectors_needed % sectors_per_block == 0); - if (IsABDevice() && !IsRetrofitMetadata() && - GetPartitionSlotSuffix(partition->name()) == "_b") { + if (IsABDevice() && ShouldHalveSuper() && GetPartitionSlotSuffix(partition->name()) == "_b") { // Allocate "a" partitions top-down and "b" partitions bottom-up, to // minimize fragmentation during OTA. free_regions = PrioritizeSecondHalfOfSuper(free_regions); @@ -1058,8 +1057,9 @@ bool MetadataBuilder::IsRetrofitDynamicPartitionsDevice() { false); } -bool MetadataBuilder::IsRetrofitMetadata() const { - return GetBlockDevicePartitionName(0) != LP_METADATA_DEFAULT_PARTITION_NAME; +bool MetadataBuilder::ShouldHalveSuper() const { + return GetBlockDevicePartitionName(0) == LP_METADATA_DEFAULT_PARTITION_NAME && + !IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false); } bool MetadataBuilder::AddLinearExtent(Partition* partition, const std::string& block_device, diff --git a/fs_mgr/liblp/include/liblp/builder.h b/fs_mgr/liblp/include/liblp/builder.h index 1f7029ece..c3f6e91b1 100644 --- a/fs_mgr/liblp/include/liblp/builder.h +++ b/fs_mgr/liblp/include/liblp/builder.h @@ -317,8 +317,8 @@ class MetadataBuilder { // Return true if the device is retrofitting dynamic partitions. static bool IsRetrofitDynamicPartitionsDevice(); - // Return true if "this" metadata represents a metadata on a retrofit device. - bool IsRetrofitMetadata() const; + // Return true if _b partitions should be prioritized at the second half of the device. + bool ShouldHalveSuper() const; bool ValidatePartitionGroups() const;