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