From b7d20bce480ec9e593dac67face36f7d1bc39ce8 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Fri, 1 May 2020 14:11:33 +0100 Subject: [PATCH] [dev-tools] Update dev tools to use non-template version of block_manager. --- thin-provisioning/thin_generate_metadata.cc | 2 +- thin-provisioning/thin_journal.cc | 4 +-- thin-provisioning/thin_journal.h | 8 +++--- thin-provisioning/thin_journal_check.cc | 12 ++++---- thin-provisioning/thin_ll_dump.cc | 14 ++++----- thin-provisioning/thin_ll_restore.cc | 8 +++--- thin-provisioning/thin_scan.cc | 20 ++++++------- thin-provisioning/thin_show_duplicates.cc | 2 +- thin-provisioning/thin_show_metadata.cc | 32 ++++++++++----------- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/thin-provisioning/thin_generate_metadata.cc b/thin-provisioning/thin_generate_metadata.cc index 6eb3c62..0891864 100644 --- a/thin-provisioning/thin_generate_metadata.cc +++ b/thin-provisioning/thin_generate_metadata.cc @@ -107,7 +107,7 @@ namespace { int create_metadata(flags const &fs) { try { // The block size gets updated by the restorer. - block_manager<>::ptr bm(open_bm(*fs.output, block_manager<>::READ_WRITE)); + block_manager::ptr bm(open_bm(*fs.output, block_manager::READ_WRITE)); metadata::ptr md(new metadata(bm, metadata::CREATE, 128, 0)); emitter::ptr restorer = create_restore_emitter(md); diff --git a/thin-provisioning/thin_journal.cc b/thin-provisioning/thin_journal.cc index b24eea1..bcccb71 100644 --- a/thin-provisioning/thin_journal.cc +++ b/thin-provisioning/thin_journal.cc @@ -26,7 +26,7 @@ using namespace std; //---------------------------------------------------------------- -byte_stream::byte_stream(block_manager::ptr bm) +byte_stream::byte_stream(block_manager::ptr bm) : bm_(bm), current_block_(0), cursor_(0) @@ -238,7 +238,7 @@ set_read_write_msg::visit(journal_visitor &v) const //------------------------------------------ -journal::journal(block_manager::ptr bm) +journal::journal(block_manager::ptr bm) : in_(bm) { } diff --git a/thin-provisioning/thin_journal.h b/thin-provisioning/thin_journal.h index 1f8cbbe..1f44a6c 100644 --- a/thin-provisioning/thin_journal.h +++ b/thin-provisioning/thin_journal.h @@ -26,13 +26,13 @@ //---------------------------------------------------------------- namespace thin_provisioning { - uint32_t const JOURNAL_BLOCK_SIZE = 256 * 1024; + uint32_t const JOURNAL_BLOCK_SIZE = 4096; uint32_t const JOURNAL_CHUNK_SIZE = 32; uint32_t const JOURNAL_NR_CHUNKS = (4096 / JOURNAL_CHUNK_SIZE); class byte_stream { public: - byte_stream(persistent_data::block_manager::ptr bm); + byte_stream(persistent_data::block_manager::ptr bm); void read_bytes(uint8_t *b, uint8_t *e); @@ -40,7 +40,7 @@ namespace thin_provisioning { void next_block_(); size_t read_some_(uint8_t *b, uint8_t *e); - persistent_data::block_manager::ptr bm_; + persistent_data::block_manager::ptr bm_; uint64_t current_block_; uint64_t cursor_; @@ -195,7 +195,7 @@ namespace thin_provisioning { class journal { public: - journal(persistent_data::block_manager::ptr bm); + journal(persistent_data::block_manager::ptr bm); void read_journal(struct journal_visitor &v); private: diff --git a/thin-provisioning/thin_journal_check.cc b/thin-provisioning/thin_journal_check.cc index 0747d6f..4a7f680 100644 --- a/thin-provisioning/thin_journal_check.cc +++ b/thin-provisioning/thin_journal_check.cc @@ -154,8 +154,8 @@ namespace { class checker : public journal_visitor { public: virtual void visit(open_journal_msg const &msg) { - bm_.reset(new block_manager<>("metadata.tmp", msg.nr_metadata_blocks_, - MAX_HELD_LOCKS, block_manager<>::CREATE)); + bm_.reset(new block_manager("metadata.tmp", msg.nr_metadata_blocks_, + MAX_HELD_LOCKS, block_manager::CREATE)); } virtual void visit(close_journal_msg const &msg) { @@ -364,7 +364,7 @@ namespace { block_set active_; block_map locks_; - block_manager<>::ptr bm_; + block_manager::ptr bm_; transaction_manager::ptr tm_; }; @@ -378,9 +378,9 @@ namespace { void check(string const &path) { block_address journal_size = get_file_length(path) / JOURNAL_BLOCK_SIZE; - block_manager::ptr bm( - new block_manager(path, journal_size, 4, - block_manager::READ_ONLY)); + block_manager::ptr bm( + new block_manager(path, journal_size, 4, + block_manager::READ_ONLY)); journal j(bm); checker c; journal_display dc(c); diff --git a/thin-provisioning/thin_ll_dump.cc b/thin-provisioning/thin_ll_dump.cc index 71896ad..e6048d0 100644 --- a/thin-provisioning/thin_ll_dump.cc +++ b/thin-provisioning/thin_ll_dump.cc @@ -85,7 +85,7 @@ namespace { //------------------------------------------------------------------- - void find_btree_nodes(block_manager<>::ptr bm, + void find_btree_nodes(block_manager::ptr bm, block_address begin, block_address end, btree_node_checker::ptr checker, @@ -93,7 +93,7 @@ namespace { using namespace persistent_data; for (block_address b = begin; b < end; ++b) { - block_manager<>::read_ref rr = bm->read_lock(b); + block_manager::read_ref rr = bm->read_lock(b); node_ref n = btree_detail::to_node(rr); if (checker->check(n)) @@ -133,7 +133,7 @@ namespace { class ll_mapping_tree_emitter : public mapping_tree_detail::device_visitor { public: - ll_mapping_tree_emitter(block_manager<>::ptr bm, + ll_mapping_tree_emitter(block_manager::ptr bm, indented_stream &out) : bm_(bm), out_(out) { } @@ -145,7 +145,7 @@ namespace { // Do not throw exception. Process the next entry inside the current node. try { - block_manager<>::read_ref rr = bm_->read_lock(tree_root); + block_manager::read_ref rr = bm_->read_lock(tree_root); node_ref n = btree_detail::to_node(rr); node_info ni; convert_to_node_info(n, ni); @@ -159,7 +159,7 @@ namespace { out_ << "" << endl; } private: - block_manager<>::ptr bm_; + block_manager::ptr bm_; indented_stream& out_; }; @@ -180,7 +180,7 @@ namespace { int low_level_dump_(string const &input, std::ostream &output, flags const &f) { - block_manager<>::ptr bm = open_bm(input, block_manager<>::READ_ONLY); + block_manager::ptr bm = open_bm(input, block_manager::READ_ONLY); block_address scan_begin = f.scan_begin_ ? *f.scan_begin_ : 0; block_address scan_end = f.scan_end_ ? *f.scan_end_ : bm->get_nr_blocks(); @@ -239,7 +239,7 @@ namespace { ++it) { if (it->begin_ && it->end_) { for (block_address b = *it->begin_; b < *it->end_; ++b) { - block_manager<>::read_ref rr = bm->read_lock(b); + block_manager::read_ref rr = bm->read_lock(b); node_ref n = btree_detail::to_node(rr); nodes.push_back(node_info()); convert_to_node_info(n, nodes.back()); diff --git a/thin-provisioning/thin_ll_restore.cc b/thin-provisioning/thin_ll_restore.cc index ff62298..9f5288d 100644 --- a/thin-provisioning/thin_ll_restore.cc +++ b/thin-provisioning/thin_ll_restore.cc @@ -38,8 +38,8 @@ using namespace xml_utils; namespace { struct user_data { - block_manager<>::ptr input_bm_; - block_manager<>::ptr output_bm_; + block_manager::ptr input_bm_; + block_manager::ptr output_bm_; metadata::ptr md_; XML_Parser parser_; @@ -166,8 +166,8 @@ namespace { int low_level_restore_(string const &src_metadata, string const &input, string const &output, flags const &f) { user_data ud; - ud.input_bm_ = open_bm(src_metadata, block_manager<>::READ_ONLY); - ud.output_bm_ = open_bm(output, block_manager<>::READ_WRITE); + ud.input_bm_ = open_bm(src_metadata, block_manager::READ_ONLY); + ud.output_bm_ = open_bm(output, block_manager::READ_WRITE); xml_parser p; ud.parser_ = p.get_parser(); diff --git a/thin-provisioning/thin_scan.cc b/thin-provisioning/thin_scan.cc index 517c954..cf08fc2 100644 --- a/thin-provisioning/thin_scan.cc +++ b/thin-provisioning/thin_scan.cc @@ -142,7 +142,7 @@ namespace { virtual ~block_range() {} virtual void reset(int type, - typename block_manager<>::read_ref &rr, + typename block_manager::read_ref &rr, int64_t ref_count) { begin_ = rr.get_location(); end_ = begin_ + 1; @@ -241,7 +241,7 @@ namespace { } virtual void reset(int type, - typename block_manager<>::read_ref &rr, + typename block_manager::read_ref &rr, int64_t ref_count) { using namespace persistent_data; using namespace sm_disk_detail; @@ -338,7 +338,7 @@ namespace { } virtual void reset(int type, - typename block_manager<>::read_ref &rr, + typename block_manager::read_ref &rr, int64_t ref_count) { node_ref n = btree_detail::to_node(rr); @@ -423,7 +423,7 @@ namespace { public: virtual ~range_factory() {} - block_range const &convert_to_range(block_manager<>::read_ref rr, int64_t ref_count) { + block_range const &convert_to_range(block_manager::read_ref rr, int64_t ref_count) { if (!memcmp(rr.data(), zeros_.data(), MD_BLOCK_SIZE)) { br_.reset(ZERO, rr, ref_count); return br_; @@ -465,7 +465,7 @@ namespace { class metadata_scanner { public: - metadata_scanner(block_manager<>::ptr bm, uint64_t scan_begin, uint64_t scan_end, + metadata_scanner(block_manager::ptr bm, uint64_t scan_begin, uint64_t scan_end, bool check_for_strings) : bm_(bm), scan_begin_(scan_begin), @@ -531,7 +531,7 @@ namespace { // asci text within our metadata is a sure sign of corruption. optional > - scan_strings(block_manager<>::read_ref rr) + scan_strings(block_manager::read_ref rr) { vector r; const char *data = reinterpret_cast(rr.data()), *end = data + MD_BLOCK_SIZE; @@ -548,7 +548,7 @@ namespace { } block_range const &read_block(block_address b) { - block_manager<>::read_ref rr = bm_->read_lock(b); + block_manager::read_ref rr = bm_->read_lock(b); int64_t ref_count; try { ref_count = metadata_sm_ ? static_cast(metadata_sm_->get_count(b)) : -1; @@ -568,7 +568,7 @@ namespace { // note: space_map does not take the ownership of transaction_manager, // so the transaction_manager must live in the same scope of space_map. - block_manager<>::ptr bm_; + block_manager::ptr bm_; transaction_manager::ptr tm_; checked_space_map::ptr metadata_sm_; @@ -601,8 +601,8 @@ namespace { int scan_metadata_(string const &input, std::ostream &out, flags const &f) { - block_manager<>::ptr bm; - bm = open_bm(input, block_manager<>::READ_ONLY, f.exclusive_); + block_manager::ptr bm; + bm = open_bm(input, block_manager::READ_ONLY, f.exclusive_); block_address scan_begin = f.scan_begin_ ? *f.scan_begin_ : 0; block_address scan_end = f.scan_end_ ? *f.scan_end_ : bm->get_nr_blocks(); diff --git a/thin-provisioning/thin_show_duplicates.cc b/thin-provisioning/thin_show_duplicates.cc index 7c6c6f2..b1eebb7 100644 --- a/thin-provisioning/thin_show_duplicates.cc +++ b/thin-provisioning/thin_show_duplicates.cc @@ -207,7 +207,7 @@ namespace { }; int show_dups_pool(flags const &fs) { - block_manager<>::ptr bm = open_bm(*fs.metadata_dev); + block_manager::ptr bm = open_bm(*fs.metadata_dev); transaction_manager::ptr tm = open_tm(bm, superblock_detail::SUPERBLOCK_LOCATION); superblock_detail::superblock sb = read_superblock(bm); diff --git a/thin-provisioning/thin_show_metadata.cc b/thin-provisioning/thin_show_metadata.cc index 5d181c0..bdbab3f 100644 --- a/thin-provisioning/thin_show_metadata.cc +++ b/thin-provisioning/thin_show_metadata.cc @@ -34,8 +34,8 @@ namespace { virtual ~examiner() {} - virtual bool recognise(block_manager<>::read_ref rr) const = 0; -// virtual void render_block(text_ui &ui, block_manager<>::read_ref rr) = 0; + virtual bool recognise(block_manager::read_ref rr) const = 0; +// virtual void render_block(text_ui &ui, block_manager::read_ref rr) = 0; string const &get_name() const { return name_; @@ -61,7 +61,7 @@ namespace { : examiner("raw", 5, '?') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { return true; } }; @@ -72,7 +72,7 @@ namespace { : examiner("superblock", 1, 'S') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { using namespace superblock_detail; superblock_disk const *sbd = reinterpret_cast(rr.data()); @@ -94,7 +94,7 @@ namespace { : examiner("bitmap", 2, ':') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { bitmap_header const *data = reinterpret_cast(rr.data()); crc32c sum(BITMAP_CSUM_XOR); sum.append(&data->not_used, MD_BLOCK_SIZE - sizeof(uint32_t)); @@ -108,7 +108,7 @@ namespace { : examiner("index", 3, 'i') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { metadata_index const *mi = reinterpret_cast(rr.data()); crc32c sum(INDEX_CSUM_XOR); sum.append(&mi->padding_, MD_BLOCK_SIZE - sizeof(uint32_t)); @@ -123,7 +123,7 @@ namespace { : examiner(name, colour_pair, c) { } - bool is_btree_node(block_manager<>::read_ref rr) const { + bool is_btree_node(block_manager::read_ref rr) const { using namespace btree_detail; disk_node const *data = reinterpret_cast(rr.data()); @@ -140,7 +140,7 @@ namespace { : btree_examiner("dev_details", 4, 'd') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { if (!btree_examiner::is_btree_node(rr)) return false; @@ -158,7 +158,7 @@ namespace { : btree_examiner("ref_count node", 6, 'r') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { if (!btree_examiner::is_btree_node(rr)) return false; @@ -176,7 +176,7 @@ namespace { : btree_examiner("mapping node", 7, 'm') { } - virtual bool recognise(block_manager<>::read_ref rr) const { + virtual bool recognise(block_manager::read_ref rr) const { if (!btree_examiner::is_btree_node(rr)) return false; @@ -191,7 +191,7 @@ namespace { class main_dialog { public: main_dialog(text_ui &ui, - block_manager<> const &bm) + block_manager const &bm) : ui_(ui), bm_(bm), raw_examiner_(new raw_examiner()) { @@ -207,7 +207,7 @@ namespace { void run() { auto line_length = 80; for (block_address b = 0; b < 2000; b++) { - block_manager<>::read_ref rr = bm_.read_lock(b); + block_manager::read_ref rr = bm_.read_lock(b); if (!(b % line_length)) { if (b > 0) @@ -237,7 +237,7 @@ namespace { printw("metadata nr blocks: %llu\n", sb.metadata_nr_blocks_); } - shared_ptr &find_examiner(block_manager<>::read_ref const &rr) { + shared_ptr &find_examiner(block_manager::read_ref const &rr) { for (shared_ptr &e : examiners_) { if (e->recognise(rr)) return e; @@ -247,7 +247,7 @@ namespace { } text_ui &ui_; - block_manager<> const &bm_; + block_manager const &bm_; list> examiners_; shared_ptr raw_examiner_; @@ -271,7 +271,7 @@ namespace { block_address nr_blocks = bm->get_nr_blocks(); for (block_address b = 0; b < nr_blocks; b++) { - block_manager<>::read_ref rr = bm->read_lock(b); + block_manager::read_ref rr = bm->read_lock(b); if (is_superblock(rr)) cout << b << ": superblock" << endl; @@ -338,7 +338,7 @@ thin_show_metadata_cmd::run(int argc, char **argv) try { ui::text_ui ui; - block_manager<>::ptr bm = open_bm(argv[optind], block_manager<>::READ_ONLY, true); + block_manager::ptr bm = open_bm(argv[optind], block_manager::READ_ONLY, true); main_dialog dialog(ui, *bm); dialog.run(); #if 0