import device-mapper-persistent-data-0.9.0-6.el8
This commit is contained in:
parent
f5c797e3ca
commit
266eba80cc
@ -0,0 +1,72 @@
|
||||
From 9388ab17da885dbd99d8b68217b282646ce9d73d 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 1/3] [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.
|
||||
|
||||
(cherry picked from commit 371df963113e7af7b97d2158757e35c44804ccb4)
|
||||
---
|
||||
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 665c762..37c6969 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 {
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -0,0 +1,122 @@
|
||||
From 4a2b112e98fe4c66f805eb690bfe1ae7ba342e5b Mon Sep 17 00:00:00 2001
|
||||
From: Ming-Hung Tsai <mtsai@redhat.com>
|
||||
Date: Thu, 19 Aug 2021 18:38:23 +0800
|
||||
Subject: [PATCH 2/3] [thin_repair/thin_dump] Change the label type for empty
|
||||
leaves
|
||||
|
||||
Empty leaves now are treated as bottom-level leaves, so that empty
|
||||
devices could be recovered.
|
||||
|
||||
(cherry picked from commit d3f796f5e35162b0867ee2ba8de781f14ad35c61)
|
||||
---
|
||||
functional-tests/thin-functional-tests.scm | 53 +++++++++++++++++++++++++++++-
|
||||
thin-provisioning/metadata_dumper.cc | 8 +++++
|
||||
2 files changed, 60 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
|
||||
index fcabddf..d06a5a3 100644
|
||||
--- a/functional-tests/thin-functional-tests.scm
|
||||
+++ b/functional-tests/thin-functional-tests.scm
|
||||
@@ -14,7 +14,8 @@
|
||||
(temp-file)
|
||||
(thin metadata)
|
||||
(thin xml)
|
||||
- (srfi s8 receive))
|
||||
+ (srfi s8 receive)
|
||||
+ (xml))
|
||||
|
||||
(define-tool thin-check)
|
||||
(define-tool thin-delta)
|
||||
@@ -96,6 +97,32 @@
|
||||
;; to run.
|
||||
(define (register-thin-tests) #t)
|
||||
|
||||
+ ;; XML of metadata with empty thins
|
||||
+ (define xml-with-empty-thins
|
||||
+ (fmt #f
|
||||
+ (tag 'superblock `((uuid . "")
|
||||
+ (time . 0)
|
||||
+ (transaction . 1)
|
||||
+ (flags . 0)
|
||||
+ (version . 2)
|
||||
+ (data-block-size . 128)
|
||||
+ (nr-data-blocks . 1024))
|
||||
+ (tag 'device `((dev-id . 1)
|
||||
+ (mapped-blocks . 16)
|
||||
+ (transaction . 0)
|
||||
+ (creation-time . 0)
|
||||
+ (snap-time . 0))
|
||||
+ (tag 'range-mapping `((origin-begin . 0)
|
||||
+ (data-begin . 0)
|
||||
+ (length . 16)
|
||||
+ (time . 0))))
|
||||
+ (tag 'device `((dev-id . 2)
|
||||
+ (mapped-blocks . 0)
|
||||
+ (transaction . 0)
|
||||
+ (creation-time . 0)
|
||||
+ (snap-time . 0))
|
||||
+ " "))))
|
||||
+
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_check scenarios
|
||||
;;;-----------------------------------------------------------
|
||||
@@ -376,6 +403,17 @@
|
||||
(run-fail-rcv (_ stderr) (thin-dump "--repair" "--transaction-id=5" "--data-block-size=128" md)
|
||||
(assert-matches ".*nr data blocks.*" stderr))))
|
||||
|
||||
+ (define-scenario (thin-dump repair-superblock with-empty-devices)
|
||||
+ "metadata with empty devices could be recovered"
|
||||
+ (with-temp-file-sized ((md "thin.bin" (meg 4)))
|
||||
+ (with-temp-file-containing ((xml "thin.xml" xml-with-empty-thins))
|
||||
+ (run-ok (thin-restore "-i" xml "-o" md)))
|
||||
+ (run-ok-rcv (expected-xml _) (thin-dump md)
|
||||
+ (damage-superblock md)
|
||||
+ (run-ok-rcv (repaired-xml stderr) (thin-dump "--repair" "--transaction-id=1" "--data-block-size=128" "--nr-data-blocks=1024" md)
|
||||
+ (assert-eof stderr)
|
||||
+ (assert-equal expected-xml repaired-xml)))))
|
||||
+
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_rmap scenarios
|
||||
;;;-----------------------------------------------------------
|
||||
@@ -572,6 +610,19 @@
|
||||
(run-fail-rcv (_ stderr) (thin-repair "--transaction-id=5" "--data-block-size=128" "-i" md1 "-o" md2)
|
||||
(assert-matches ".*nr data blocks.*" stderr)))))
|
||||
|
||||
+ (define-scenario (thin-repair superblock with-empty-devices)
|
||||
+ "metadata with empty devices could be recovered"
|
||||
+ (with-temp-file-sized ((md1 "thin.bin" (meg 4)))
|
||||
+ (with-temp-file-containing ((xml "thin.xml" xml-with-empty-thins))
|
||||
+ (run-ok (thin-restore "-i" xml "-o" md1)))
|
||||
+ (run-ok-rcv (expected-xml _) (thin-dump md1)
|
||||
+ (damage-superblock md1)
|
||||
+ (with-empty-metadata (md2)
|
||||
+ (run-ok-rcv (_ stderr) (thin-repair "--transaction-id=1" "--data-block-size=128" "--nr-data-blocks=1024" "-i" md1 "-o" md2)
|
||||
+ (assert-eof stderr))
|
||||
+ (run-ok-rcv (repaired-xml stderr) (thin-dump md2)
|
||||
+ (assert-eof stderr)
|
||||
+ (assert-equal expected-xml repaired-xml))))))
|
||||
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_metadata_pack scenarios
|
||||
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
|
||||
index 37c6969..d169c27 100644
|
||||
--- a/thin-provisioning/metadata_dumper.cc
|
||||
+++ b/thin-provisioning/metadata_dumper.cc
|
||||
@@ -438,6 +438,14 @@ namespace {
|
||||
// in the bottom 24 bits. This means every block/time apart from block 0
|
||||
// will result in a value that's outside the range of the metadata device.
|
||||
bool is_top_level(node_ref<uint64_traits> &n) {
|
||||
+ // A leaf node of value-size 8 and without mappings should be
|
||||
+ // treated as a bottom-level leaf, so that it could be referenced
|
||||
+ // by top-level nodes, if any. On the other hand, an empty
|
||||
+ // top-level leaf doesn't help repairing.
|
||||
+ if (!n.get_nr_entries()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
auto nr_metadata_blocks = bm_.get_nr_blocks();
|
||||
|
||||
for (unsigned i = 0; i < n.get_nr_entries(); i++)
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -0,0 +1,129 @@
|
||||
From 992bb5feeb9e1994d4c31b4b13dbae594dd3c87a Mon Sep 17 00:00:00 2001
|
||||
From: Ming-Hung Tsai <mtsai@redhat.com>
|
||||
Date: Tue, 24 Aug 2021 16:20:50 +0800
|
||||
Subject: [PATCH 3/3] [thin_repair/thin_dump] Check consistency of thin_ids
|
||||
before running a regular dump
|
||||
|
||||
(cherry picked from commit 73dda15b5977dfa45cbfa36edddf4c19d279767b)
|
||||
---
|
||||
functional-tests/thin-functional-tests.scm | 56 ++++++++++++++++++++++++++++++
|
||||
thin-provisioning/metadata_dumper.cc | 8 +++--
|
||||
2 files changed, 62 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
|
||||
index d06a5a3..37d3df9 100644
|
||||
--- a/functional-tests/thin-functional-tests.scm
|
||||
+++ b/functional-tests/thin-functional-tests.scm
|
||||
@@ -81,6 +81,15 @@
|
||||
(let ((csum (checksum-block b (ftype-sizeof unsigned-32) superblock-salt)))
|
||||
(ftype-set! ThinSuperblock (csum) sb csum))))))
|
||||
|
||||
+ (define (tamper-mapping-root md mapping-root)
|
||||
+ (with-bcache (cache md 1)
|
||||
+ (with-block (b cache 0 (get-flags dirty))
|
||||
+ (let ((sb (block->superblock b)))
|
||||
+ (ftype-set! ThinSuperblock (data-mapping-root) sb mapping-root)
|
||||
+ ;;;;;; Update the csum manually since the block validator for ft-lib is not ready
|
||||
+ (let ((csum (checksum-block b (ftype-sizeof unsigned-32) superblock-salt)))
|
||||
+ (ftype-set! ThinSuperblock (csum) sb csum))))))
|
||||
+
|
||||
(define (get-superblock-flags md)
|
||||
(with-bcache (cache md 1)
|
||||
(with-block (b cache 0 (get-flags))
|
||||
@@ -97,6 +106,26 @@
|
||||
;; to run.
|
||||
(define (register-thin-tests) #t)
|
||||
|
||||
+ ;; An deterministic simple XML for testing
|
||||
+ (define simple-thin-xml
|
||||
+ (fmt #f
|
||||
+ (tag 'superblock `((uuid . "")
|
||||
+ (time . 0)
|
||||
+ (transaction . 1)
|
||||
+ (flags . 0)
|
||||
+ (version . 2)
|
||||
+ (data-block-size . 128)
|
||||
+ (nr-data-blocks . 1024))
|
||||
+ (tag 'device `((dev-id . 1)
|
||||
+ (mapped-blocks . 16)
|
||||
+ (transaction . 0)
|
||||
+ (creation-time . 0)
|
||||
+ (snap-time . 0))
|
||||
+ (tag 'range-mapping `((origin-begin . 0)
|
||||
+ (data-begin . 0)
|
||||
+ (length . 16)
|
||||
+ (time . 0)))))))
|
||||
+
|
||||
;; XML of metadata with empty thins
|
||||
(define xml-with-empty-thins
|
||||
(fmt #f
|
||||
@@ -414,6 +443,18 @@
|
||||
(assert-eof stderr)
|
||||
(assert-equal expected-xml repaired-xml)))))
|
||||
|
||||
+ (define-scenario (thin-dump repair-superblock inconsistent-device-ids)
|
||||
+ "metadata with inconsistent device ids should be repaired"
|
||||
+ (with-temp-file-sized ((md "thin.bin" (meg 4)))
|
||||
+ (with-temp-file-containing ((xml "thin.xml" simple-thin-xml))
|
||||
+ (run-ok (thin-restore "-i" xml "-o" md)))
|
||||
+ (run-ok-rcv (expected-xml _) (thin-dump md)
|
||||
+ ;;;;;; simulate multiple activation by replacing the mapping root with a bottom-level leaf
|
||||
+ (tamper-mapping-root md 10)
|
||||
+ (run-ok-rcv (repaired-xml stderr) (thin-dump "--repair" md)
|
||||
+ (assert-eof stderr)
|
||||
+ (assert-equal expected-xml repaired-xml)))))
|
||||
+
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_rmap scenarios
|
||||
;;;-----------------------------------------------------------
|
||||
@@ -624,6 +665,21 @@
|
||||
(assert-eof stderr)
|
||||
(assert-equal expected-xml repaired-xml))))))
|
||||
|
||||
+ (define-scenario (thin-repair superblock inconsistent-device-ids)
|
||||
+ "metadata with inconsistent device ids should be repaired"
|
||||
+ (with-temp-file-sized ((md1 "thin.bin" (meg 4)))
|
||||
+ (with-temp-file-containing ((xml "thin.xml" simple-thin-xml))
|
||||
+ (run-ok (thin-restore "-i" xml "-o" md1)))
|
||||
+ (run-ok-rcv (expected-xml _) (thin-dump md1)
|
||||
+ ;;;;;; simulate multiple activation by replacing the mapping root with a bottom-level leaf
|
||||
+ (tamper-mapping-root md1 10)
|
||||
+ (with-empty-metadata (md2)
|
||||
+ (run-ok-rcv (_ stderr) (thin-repair "-i" md1 "-o" md2)
|
||||
+ (assert-eof stderr))
|
||||
+ (run-ok-rcv (repaired-xml stderr) (thin-dump md2)
|
||||
+ (assert-eof stderr)
|
||||
+ (assert-equal expected-xml repaired-xml))))))
|
||||
+
|
||||
;;;-----------------------------------------------------------
|
||||
;;; thin_metadata_pack scenarios
|
||||
;;;-----------------------------------------------------------
|
||||
diff --git a/thin-provisioning/metadata_dumper.cc b/thin-provisioning/metadata_dumper.cc
|
||||
index d169c27..0ca4afe 100644
|
||||
--- a/thin-provisioning/metadata_dumper.cc
|
||||
+++ b/thin-provisioning/metadata_dumper.cc
|
||||
@@ -412,6 +412,9 @@ namespace {
|
||||
if (rhs == ms.end())
|
||||
continue;
|
||||
|
||||
+ if (lhs->second != rhs->second)
|
||||
+ continue;
|
||||
+
|
||||
filtered.push_back(make_pair(p.first.b, p.second.b));
|
||||
}
|
||||
|
||||
@@ -886,8 +889,9 @@ namespace {
|
||||
|
||||
auto tm = open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION);
|
||||
|
||||
- if (!get_dev_ids(*tm, msb->device_details_root_) ||
|
||||
- !get_map_ids(*tm, msb->data_mapping_root_))
|
||||
+ auto maybe_dev_ids = get_dev_ids(*tm, msb->device_details_root_);
|
||||
+ auto maybe_map_ids = get_map_ids(*tm, msb->data_mapping_root_);
|
||||
+ if (!maybe_dev_ids || !maybe_map_ids || (*maybe_dev_ids) != (*maybe_map_ids))
|
||||
find_better_roots_(bm, *msb);
|
||||
|
||||
emit_trees_(bm, *msb, e, opts);
|
||||
--
|
||||
1.8.3.1
|
||||
|
@ -0,0 +1,338 @@
|
||||
From 6ce838b83c28d9b64f34cf0c68cfebaf9affac11 Mon Sep 17 00:00:00 2001
|
||||
From: Ming-Hung Tsai <mtsai@redhat.com>
|
||||
Date: Fri, 21 Aug 2020 18:26:48 +0800
|
||||
Subject: [PATCH] [thin_check] Allow using --clear-needs-check and
|
||||
--skip-mappings together
|
||||
|
||||
Although it is not recommended to clear the flag without a full
|
||||
examination, however, the usage has been documented as an approach
|
||||
to reduce lvchange run time [1]. For the purpose of backward
|
||||
compatibility and avoiding boot failure after upgrading thin_check [2],
|
||||
the limitation is now removed.
|
||||
|
||||
[1] https://wiki.archlinux.org/index.php/LVM#Thinly-provisioned_root_volume_device_times_out
|
||||
[2] Community feedback on previous commit:
|
||||
https://github.com/jthornber/thin-provisioning-tools/commit/b278f4f
|
||||
|
||||
(cherry picked from commit f4675e3f32aad3d1518869e4f3824e05230c6a5d)
|
||||
---
|
||||
functional-tests/thin-functional-tests.scm | 65 +++++++++++++---
|
||||
thin-provisioning/metadata_checker.cc | 88 +++++++++++-----------
|
||||
thin-provisioning/metadata_checker.h | 5 +-
|
||||
thin-provisioning/thin_check.cc | 2 +-
|
||||
4 files changed, 106 insertions(+), 54 deletions(-)
|
||||
|
||||
diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm
|
||||
index 37d3df9..5b1423c 100644
|
||||
--- a/functional-tests/thin-functional-tests.scm
|
||||
+++ b/functional-tests/thin-functional-tests.scm
|
||||
@@ -189,15 +189,6 @@
|
||||
(run-fail (thin-check "--auto-repair" "--skip-mappings" md))
|
||||
(run-fail (thin-check "--auto-repair" "--ignore-non-fatal-errors" md))))
|
||||
|
||||
- (define-scenario (thin-check incompatible-options clear-needs-check-flag)
|
||||
- "Incompatible options should cause failure"
|
||||
- (with-valid-metadata (md)
|
||||
- (run-fail (thin-check "--clear-needs-check-flag" "-m" md))
|
||||
- (run-fail (thin-check "--clear-needs-check-flag" "--override-mapping-root 123" md))
|
||||
- (run-fail (thin-check "--clear-needs-check-flag" "--super-block-only" md))
|
||||
- (run-fail (thin-check "--clear-needs-check-flag" "--skip-mappings" md))
|
||||
- (run-fail (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))))
|
||||
-
|
||||
(define-scenario (thin-check superblock-only-valid)
|
||||
"--super-block-only check passes on valid metadata"
|
||||
(with-valid-metadata (md)
|
||||
@@ -230,6 +221,62 @@
|
||||
(with-valid-metadata (md)
|
||||
(run-ok (thin-check "--clear-needs-check-flag" md))))
|
||||
|
||||
+ (define-scenario (thin-check mixing-clear-needs-check-flag super-block-only-should-pass)
|
||||
+ "Accepts --clear-needs-check and --super-block-only"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--super-block-only" md))))
|
||||
+
|
||||
+ (define-scenario (thin-check mixing-clear-needs-check-flag skip-mappings-should-pass)
|
||||
+ "Accepts --clear-needs-check and --skip-mappings"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--skip-mappings" md))))
|
||||
+
|
||||
+ (define-scenario (thin-check mixing-clear-needs-check-flag ignore-non-fatal-errors-should-pass)
|
||||
+ "Accepts --clear-needs-check and --ignore-non-fatal-errors"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))))
|
||||
+
|
||||
+ (define-scenario (thin-check try-clear-needs-check-flag super-block-only-should-clear)
|
||||
+ "--clear-needs-check is a noop while using --super-block-only"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (set-needs-check-flag md)
|
||||
+ (assert-metadata-needs-check md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--super-block-only" md))
|
||||
+ (assert-metadata-clean md)))
|
||||
+
|
||||
+ (define-scenario (thin-check try-clear-needs-check-flag skip-mappings-should-clear)
|
||||
+ "--clear-needs-check is a noop while using --skip-mappings"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (set-needs-check-flag md)
|
||||
+ (assert-metadata-needs-check md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--skip-mappings" md))
|
||||
+ (assert-metadata-clean md)))
|
||||
+
|
||||
+ (define-scenario (thin-check try-clear-needs-check-flag ignore-non-fatal-errors-should-clear)
|
||||
+ "--clear-needs-check works while using --ignore-non-fatal-errors"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (set-needs-check-flag md)
|
||||
+ (assert-metadata-needs-check md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" "--ignore-non-fatal-errors" md))
|
||||
+ (assert-metadata-clean md)))
|
||||
+
|
||||
+ (define-scenario (thin-check try-clear-needs-check-flag no-errors-should-clear)
|
||||
+ "--clear-needs-check works if there's no errors"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (set-needs-check-flag md)
|
||||
+ (assert-metadata-needs-check md)
|
||||
+ (run-ok (thin-check "--clear-needs-check-flag" md))
|
||||
+ (assert-metadata-clean md)))
|
||||
+
|
||||
+ (define-scenario (thin-check try-clear-needs-check-flag fatal-errors-should-keep)
|
||||
+ "--clear-needs-check is a noop if there's fatal errors"
|
||||
+ (with-valid-metadata (md)
|
||||
+ (set-needs-check-flag md)
|
||||
+ (tamper-mapping-root md 10)
|
||||
+ (assert-metadata-needs-check md)
|
||||
+ (run-fail (thin-check "--clear-needs-check-flag" md))
|
||||
+ (assert-metadata-needs-check md)))
|
||||
+
|
||||
(define-scenario (thin-check auto-repair)
|
||||
"Accepts --auto-repair"
|
||||
(with-valid-metadata (md)
|
||||
diff --git a/thin-provisioning/metadata_checker.cc b/thin-provisioning/metadata_checker.cc
|
||||
index e81e22c..1c9734e 100644
|
||||
--- a/thin-provisioning/metadata_checker.cc
|
||||
+++ b/thin-provisioning/metadata_checker.cc
|
||||
@@ -371,7 +371,8 @@ namespace {
|
||||
out_(cerr, 2),
|
||||
info_out_(cout, 0),
|
||||
expected_rc_(true), // set stop on the first error
|
||||
- err_(NO_ERROR) {
|
||||
+ err_(NO_ERROR),
|
||||
+ metadata_checked_(false) {
|
||||
|
||||
if (output_opts == OUTPUT_QUIET) {
|
||||
out_.disable();
|
||||
@@ -381,7 +382,29 @@ namespace {
|
||||
sb_location_ = get_superblock_location();
|
||||
}
|
||||
|
||||
- void check() {
|
||||
+ void check_and_repair() {
|
||||
+ if (!check())
|
||||
+ return;
|
||||
+
|
||||
+ if (!options_.use_metadata_snap_ &&
|
||||
+ !options_.override_mapping_root_) {
|
||||
+ if (options_.sm_opts_ == check_options::SPACE_MAP_FULL &&
|
||||
+ options_.fix_metadata_leaks_)
|
||||
+ fix_metadata_leaks(options_.open_transaction_);
|
||||
+ if (options_.clear_needs_check_)
|
||||
+ clear_needs_check_flag();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ bool get_status() const {
|
||||
+ if (options_.ignore_non_fatal_)
|
||||
+ return (err_ == FATAL) ? false : true;
|
||||
+
|
||||
+ return (err_ == NO_ERROR) ? true : false;
|
||||
+ }
|
||||
+
|
||||
+ private:
|
||||
+ bool check() {
|
||||
block_manager::ptr bm = open_bm(path_, block_manager::READ_ONLY,
|
||||
!options_.use_metadata_snap_);
|
||||
|
||||
@@ -389,7 +412,7 @@ namespace {
|
||||
if (err_ == FATAL) {
|
||||
if (check_for_xml(bm))
|
||||
out_ << "This looks like XML. thin_check only checks the binary metadata format." << end_message();
|
||||
- return;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
transaction_manager::ptr tm = open_tm(bm, sb_location_);
|
||||
@@ -407,7 +430,7 @@ namespace {
|
||||
err_ << examine_data_mappings(tm, sb, options_.data_mapping_opts_, out_, core_sm);
|
||||
|
||||
if (err_ == FATAL)
|
||||
- return;
|
||||
+ return false;
|
||||
|
||||
// if we're checking everything, and there were no errors,
|
||||
// then we should check the space maps too.
|
||||
@@ -419,10 +442,14 @@ namespace {
|
||||
} else
|
||||
err_ << examine_data_mappings(tm, sb, options_.data_mapping_opts_, out_,
|
||||
optional<space_map::ptr>());
|
||||
+
|
||||
+ metadata_checked_ = true;
|
||||
+
|
||||
+ return true;
|
||||
}
|
||||
|
||||
bool fix_metadata_leaks(bool open_transaction) {
|
||||
- if (!verify_preconditions_before_fixing()) {
|
||||
+ if (!metadata_checked_) {
|
||||
out_ << "metadata has not been fully examined" << end_message();
|
||||
return false;
|
||||
}
|
||||
@@ -458,12 +485,13 @@ namespace {
|
||||
}
|
||||
|
||||
bool clear_needs_check_flag() {
|
||||
- if (!verify_preconditions_before_fixing()) {
|
||||
+ if (!metadata_checked_) {
|
||||
out_ << "metadata has not been fully examined" << end_message();
|
||||
return false;
|
||||
}
|
||||
|
||||
- if (err_ != NO_ERROR)
|
||||
+ if (err_ == FATAL ||
|
||||
+ (err_ == NON_FATAL && !options_.ignore_non_fatal_))
|
||||
return false;
|
||||
|
||||
block_manager::ptr bm = open_bm(path_, block_manager::READ_WRITE);
|
||||
@@ -480,14 +508,6 @@ namespace {
|
||||
return true;
|
||||
}
|
||||
|
||||
- bool get_status() const {
|
||||
- if (options_.ignore_non_fatal_)
|
||||
- return (err_ == FATAL) ? false : true;
|
||||
-
|
||||
- return (err_ == NO_ERROR) ? true : false;
|
||||
- }
|
||||
-
|
||||
- private:
|
||||
block_address
|
||||
get_superblock_location() {
|
||||
block_address sb_location = superblock_detail::SUPERBLOCK_LOCATION;
|
||||
@@ -545,19 +565,6 @@ namespace {
|
||||
return err;
|
||||
}
|
||||
|
||||
- bool verify_preconditions_before_fixing() const {
|
||||
- if (options_.use_metadata_snap_ ||
|
||||
- !!options_.override_mapping_root_ ||
|
||||
- options_.sm_opts_ != check_options::SPACE_MAP_FULL ||
|
||||
- options_.data_mapping_opts_ != check_options::DATA_MAPPING_LEVEL2)
|
||||
- return false;
|
||||
-
|
||||
- if (!expected_rc_.get_counts().size())
|
||||
- return false;
|
||||
-
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
std::string const &path_;
|
||||
check_options options_;
|
||||
nested_output out_;
|
||||
@@ -565,6 +572,7 @@ namespace {
|
||||
block_address sb_location_;
|
||||
block_counter expected_rc_;
|
||||
base::error_state err_; // metadata state
|
||||
+ bool metadata_checked_;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -603,8 +611,9 @@ void check_options::set_ignore_non_fatal() {
|
||||
ignore_non_fatal_ = true;
|
||||
}
|
||||
|
||||
-void check_options::set_fix_metadata_leaks() {
|
||||
+void check_options::set_auto_repair() {
|
||||
fix_metadata_leaks_ = true;
|
||||
+ clear_needs_check_ = true;
|
||||
}
|
||||
|
||||
void check_options::set_clear_needs_check() {
|
||||
@@ -612,7 +621,7 @@ void check_options::set_clear_needs_check() {
|
||||
}
|
||||
|
||||
bool check_options::check_conformance() {
|
||||
- if (fix_metadata_leaks_ || clear_needs_check_) {
|
||||
+ if (fix_metadata_leaks_) {
|
||||
if (ignore_non_fatal_) {
|
||||
cerr << "cannot perform fix by ignoring non-fatal errors" << endl;
|
||||
return false;
|
||||
@@ -627,12 +636,12 @@ bool check_options::check_conformance() {
|
||||
cerr << "cannot perform fix with an overridden mapping root" << endl;
|
||||
return false;
|
||||
}
|
||||
+ }
|
||||
|
||||
- if (data_mapping_opts_ != DATA_MAPPING_LEVEL2 ||
|
||||
- sm_opts_ != SPACE_MAP_FULL) {
|
||||
- cerr << "cannot perform fix without a full examination" << endl;
|
||||
- return false;
|
||||
- }
|
||||
+ if (fix_metadata_leaks_ &&
|
||||
+ (data_mapping_opts_ != DATA_MAPPING_LEVEL2 || sm_opts_ != SPACE_MAP_FULL)) {
|
||||
+ cerr << "cannot perform fix without a full examination" << endl;
|
||||
+ return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -646,14 +655,7 @@ thin_provisioning::check_metadata(std::string const &path,
|
||||
output_options output_opts)
|
||||
{
|
||||
metadata_checker checker(path, check_opts, output_opts);
|
||||
-
|
||||
- checker.check();
|
||||
- if (check_opts.fix_metadata_leaks_)
|
||||
- checker.fix_metadata_leaks(check_opts.open_transaction_);
|
||||
- if (check_opts.fix_metadata_leaks_ ||
|
||||
- check_opts.clear_needs_check_)
|
||||
- checker.clear_needs_check_flag();
|
||||
-
|
||||
+ checker.check_and_repair();
|
||||
return checker.get_status();
|
||||
}
|
||||
|
||||
diff --git a/thin-provisioning/metadata_checker.h b/thin-provisioning/metadata_checker.h
|
||||
index 5569d27..ea66dc3 100644
|
||||
--- a/thin-provisioning/metadata_checker.h
|
||||
+++ b/thin-provisioning/metadata_checker.h
|
||||
@@ -45,14 +45,17 @@ namespace thin_provisioning {
|
||||
void set_override_mapping_root(bcache::block_address b);
|
||||
void set_metadata_snap();
|
||||
void set_ignore_non_fatal();
|
||||
- void set_fix_metadata_leaks();
|
||||
+ void set_auto_repair();
|
||||
void set_clear_needs_check();
|
||||
|
||||
+ // flags for checking
|
||||
bool use_metadata_snap_;
|
||||
data_mapping_options data_mapping_opts_;
|
||||
space_map_options sm_opts_;
|
||||
boost::optional<bcache::block_address> override_mapping_root_;
|
||||
bool ignore_non_fatal_;
|
||||
+
|
||||
+ // flags for repairing
|
||||
bool fix_metadata_leaks_;
|
||||
bool clear_needs_check_;
|
||||
bool open_transaction_;
|
||||
diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc
|
||||
index 60f7838..e3c9db3 100644
|
||||
--- a/thin-provisioning/thin_check.cc
|
||||
+++ b/thin-provisioning/thin_check.cc
|
||||
@@ -166,7 +166,7 @@ thin_check_cmd::run(int argc, char **argv)
|
||||
|
||||
case 6:
|
||||
// auto-repair
|
||||
- fs.check_opts.set_fix_metadata_leaks();
|
||||
+ fs.check_opts.set_auto_repair();
|
||||
break;
|
||||
|
||||
default:
|
||||
--
|
||||
2.31.1
|
||||
|
@ -10,7 +10,7 @@
|
||||
Summary: Device-mapper Persistent Data Tools
|
||||
Name: device-mapper-persistent-data
|
||||
Version: 0.9.0
|
||||
Release: 4%{?dist}%{?release_suffix}
|
||||
Release: 6%{?dist}%{?release_suffix}
|
||||
License: GPLv3+
|
||||
URL: https://github.com/jthornber/thin-provisioning-tools
|
||||
#Source0: https://github.com/jthornber/thin-provisioning-tools/archive/thin-provisioning-tools-%%{version}.tar.gz
|
||||
@ -36,6 +36,14 @@ Patch14: 0013-build-Remove-lboost_iostreams-linker-flag.patch
|
||||
Patch15: 0014-cargo-update.patch
|
||||
# BZ 1993290:
|
||||
Patch16: 0015-thin-Clear-superblock-flags-in-restored-metadata.patch
|
||||
# BZ 2001000:
|
||||
Patch17: 0016-thin_repair-thin_dump-Fix-sorting-of-data-mapping-ca.patch
|
||||
# BZ 2000896:
|
||||
Patch18: 0017-thin_repair-thin_dump-Change-the-label-type-for-empt.patch
|
||||
# BZ 2000981:
|
||||
Patch19: 0018-thin_repair-thin_dump-Check-consistency-of-thin_ids-.patch
|
||||
# BZ 2028905:
|
||||
Patch20: 0019-thin_check-Allow-using-clear-needs-check-and-skip-ma.patch
|
||||
|
||||
BuildRequires: autoconf, expat-devel, libaio-devel, libstdc++-devel, boost-devel, gcc-c++
|
||||
Requires: expat
|
||||
@ -88,6 +96,10 @@ END
|
||||
%patch14 -p1 -b .backup14
|
||||
# NOTE: patch 15 is above at the rust setup
|
||||
%patch16 -p1 -b .backup16
|
||||
%patch17 -p1 -b .backup17
|
||||
%patch18 -p1 -b .backup18
|
||||
%patch19 -p1 -b .backup19
|
||||
%patch20 -p1 -b .backup20
|
||||
echo %{version}-%{release} > VERSION
|
||||
|
||||
%build
|
||||
@ -158,6 +170,12 @@ make DESTDIR=%{buildroot} MANDIR=%{_mandir} install-rust-tools
|
||||
#% {_sbindir}/thin_show_duplicates
|
||||
|
||||
%changelog
|
||||
* Wed Dec 08 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-6
|
||||
- Allows --clear-needs-check with --super-block-only or --skip-mappings.
|
||||
|
||||
* Tue Sep 07 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-5
|
||||
- Fix several corner cases in thin_repair.
|
||||
|
||||
* Tue Aug 16 2021 Marian Csontos <mcsontos@redhat.com> - 0.9.0-4
|
||||
- Fix thin_repair clearing needs_check flag in repaired metadata.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user