From 8d8ee5159979d7d8adac4f808ebc9930d9870300 Mon Sep 17 00:00:00 2001 From: Ming-Hung Tsai Date: Tue, 21 Jul 2020 17:33:52 +0800 Subject: [PATCH] [thin_generate_metadata] Support setting the needs_check flag --- thin-provisioning/thin_generate_metadata.cc | 10 ++++++++++ thin-provisioning/thin_pool.cc | 6 ++++++ thin-provisioning/thin_pool.h | 3 +++ 3 files changed, 19 insertions(+) diff --git a/thin-provisioning/thin_generate_metadata.cc b/thin-provisioning/thin_generate_metadata.cc index e535273..d30aec1 100644 --- a/thin-provisioning/thin_generate_metadata.cc +++ b/thin-provisioning/thin_generate_metadata.cc @@ -43,6 +43,7 @@ namespace { METADATA_OP_SET_TRANSACTION_ID, METADATA_OP_RESERVE_METADATA_SNAP, METADATA_OP_RELEASE_METADATA_SNAP, + METADATA_OP_SET_NEEDS_CHECK, METADATA_OP_LAST }; @@ -133,6 +134,9 @@ namespace { case flags::METADATA_OP_RELEASE_METADATA_SNAP: pool->release_metadata_snap(); break; + case flags::METADATA_OP_SET_NEEDS_CHECK: + pool->set_needs_check(); + break; default: break; } @@ -163,6 +167,7 @@ thin_generate_metadata_cmd::usage(std::ostream &out) const << " {--reserve-metadata-snap}\n" << " {--release-metadata-snap}\n" << " {--set-transaction-id} \n" + << " {--set-needs-check}\n" << " {--data-block-size} \n" << " {--nr-data-blocks} \n" << " {--origin} \n" @@ -187,6 +192,7 @@ thin_generate_metadata_cmd::run(int argc, char **argv) { "set-transaction-id", required_argument, NULL, 6 }, { "reserve-metadata-snap", no_argument, NULL, 7 }, { "release-metadata-snap", no_argument, NULL, 8 }, + { "set-needs-check", no_argument, NULL, 9 }, { "data-block-size", required_argument, NULL, 101 }, { "nr-data-blocks", required_argument, NULL, 102 }, { "origin", required_argument, NULL, 401 }, @@ -240,6 +246,10 @@ thin_generate_metadata_cmd::run(int argc, char **argv) fs.op = flags::METADATA_OP_RELEASE_METADATA_SNAP; break; + case 9: + fs.op = flags::METADATA_OP_SET_NEEDS_CHECK; + break; + case 101: fs.data_block_size = parse_uint64(optarg, "data block size"); break; diff --git a/thin-provisioning/thin_pool.cc b/thin-provisioning/thin_pool.cc index 3a34ba8..629fce6 100644 --- a/thin-provisioning/thin_pool.cc +++ b/thin-provisioning/thin_pool.cc @@ -408,6 +408,12 @@ thin_pool::write_changed_details() } } +void +thin_pool::set_needs_check() +{ + md_->sb_.set_needs_check_flag(true); +} + //---------------------------------------------------------------- void diff --git a/thin-provisioning/thin_pool.h b/thin-provisioning/thin_pool.h index 62f6945..74a26db 100644 --- a/thin-provisioning/thin_pool.h +++ b/thin-provisioning/thin_pool.h @@ -99,6 +99,9 @@ namespace thin_provisioning { thin::ptr open_thin(thin_dev_t); void close_thin(thin::ptr td); + // updates the superblock + void set_needs_check(); + private: friend class thin; typedef std::map device_map;