From 6868cb9f5e56cdacc328285ed8cc2f54b6ee090d Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 6 Aug 2018 15:53:38 -0700 Subject: [PATCH] fs_mgr: Do not mount empty partitions. If a logical partition is resized to 0 bytes, it will have no extents. This is not allowed by device-mapper, but is useful for effectively compacting partitions with "fastboot flashall". If all logical partitions are resized to 0, then resized to their intended size, then we will allocate extents more efficiently. However, if a partition is left with a zero size (either intentionally or not), this should not throw the device into a reboot loop due to CreateLogicalPartitions failing. Instead we skip partitions with no extents. Bug: 78793464 Test: with fastbootd: fastboot create-partition example 4096 fastboot resize-partition example 0 device reboots successfully Change-Id: I572efa949176c8c3c493ef00438d8badd4d7cf4f --- fs_mgr/fs_mgr_dm_linear.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs_mgr/fs_mgr_dm_linear.cpp b/fs_mgr/fs_mgr_dm_linear.cpp index aa68ceb18..38df6643b 100644 --- a/fs_mgr/fs_mgr_dm_linear.cpp +++ b/fs_mgr/fs_mgr_dm_linear.cpp @@ -106,6 +106,10 @@ bool CreateLogicalPartitions(const std::string& block_device) { return true; } for (const auto& partition : metadata->partitions) { + if (!partition.num_extents) { + LINFO << "Skipping zero-length logical partition: " << GetPartitionName(partition); + continue; + } std::string path; if (!CreateLogicalPartition(block_device, *metadata.get(), partition, &path)) { LERROR << "Could not create logical partition: " << GetPartitionName(partition);