From c7ea8cb583730f824bf7d75b8967bcddb336cb1b Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 28 Aug 2007 21:19:57 +0000 Subject: [PATCH] verify tables on mount git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1718 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/ebofs/Ebofs.cc | 18 ++++++++++++++++++ trunk/ceph/ebofs/Ebofs.h | 1 + trunk/ceph/ebofs/Table.h | 13 +++++++++---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/trunk/ceph/ebofs/Ebofs.cc b/trunk/ceph/ebofs/Ebofs.cc index 326d5871bfad7..232cddf29de22 100644 --- a/trunk/ceph/ebofs/Ebofs.cc +++ b/trunk/ceph/ebofs/Ebofs.cc @@ -115,6 +115,8 @@ int Ebofs::mount() collection_tab = new Table( nodepool, sb->collection_tab ); co_tab = new Table( nodepool, sb->co_tab ); + verify_tables(); + allocator.release_limbo(); @@ -292,6 +294,22 @@ void Ebofs::close_tables() nodepool.close(); } +void Ebofs::verify_tables() +{ + bool o = g_conf.ebofs_verify; + g_conf.ebofs_verify = true; + + object_tab->verify("onmount"); + limbo_tab->verify("onmount"); + alloc_tab->verify("onmount"); + collection_tab->verify("onmount"); + co_tab->verify("onmount"); + for (int i=0; iverify("onmount"); + + g_conf.ebofs_verify = o; +} + int Ebofs::umount() { ebofs_lock.Lock(); diff --git a/trunk/ceph/ebofs/Ebofs.h b/trunk/ceph/ebofs/Ebofs.h index 4d95a71f77e4e..efa53e58878ba 100644 --- a/trunk/ceph/ebofs/Ebofs.h +++ b/trunk/ceph/ebofs/Ebofs.h @@ -116,6 +116,7 @@ protected: Table *co_tab; void close_tables(); + void verify_tables(); // ** onodes ** diff --git a/trunk/ceph/ebofs/Table.h b/trunk/ceph/ebofs/Table.h index 7c5f29ab59604..041a55afa0c68 100644 --- a/trunk/ceph/ebofs/Table.h +++ b/trunk/ceph/ebofs/Table.h @@ -139,6 +139,7 @@ class Table { leaf_item(i) = leaf_item(i+1); } set_size(size() - 1); + dbtout << "remove_at_pos done, size now " << size() << " " << (node->is_index() ? "index":"leaf") << std::endl; } void insert_at_leaf_pos(int p, K key, V value) { assert(is_leaf()); @@ -305,7 +306,7 @@ class Table { repair_parents(); // was it a key? - if (level == table->depth-1) + if (level == table->depth-1) table->nkeys--; } @@ -420,6 +421,7 @@ class Table { int find(K key, Cursor& cursor) { dbtout << "find " << key << std::endl; + verify("find"); if (depth == 0) return Cursor::OOB; @@ -530,6 +532,7 @@ class Table { } int insert(K key, V value) { + verify("pre-insert"); dbtout << "insert " << key << " -> " << value << std::endl; if (almost_full()) return -1; @@ -653,6 +656,7 @@ class Table { int remove(K key) { + verify("pre-remove"); dbtout << "remove " << key << std::endl; if (almost_full()) { @@ -674,7 +678,8 @@ class Table { while (1) { cursor.remove(); - + verify("post-remove"); + // balance + adjust if (cursor.level == 0) { @@ -849,7 +854,7 @@ class Table { } } - //return err; + if (err == 0) return err; // print it char s[1000]; @@ -867,7 +872,7 @@ class Table { << node.size() << " / " << node.max_items() << " keys, " << hex << min << "-" << max << dec << std::endl; } - if (0) { + if (1) { for (int i=0; i