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
This commit is contained in:
Yifan Hong 2019-08-12 19:13:58 -07:00
parent 8367b9f73a
commit fadce1ee1f
2 changed files with 6 additions and 6 deletions

View file

@ -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,

View file

@ -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;