summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-06-12 14:43:23 -0700
committerSamuel Just <sam.just@inktank.com>2013-06-17 14:50:53 -0700
commit9b6cb63931c28f1c7cf3548771774c4a21aebe24 (patch)
tree9fb1788d108bea5a02581dd2ec0b5f8bd54be6e6
parentabac4eab50bd854b3ee8d7f1971a21556f4fd13c (diff)
downloadceph-9b6cb63931c28f1c7cf3548771774c4a21aebe24.tar.gz
PGLog: add debug check on written keys, verify on write
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/osd/PGLog.cc22
-rw-r--r--src/osd/PGLog.h46
2 files changed, 55 insertions, 13 deletions
diff --git a/src/osd/PGLog.cc b/src/osd/PGLog.cc
index 8579e9828b4..011da4c0e67 100644
--- a/src/osd/PGLog.cc
+++ b/src/osd/PGLog.cc
@@ -114,6 +114,7 @@ void PGLog::clear() {
divergent_priors.clear();
missing.clear();
log.zero();
+ log_keys_debug.clear();
undirty();
}
@@ -540,7 +541,8 @@ void PGLog::write_log(
dirty_to,
dirty_from,
dirty_divergent_priors,
- !touched_log);
+ !touched_log,
+ &log_keys_debug);
undirty();
} else {
dout(10) << "log is not dirty" << dendl;
@@ -551,7 +553,7 @@ void PGLog::write_log(ObjectStore::Transaction& t, pg_log_t &log,
const hobject_t &log_oid, map<eversion_t, hobject_t> &divergent_priors)
{
_write_log(t, log, log_oid, divergent_priors, eversion_t::max(), eversion_t(),
- true, true);
+ true, true, 0);
}
void PGLog::_write_log(
@@ -560,7 +562,8 @@ void PGLog::_write_log(
eversion_t dirty_to,
eversion_t dirty_from,
bool dirty_divergent_priors,
- bool touch_log
+ bool touch_log,
+ set<string> *log_keys_debug
)
{
//dout(10) << "write_log, clearing up to " << dirty_to << dendl;
@@ -569,11 +572,13 @@ void PGLog::_write_log(
t.omap_rmkeyrange(
coll_t(), log_oid,
eversion_t().get_key_name(), dirty_to.get_key_name());
+ clear_up_to(log_keys_debug, dirty_to.get_key_name());
if (dirty_to != eversion_t::max()) {
// dout(10) << "write_log, clearing from " << dirty_from << dendl;
t.omap_rmkeyrange(
coll_t(), log_oid,
dirty_from.get_key_name(), eversion_t::max().get_key_name());
+ clear_after(log_keys_debug, dirty_from.get_key_name());
}
map<string,bufferlist> keys;
@@ -584,6 +589,11 @@ void PGLog::_write_log(
bufferlist bl(sizeof(*p) * 2);
p->encode_with_checksum(bl);
keys[p->get_key_name()].claim(bl);
+
+ if (log_keys_debug) {
+ assert(!log_keys_debug->count(p->get_key_name()));
+ log_keys_debug->insert(p->get_key_name());
+ }
}
}
//dout(10) << "write_log " << keys.size() << " keys" << dendl;
@@ -599,7 +609,9 @@ void PGLog::_write_log(
bool PGLog::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid,
const pg_info_t &info, map<eversion_t, hobject_t> &divergent_priors,
IndexedLog &log,
- pg_missing_t &missing, ostringstream &oss)
+ pg_missing_t &missing,
+ ostringstream &oss,
+ set<string> *log_keys_debug)
{
dout(10) << "read_log" << dendl;
bool rewrite_log = false;
@@ -631,6 +643,8 @@ bool PGLog::read_log(ObjectStore *store, coll_t coll, hobject_t log_oid,
}
log.log.push_back(e);
log.head = e.version;
+ if (log_keys_debug)
+ log_keys_debug->insert(e.get_key_name());
}
}
}
diff --git a/src/osd/PGLog.h b/src/osd/PGLog.h
index 8f48278041f..58a74ca76da 100644
--- a/src/osd/PGLog.h
+++ b/src/osd/PGLog.h
@@ -160,12 +160,6 @@ protected:
eversion_t dirty_from;
bool dirty_divergent_priors;
- void undirty() {
- dirty_to = eversion_t();
- dirty_from = eversion_t::max();
- dirty_divergent_priors = false;
- touched_log = true;
- }
bool dirty() const {
return !touched_log ||
(dirty_to != eversion_t()) ||
@@ -185,7 +179,38 @@ protected:
dirty_divergent_priors = true;
}
+ /// DEBUG
+ set<string> log_keys_debug;
+ static void clear_after(set<string> *log_keys_debug, const string &lb) {
+ if (!log_keys_debug)
+ return;
+ for (set<string>::iterator i = log_keys_debug->lower_bound(lb);
+ i != log_keys_debug->end();
+ log_keys_debug->erase(i++));
+ }
+ static void clear_up_to(set<string> *log_keys_debug, const string &ub) {
+ if (!log_keys_debug)
+ return;
+ for (set<string>::iterator i = log_keys_debug->begin();
+ i != log_keys_debug->end() && *i < ub;
+ log_keys_debug->erase(i++));
+ }
+ void check() {
+ assert(log.log.size() == log_keys_debug.size());
+ for (list<pg_log_entry_t>::iterator i = log.log.begin();
+ i != log.log.end();
+ ++i) {
+ assert(log_keys_debug.count(i->get_key_name()));
+ }
+ }
+ void undirty() {
+ dirty_to = eversion_t();
+ dirty_from = eversion_t::max();
+ dirty_divergent_priors = false;
+ touched_log = true;
+ check();
+ }
public:
PGLog() :
touched_log(false), dirty_from(eversion_t::max()),
@@ -334,20 +359,23 @@ public:
eversion_t dirty_to,
eversion_t dirty_from,
bool dirty_divergent_priors,
- bool touch_log
+ bool touch_log,
+ set<string> *log_keys_debug
);
bool read_log(ObjectStore *store, coll_t coll, hobject_t log_oid,
const pg_info_t &info, ostringstream &oss) {
return read_log(store, coll, log_oid, info, divergent_priors,
- log, missing, oss);
+ log, missing, oss, &log_keys_debug);
}
/// return true if the log should be rewritten
static bool read_log(ObjectStore *store, coll_t coll, hobject_t log_oid,
const pg_info_t &info, map<eversion_t, hobject_t> &divergent_priors,
IndexedLog &log,
- pg_missing_t &missing, ostringstream &oss);
+ pg_missing_t &missing, ostringstream &oss,
+ set<string> *log_keys_debug = 0
+ );
protected:
static void read_log_old(ObjectStore *store, coll_t coll, hobject_t log_oid,