|
|
3be71b |
From 9388ab17da885dbd99d8b68217b282646ce9d73d Mon Sep 17 00:00:00 2001
|
|
|
3be71b |
From: Ming-Hung Tsai <mtsai@redhat.com>
|
|
|
3be71b |
Date: Mon, 16 Aug 2021 18:16:29 +0800
|
|
|
3be71b |
Subject: [PATCH 1/3] [thin_repair/thin_dump] Fix sorting of data mapping
|
|
|
3be71b |
candidates
|
|
|
3be71b |
|
|
|
3be71b |
- Fix the references for sorting. The timestamp statistics is stored
|
|
|
3be71b |
in node_info corresponding to the second element.
|
|
|
3be71b |
- Fix the timestamp comparison routine. The mapping root with more recent
|
|
|
3be71b |
blocks should have higher priority.
|
|
|
3be71b |
|
|
|
3be71b |
(cherry picked from commit 371df963113e7af7b97d2158757e35c44804ccb4)
|
|
|
3be71b |
---
|
|
|
3be71b |
thin-provisioning/metadata_dumper.cc | 37 +++++++++++++++++++++---------------
|
|
|
3be71b |
1 file changed, 22 insertions(+), 15 deletions(-)
|
|
|
3be71b |
|
|
|
3be71b |
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
|
|
|
3be71b |
index 665c762..37c6969 100644
|
|
|
3be71b |
--- a/thin-provisioning/metadata_dumper.cc
|
|
|
3be71b |
+++ b/thin-provisioning/metadata_dumper.cc
|
|
|
3be71b |
@@ -252,26 +252,33 @@ namespace {
|
|
|
3be71b |
|
|
|
3be71b |
bool cmp_time_counts(pair<node_info, node_info> const &lhs_pair,
|
|
|
3be71b |
pair<node_info, node_info> const &rhs_pair) {
|
|
|
3be71b |
- auto const &lhs = lhs_pair.first.time_counts;
|
|
|
3be71b |
- auto const &rhs = rhs_pair.first.time_counts;
|
|
|
3be71b |
+ auto const &lhs = lhs_pair.second.time_counts;
|
|
|
3be71b |
+ auto const &rhs = rhs_pair.second.time_counts;
|
|
|
3be71b |
|
|
|
3be71b |
- for (auto lhs_it = lhs.crbegin(); lhs_it != lhs.crend(); lhs_it++) {
|
|
|
3be71b |
- for (auto rhs_it = rhs.crbegin(); rhs_it != rhs.crend(); rhs_it++) {
|
|
|
3be71b |
- if (lhs_it->first > rhs_it->first)
|
|
|
3be71b |
- return true;
|
|
|
3be71b |
|
|
|
3be71b |
- else if (rhs_it->first > lhs_it->first)
|
|
|
3be71b |
- return false;
|
|
|
3be71b |
+ auto lhs_it = lhs.crbegin();
|
|
|
3be71b |
+ auto rhs_it = rhs.crbegin();
|
|
|
3be71b |
+ while (lhs_it != lhs.crend() && rhs_it != rhs.crend()) {
|
|
|
3be71b |
|
|
|
3be71b |
- else if (lhs_it->second > rhs_it->second)
|
|
|
3be71b |
- return true;
|
|
|
3be71b |
+ auto lhs_time = lhs_it->first;
|
|
|
3be71b |
+ auto rhs_time = rhs_it->first;
|
|
|
3be71b |
+ auto lhs_count = lhs_it->second;
|
|
|
3be71b |
+ auto rhs_count = rhs_it->second;
|
|
|
3be71b |
|
|
|
3be71b |
- else if (rhs_it->second > lhs_it->second)
|
|
|
3be71b |
- return false;
|
|
|
3be71b |
- }
|
|
|
3be71b |
- }
|
|
|
3be71b |
+ if (lhs_time > rhs_time)
|
|
|
3be71b |
+ return true;
|
|
|
3be71b |
+ else if (rhs_time > lhs_time)
|
|
|
3be71b |
+ return false;
|
|
|
3be71b |
+ else if (lhs_count > rhs_count)
|
|
|
3be71b |
+ return true;
|
|
|
3be71b |
+ else if (rhs_count > lhs_count)
|
|
|
3be71b |
+ return false;
|
|
|
3be71b |
+
|
|
|
3be71b |
+ lhs_it++;
|
|
|
3be71b |
+ rhs_it++;
|
|
|
3be71b |
+ }
|
|
|
3be71b |
|
|
|
3be71b |
- return true;
|
|
|
3be71b |
+ return (lhs_it != lhs.crend()) ? true : false;
|
|
|
3be71b |
}
|
|
|
3be71b |
|
|
|
3be71b |
class gatherer {
|
|
|
3be71b |
--
|
|
|
3be71b |
1.8.3.1
|
|
|
3be71b |
|