diff options
author | Steven Laver <lavers@google.com> | 2020-04-28 14:34:30 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2020-04-28 14:34:30 +0000 |
commit | aa82a3d93801a59d8cf8af115c7bf235e7243fcc (patch) | |
tree | 36ded3563a964ecb44ef7fda3bb373aed83353d8 /fs_mgr/liblp/builder.cpp | |
parent | c30cc8172fda35c81c7ccfd94d2dc00881d1d2c3 (diff) | |
parent | 4ac5a687c56a98bc54783c53d3a7ed38c93c4386 (diff) |
Merge "Merge RP1A.200426.001" into r-keystone-qcom-dev
Diffstat (limited to 'fs_mgr/liblp/builder.cpp')
-rw-r--r-- | fs_mgr/liblp/builder.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/fs_mgr/liblp/builder.cpp b/fs_mgr/liblp/builder.cpp index d4964669a6..2f516fa9b9 100644 --- a/fs_mgr/liblp/builder.cpp +++ b/fs_mgr/liblp/builder.cpp @@ -40,6 +40,20 @@ bool LinearExtent::AddTo(LpMetadata* out) const { return true; } +bool LinearExtent::OverlapsWith(const LinearExtent& other) const { + if (device_index_ != other.device_index()) { + return false; + } + return physical_sector() < other.end_sector() && other.physical_sector() < end_sector(); +} + +bool LinearExtent::OverlapsWith(const Interval& interval) const { + if (device_index_ != interval.device_index) { + return false; + } + return physical_sector() < interval.end && interval.start < end_sector(); +} + Interval LinearExtent::AsInterval() const { return Interval(device_index(), physical_sector(), end_sector()); } @@ -774,8 +788,7 @@ std::unique_ptr<LinearExtent> MetadataBuilder::ExtendFinalExtent( bool MetadataBuilder::IsAnyRegionCovered(const std::vector<Interval>& regions, const LinearExtent& candidate) const { for (const auto& region : regions) { - if (region.device_index == candidate.device_index() && - (candidate.OwnsSector(region.start) || candidate.OwnsSector(region.end))) { + if (candidate.OverlapsWith(region)) { return true; } } @@ -786,11 +799,10 @@ bool MetadataBuilder::IsAnyRegionAllocated(const LinearExtent& candidate) const for (const auto& partition : partitions_) { for (const auto& extent : partition->extents()) { LinearExtent* linear = extent->AsLinearExtent(); - if (!linear || linear->device_index() != candidate.device_index()) { + if (!linear) { continue; } - if (linear->OwnsSector(candidate.physical_sector()) || - linear->OwnsSector(candidate.end_sector() - 1)) { + if (linear->OverlapsWith(candidate)) { return true; } } |