[dev-tools] Update dev tools to use non-template version of block_manager.

This commit is contained in:
Joe Thornber 2020-05-01 14:11:33 +01:00
parent 0882022120
commit b7d20bce48
9 changed files with 51 additions and 51 deletions

View File

@ -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);

View File

@ -26,7 +26,7 @@ using namespace std;
//----------------------------------------------------------------
byte_stream::byte_stream(block_manager<JOURNAL_BLOCK_SIZE>::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<JOURNAL_BLOCK_SIZE>::ptr bm)
journal::journal(block_manager::ptr bm)
: in_(bm)
{
}

View File

@ -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<JOURNAL_BLOCK_SIZE>::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<JOURNAL_BLOCK_SIZE>::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<JOURNAL_BLOCK_SIZE>::ptr bm);
journal(persistent_data::block_manager::ptr bm);
void read_journal(struct journal_visitor &v);
private:

View File

@ -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<JOURNAL_BLOCK_SIZE>::ptr bm(
new block_manager<JOURNAL_BLOCK_SIZE>(path, journal_size, 4,
block_manager<JOURNAL_BLOCK_SIZE>::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);

View File

@ -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<uint64_traits> n = btree_detail::to_node<uint64_traits>(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<uint64_traits> n = btree_detail::to_node<uint64_traits>(rr);
node_info ni;
convert_to_node_info(n, ni);
@ -159,7 +159,7 @@ namespace {
out_ << "</device>" << 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<uint64_traits> n = btree_detail::to_node<uint64_traits>(rr);
nodes.push_back(node_info());
convert_to_node_info(n, nodes.back());

View File

@ -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();

View File

@ -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<uint64_traits> n = btree_detail::to_node<uint64_traits>(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<vector<string> >
scan_strings(block_manager<>::read_ref rr)
scan_strings(block_manager::read_ref rr)
{
vector<string> r;
const char *data = reinterpret_cast<const char *>(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<int64_t>(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();

View File

@ -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);

View File

@ -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<superblock_disk const *>(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<bitmap_header const *>(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<metadata_index const *>(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<disk_node const *>(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<examiner> &find_examiner(block_manager<>::read_ref const &rr) {
shared_ptr<examiner> &find_examiner(block_manager::read_ref const &rr) {
for (shared_ptr<examiner> &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<shared_ptr<examiner>> examiners_;
shared_ptr<examiner> 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