liblp: Always align the first usable sector.
Align the first usable sector to the logical block size, if no other alignment was specified. This fixes a bunch of warnings during certain gtests (ones with unaligned metadata sizes). The warnings were coming from MetadataBuilder::GrowPartition() which expects the first sector to always be block-aligned. Bug: 116802789 Test: liblp_test gtest Change-Id: I8dcf502aa4c2ba0674c5b4dcb77a274f300ff0a3
This commit is contained in:
parent
692049259c
commit
87391664e3
1 changed files with 7 additions and 2 deletions
|
|
@ -268,8 +268,13 @@ bool MetadataBuilder::Init(const BlockDeviceInfo& device_info, uint32_t metadata
|
|||
}
|
||||
|
||||
// Compute the first free sector, factoring in alignment.
|
||||
uint64_t free_area_start =
|
||||
AlignTo(total_reserved, device_info.alignment, device_info.alignment_offset);
|
||||
uint64_t free_area_start = total_reserved;
|
||||
if (device_info.alignment || device_info.alignment_offset) {
|
||||
free_area_start =
|
||||
AlignTo(free_area_start, device_info.alignment, device_info.alignment_offset);
|
||||
} else {
|
||||
free_area_start = AlignTo(free_area_start, device_info.logical_block_size);
|
||||
}
|
||||
uint64_t first_sector = free_area_start / LP_SECTOR_SIZE;
|
||||
|
||||
// There must be one logical block of free space remaining (enough for one partition).
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue