Merge "fs_mgr: Remove the timeout parameter to DestroyLogicalPartition."

This commit is contained in:
David Anderson 2019-07-13 18:02:05 +00:00 committed by Gerrit Code Review
commit cd22e3a6f6
7 changed files with 13 additions and 21 deletions

View file

@ -61,7 +61,7 @@ bool OpenLogicalPartition(FastbootDevice* device, const std::string& partition_n
LOG(ERROR) << "Could not map partition: " << partition_name;
return false;
}
auto closer = [partition_name]() -> void { DestroyLogicalPartition(partition_name, 5s); };
auto closer = [partition_name]() -> void { DestroyLogicalPartition(partition_name); };
*handle = PartitionHandle(dm_path, std::move(closer));
return true;
}

View file

@ -1331,7 +1331,7 @@ int fs_mgr_umount_all(android::fs_mgr::Fstab* fstab) {
continue;
}
} else if ((current_entry.fs_mgr_flags.verify)) {
if (!fs_mgr_teardown_verity(&current_entry, true /* wait */)) {
if (!fs_mgr_teardown_verity(&current_entry)) {
LERROR << "Failed to tear down verified partition on mount point: "
<< current_entry.mount_point;
ret |= FsMgrUmountStatus::ERROR_VERITY;

View file

@ -184,24 +184,16 @@ bool CreateLogicalPartition(const std::string& block_device, uint32_t metadata_s
timeout_ms, path);
}
bool UnmapDevice(const std::string& name, const std::chrono::milliseconds& timeout_ms) {
bool UnmapDevice(const std::string& name) {
DeviceMapper& dm = DeviceMapper::Instance();
std::string path;
if (timeout_ms > std::chrono::milliseconds::zero()) {
dm.GetDmDevicePathByName(name, &path);
}
if (!dm.DeleteDevice(name)) {
return false;
}
if (!path.empty() && !WaitForFileDeleted(path, timeout_ms)) {
LERROR << "Timed out waiting for device path to unlink: " << path;
return false;
}
return true;
}
bool DestroyLogicalPartition(const std::string& name, const std::chrono::milliseconds& timeout_ms) {
if (!UnmapDevice(name, timeout_ms)) {
bool DestroyLogicalPartition(const std::string& name) {
if (!UnmapDevice(name)) {
return false;
}
LINFO << "Unmapped logical partition " << name;

View file

@ -444,7 +444,7 @@ bool fs_mgr_overlayfs_teardown_scratch(const std::string& overlay, bool* change)
auto metadata = builder->Export();
if (metadata && UpdatePartitionTable(super_device, *metadata.get(), slot_number)) {
if (change) *change = true;
if (!DestroyLogicalPartition(partition_name, 0s)) return false;
if (!DestroyLogicalPartition(partition_name)) return false;
} else {
LERROR << "delete partition " << overlay;
return false;
@ -844,7 +844,7 @@ static void TruncatePartitionsWithSuffix(MetadataBuilder* builder, const std::st
if (!android::base::EndsWith(name, suffix)) {
continue;
}
if (dm.GetState(name) != DmDeviceState::INVALID && !DestroyLogicalPartition(name, 2s)) {
if (dm.GetState(name) != DmDeviceState::INVALID && !DestroyLogicalPartition(name)) {
continue;
}
builder->ResizePartition(builder->FindPartition(name), 0);
@ -918,7 +918,7 @@ bool fs_mgr_overlayfs_create_scratch(const Fstab& fstab, std::string* scratch_de
return false;
}
}
if (!partition_create) DestroyLogicalPartition(partition_name, 10s);
if (!partition_create) DestroyLogicalPartition(partition_name);
changed = true;
*partition_exists = false;
}

View file

@ -97,10 +97,10 @@ bool is_dt_compatible();
bool fs_mgr_is_ext4(const std::string& blk_device);
bool fs_mgr_is_f2fs(const std::string& blk_device);
bool fs_mgr_teardown_verity(android::fs_mgr::FstabEntry* fstab, bool wait);
bool fs_mgr_teardown_verity(android::fs_mgr::FstabEntry* fstab);
namespace android {
namespace fs_mgr {
bool UnmapDevice(const std::string& name, const std::chrono::milliseconds& timeout_ms);
bool UnmapDevice(const std::string& name);
} // namespace fs_mgr
} // namespace android

View file

@ -547,9 +547,9 @@ out:
return retval;
}
bool fs_mgr_teardown_verity(FstabEntry* entry, bool wait) {
bool fs_mgr_teardown_verity(FstabEntry* entry) {
const std::string mount_point(basename(entry->mount_point.c_str()));
if (!android::fs_mgr::UnmapDevice(mount_point, wait ? 1000ms : 0ms)) {
if (!android::fs_mgr::UnmapDevice(mount_point)) {
return false;
}
LINFO << "Unmapped verity device " << mount_point;

View file

@ -68,7 +68,7 @@ bool CreateLogicalPartition(const std::string& block_device, const LpMetadata& m
// Destroy the block device for a logical partition, by name. If |timeout_ms|
// is non-zero, then this will block until the device path has been unlinked.
bool DestroyLogicalPartition(const std::string& name, const std::chrono::milliseconds& timeout_ms);
bool DestroyLogicalPartition(const std::string& name);
} // namespace fs_mgr
} // namespace android