From d1a41d01ccf9c77f09053b15ce1314dd3754fbc9 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 9 Nov 2018 12:43:21 +0000 Subject: [PATCH] [thin-check] print out some info fields. These are consumed by lvm. --- functional-tests/thin-functional-tests.scm | 7 +++++++ thin-provisioning/thin_check.cc | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/functional-tests/thin-functional-tests.scm b/functional-tests/thin-functional-tests.scm index 7f8ee0d..970e19d 100644 --- a/functional-tests/thin-functional-tests.scm +++ b/functional-tests/thin-functional-tests.scm @@ -126,6 +126,13 @@ (run-fail-rcv (_ stderr) (thin-check xml) (assert-matches ".*This looks like XML. thin_check only checks the binary metadata format." stderr)))) + (define-scenario (thin-check info-fields) + "Outputs info fields" + (with-valid-metadata (md) + (run-ok-rcv (stdout stderr) (thin-check md) + (assert-matches ".*TRANSACTION_ID=[0-9]+.*" stdout) + (assert-matches ".*METADATA_FREE_BLOCKS=[0-9]+.*" stdout)))) + ;;;----------------------------------------------------------- ;;; thin_restore scenarios ;;;----------------------------------------------------------- diff --git a/thin-provisioning/thin_check.cc b/thin-provisioning/thin_check.cc index f3d30fd..c553cb7 100644 --- a/thin-provisioning/thin_check.cc +++ b/thin-provisioning/thin_check.cc @@ -195,6 +195,13 @@ namespace { return fs.override_mapping_root ? *fs.override_mapping_root : sb.data_mapping_root_; } + void print_info(superblock_detail::superblock const &sb, + transaction_manager::ptr tm) + { + cout << "TRANSACTION_ID=" << sb.trans_id_ << "\n"; + cout << "METADATA_FREE_BLOCKS=" << tm->get_sm()->get_nr_free() << "\n"; + } + error_state metadata_check(string const &path, flags fs) { nested_output out(cerr, 2); if (fs.quiet) @@ -228,6 +235,9 @@ namespace { transaction_manager::ptr tm = open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION); + if (!fs.quiet) + print_info(sb, tm); + if (fs.check_device_tree) { out << "examining devices tree" << end_message(); {