Projects
openEuler:24.03:SP1:Everything:64G
thin-provisioning-tools
_service:tar_scm:0005-Fix-sorting-of-data-mappi...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm:0005-Fix-sorting-of-data-mapping-candidates.patch of Package thin-provisioning-tools
From c286041f2595c50ced44987343c81a34d7698c23 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai <mtsai@redhat.com> Date: Mon, 16 Aug 2021 18:16:29 +0800 Subject: [PATCH] [thin_repair/thin_dump] Fix sorting of data mapping candidates - Fix the references for sorting. The timestamp statistics is stored in node_info corresponding to the second element. - Fix the timestamp comparison routine. The mapping root with more recent blocks should have higher priority. --- thin-provisioning/metadata_dumper.cc | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc index 665c7624..37c69694 100644 --- a/thin-provisioning/metadata_dumper.cc +++ b/thin-provisioning/metadata_dumper.cc @@ -252,26 +252,33 @@ namespace { bool cmp_time_counts(pair<node_info, node_info> const &lhs_pair, pair<node_info, node_info> const &rhs_pair) { - auto const &lhs = lhs_pair.first.time_counts; - auto const &rhs = rhs_pair.first.time_counts; + auto const &lhs = lhs_pair.second.time_counts; + auto const &rhs = rhs_pair.second.time_counts; - for (auto lhs_it = lhs.crbegin(); lhs_it != lhs.crend(); lhs_it++) { - for (auto rhs_it = rhs.crbegin(); rhs_it != rhs.crend(); rhs_it++) { - if (lhs_it->first > rhs_it->first) - return true; - else if (rhs_it->first > lhs_it->first) - return false; + auto lhs_it = lhs.crbegin(); + auto rhs_it = rhs.crbegin(); + while (lhs_it != lhs.crend() && rhs_it != rhs.crend()) { - else if (lhs_it->second > rhs_it->second) - return true; + auto lhs_time = lhs_it->first; + auto rhs_time = rhs_it->first; + auto lhs_count = lhs_it->second; + auto rhs_count = rhs_it->second; - else if (rhs_it->second > lhs_it->second) - return false; - } - } + if (lhs_time > rhs_time) + return true; + else if (rhs_time > lhs_time) + return false; + else if (lhs_count > rhs_count) + return true; + else if (rhs_count > lhs_count) + return false; + + lhs_it++; + rhs_it++; + } - return true; + return (lhs_it != lhs.crend()) ? true : false; } class gatherer {
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2