From 5aa0527499b9fbed98b0572098de7d34e9ffe9bd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 2 Mar 2021 18:28:42 -0800 Subject: [PATCH] liblp: Remove uses of alignment_offset. alignment_offset restrictions were removed in R and are no longer needed. Bug: 180571070 Test: liblp_test Change-Id: I43fa4a929c20cc8c6ec2fece71d5400351c13dbe --- fs_mgr/liblp/builder.cpp | 7 +------ fs_mgr/liblp/builder_test.cpp | 9 ++------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp index 623293eb2..6cb2c5172 100644 --- a/fs_mgr/liblp/builder.cpp +++ b/fs_mgr/liblp/builder.cpp @@ -383,11 +383,6 @@ static bool VerifyDeviceProperties(const BlockDeviceInfo& device_info) { << " partition alignment is not sector-aligned."; return false; } - if (device_info.alignment_offset > device_info.alignment) { - LERROR << "Block device " << device_info.partition_name - << " partition alignment offset is greater than its alignment."; - return false; - } return true; } @@ -489,7 +484,7 @@ bool MetadataBuilder::Init(const std::vector& block_devices, // Compute the first free sector, factoring in alignment. uint64_t free_area_start = total_reserved; bool ok; - if (super.alignment || super.alignment_offset) { + if (super.alignment) { ok = AlignTo(free_area_start, super.alignment, &free_area_start); } else { ok = AlignTo(free_area_start, logical_block_size, &free_area_start); diff --git a/fs_mgr/liblp/builder_test.cpp b/fs_mgr/liblp/builder_test.cpp index e4b617a51..72827eb6c 100644 --- a/fs_mgr/liblp/builder_test.cpp +++ b/fs_mgr/liblp/builder_test.cpp @@ -176,10 +176,10 @@ TEST_F(BuilderTest, InternalAlignment) { ASSERT_NE(super_device, nullptr); EXPECT_EQ(super_device->first_logical_sector, 1536); - // Alignment offset without alignment doesn't mean anything. + // Alignment offset without alignment is ignored. device_info.alignment = 0; builder = MetadataBuilder::New(device_info, 1024, 2); - ASSERT_EQ(builder, nullptr); + ASSERT_NE(builder, nullptr); // Test a small alignment with an alignment offset. device_info.alignment = 12 * 1024; @@ -444,11 +444,6 @@ TEST_F(BuilderTest, MetadataTooLarge) { device_info.alignment = 131072; builder = MetadataBuilder::New(device_info, kMetadataSize, 1); EXPECT_EQ(builder, nullptr); - - device_info.alignment = 0; - device_info.alignment_offset = 32768 - LP_SECTOR_SIZE; - builder = MetadataBuilder::New(device_info, kMetadataSize, 1); - EXPECT_EQ(builder, nullptr); } TEST_F(BuilderTest, UpdateBlockDeviceInfo) {