liblp: Add more logging for logical partition operations.
This logs when partition tables update, when partitions resize, and when partitions are unmapped from device mapper. Bug: N/A Test: N/A Change-Id: I1125332c79fccc3ebc556b3b48856901e2503c47
This commit is contained in:
parent
615745cead
commit
b9f734c936
4 changed files with 27 additions and 7 deletions
|
@ -133,7 +133,11 @@ bool CreateLogicalPartition(const std::string& block_device, uint32_t metadata_s
|
|||
|
||||
bool DestroyLogicalPartition(const std::string& name) {
|
||||
DeviceMapper& dm = DeviceMapper::Instance();
|
||||
return dm.DeleteDevice(name);
|
||||
if (!dm.DeleteDevice(name)) {
|
||||
return false;
|
||||
}
|
||||
LINFO << "Unmapped logical partition " << name;
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace fs_mgr
|
||||
|
|
|
@ -498,13 +498,18 @@ void MetadataBuilder::set_block_device_info(const BlockDeviceInfo& device_info)
|
|||
bool MetadataBuilder::ResizePartition(Partition* partition, uint64_t requested_size) {
|
||||
// Align the space needed up to the nearest sector.
|
||||
uint64_t aligned_size = AlignTo(requested_size, device_info_.logical_block_size);
|
||||
uint64_t old_size = partition->size();
|
||||
|
||||
if (aligned_size > partition->size()) {
|
||||
return GrowPartition(partition, aligned_size);
|
||||
}
|
||||
if (aligned_size < partition->size()) {
|
||||
if (aligned_size > old_size) {
|
||||
if (!GrowPartition(partition, aligned_size)) {
|
||||
return false;
|
||||
}
|
||||
} else if (aligned_size < partition->size()) {
|
||||
ShrinkPartition(partition, aligned_size);
|
||||
}
|
||||
|
||||
LINFO << "Partition " << partition->name() << " will resize from " << old_size << " bytes to "
|
||||
<< aligned_size << " bytes";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include "liblp/metadata_format.h"
|
||||
|
||||
#define LP_TAG "[liblp]"
|
||||
#define LWARN LOG(WARNING) << LP_TAG
|
||||
#define LINFO LOG(INFO) << LP_TAG
|
||||
#define LERROR LOG(ERROR) << LP_TAG
|
||||
#define PERROR PLOG(ERROR) << LP_TAG
|
||||
|
||||
|
|
|
@ -304,7 +304,11 @@ bool FlashPartitionTable(const std::string& block_device, const LpMetadata& meta
|
|||
PERROR << __PRETTY_FUNCTION__ << "open failed: " << block_device;
|
||||
return false;
|
||||
}
|
||||
return FlashPartitionTable(fd, metadata, slot_number);
|
||||
if (!FlashPartitionTable(fd, metadata, slot_number)) {
|
||||
return false;
|
||||
}
|
||||
LWARN << "Flashed new logical partition geometry to " << block_device;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UpdatePartitionTable(const std::string& block_device, const LpMetadata& metadata,
|
||||
|
@ -314,7 +318,12 @@ bool UpdatePartitionTable(const std::string& block_device, const LpMetadata& met
|
|||
PERROR << __PRETTY_FUNCTION__ << "open failed: " << block_device;
|
||||
return false;
|
||||
}
|
||||
return UpdatePartitionTable(fd, metadata, slot_number);
|
||||
if (!UpdatePartitionTable(fd, metadata, slot_number)) {
|
||||
return false;
|
||||
}
|
||||
LINFO << "Updated logical partition table at slot " << slot_number << " on device "
|
||||
<< block_device;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UpdatePartitionTable(int fd, const LpMetadata& metadata, uint32_t slot_number) {
|
||||
|
|
Loading…
Reference in a new issue