[thin_generate_metadata] Support setting the needs_check flag

This commit is contained in:
Ming-Hung Tsai 2020-07-21 17:33:52 +08:00
parent aabc3a9dbc
commit 8d8ee51599
3 changed files with 19 additions and 0 deletions

View File

@ -43,6 +43,7 @@ namespace {
METADATA_OP_SET_TRANSACTION_ID, METADATA_OP_SET_TRANSACTION_ID,
METADATA_OP_RESERVE_METADATA_SNAP, METADATA_OP_RESERVE_METADATA_SNAP,
METADATA_OP_RELEASE_METADATA_SNAP, METADATA_OP_RELEASE_METADATA_SNAP,
METADATA_OP_SET_NEEDS_CHECK,
METADATA_OP_LAST METADATA_OP_LAST
}; };
@ -133,6 +134,9 @@ namespace {
case flags::METADATA_OP_RELEASE_METADATA_SNAP: case flags::METADATA_OP_RELEASE_METADATA_SNAP:
pool->release_metadata_snap(); pool->release_metadata_snap();
break; break;
case flags::METADATA_OP_SET_NEEDS_CHECK:
pool->set_needs_check();
break;
default: default:
break; break;
} }
@ -163,6 +167,7 @@ thin_generate_metadata_cmd::usage(std::ostream &out) const
<< " {--reserve-metadata-snap}\n" << " {--reserve-metadata-snap}\n"
<< " {--release-metadata-snap}\n" << " {--release-metadata-snap}\n"
<< " {--set-transaction-id} <tid>\n" << " {--set-transaction-id} <tid>\n"
<< " {--set-needs-check}\n"
<< " {--data-block-size} <block size>\n" << " {--data-block-size} <block size>\n"
<< " {--nr-data-blocks} <nr>\n" << " {--nr-data-blocks} <nr>\n"
<< " {--origin} <origin-id>\n" << " {--origin} <origin-id>\n"
@ -187,6 +192,7 @@ thin_generate_metadata_cmd::run(int argc, char **argv)
{ "set-transaction-id", required_argument, NULL, 6 }, { "set-transaction-id", required_argument, NULL, 6 },
{ "reserve-metadata-snap", no_argument, NULL, 7 }, { "reserve-metadata-snap", no_argument, NULL, 7 },
{ "release-metadata-snap", no_argument, NULL, 8 }, { "release-metadata-snap", no_argument, NULL, 8 },
{ "set-needs-check", no_argument, NULL, 9 },
{ "data-block-size", required_argument, NULL, 101 }, { "data-block-size", required_argument, NULL, 101 },
{ "nr-data-blocks", required_argument, NULL, 102 }, { "nr-data-blocks", required_argument, NULL, 102 },
{ "origin", required_argument, NULL, 401 }, { "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; fs.op = flags::METADATA_OP_RELEASE_METADATA_SNAP;
break; break;
case 9:
fs.op = flags::METADATA_OP_SET_NEEDS_CHECK;
break;
case 101: case 101:
fs.data_block_size = parse_uint64(optarg, "data block size"); fs.data_block_size = parse_uint64(optarg, "data block size");
break; break;

View File

@ -408,6 +408,12 @@ thin_pool::write_changed_details()
} }
} }
void
thin_pool::set_needs_check()
{
md_->sb_.set_needs_check_flag(true);
}
//---------------------------------------------------------------- //----------------------------------------------------------------
void void

View File

@ -99,6 +99,9 @@ namespace thin_provisioning {
thin::ptr open_thin(thin_dev_t); thin::ptr open_thin(thin_dev_t);
void close_thin(thin::ptr td); void close_thin(thin::ptr td);
// updates the superblock
void set_needs_check();
private: private:
friend class thin; friend class thin;
typedef std::map<thin_dev_t, thin::ptr> device_map; typedef std::map<thin_dev_t, thin::ptr> device_map;