public:
dirlump() : state(0), nfull(0), nremote(0), nnull(0), dn_decoded(true) { }
- bool is_complete() { return state & STATE_COMPLETE; }
+ bool is_complete() const { return state & STATE_COMPLETE; }
void mark_complete() { state |= STATE_COMPLETE; }
- bool is_dirty() { return state & STATE_DIRTY; }
+ bool is_dirty() const { return state & STATE_DIRTY; }
void mark_dirty() { state |= STATE_DIRTY; }
- bool is_new() { return state & STATE_NEW; }
+ bool is_new() const { return state & STATE_NEW; }
void mark_new() { state |= STATE_NEW; }
bool is_importing() { return state & STATE_IMPORTING; }
void mark_importing() { state |= STATE_IMPORTING; }
p->print(out);
}
+ string state_string() const {
+ string state_string;
+ bool marked_already = false;
+ if (is_complete()) {
+ state_string.append("complete");
+ marked_already = true;
+ }
+ if (is_dirty()) {
+ state_string.append(marked_already ? "+dirty" : "dirty");
+ marked_already = true;
+ }
+ if (is_new()) {
+ state_string.append(marked_already ? "+new" : "new");
+ }
+ return state_string;
+ }
+
// if this changes, update the versioning in encode for it!
void _encode_bits() const {
+ if (!dn_decoded) return;
::encode(dfull, dnbl);
::encode(dremote, dnbl);
::encode(dnull, dnbl);
dn_decoded = true;
}
- void encode(bufferlist& bl) const {
- ENCODE_START(2, 2, bl);
- ::encode(fnode, bl);
- ::encode(state, bl);
- ::encode(nfull, bl);
- ::encode(nremote, bl);
- ::encode(nnull, bl);
- _encode_bits();
- ::encode(dnbl, bl);
- ENCODE_FINISH(bl);
- }
- void decode(bufferlist::iterator &bl) {
- DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl)
- ::decode(fnode, bl);
- ::decode(state, bl);
- ::decode(nfull, bl);
- ::decode(nremote, bl);
- ::decode(nnull, bl);
- ::decode(dnbl, bl);
- dn_decoded = false; // don't decode bits unless we need them.
- DECODE_FINISH(bl);
- }
+ void encode(bufferlist& bl) const;
+ void decode(bufferlist::iterator &bl);
+ void dump(Formatter *f) const;
+ static void generate_test_instances(list<dirlump*>& ls);
};
WRITE_CLASS_ENCODER(dirlump)
ls.push_back(sample2);
}
+// EMetaBlob::dirlump
+
+void EMetaBlob::dirlump::encode(bufferlist& bl) const
+{
+ ENCODE_START(2, 2, bl);
+ ::encode(fnode, bl);
+ ::encode(state, bl);
+ ::encode(nfull, bl);
+ ::encode(nremote, bl);
+ ::encode(nnull, bl);
+ _encode_bits();
+ ::encode(dnbl, bl);
+ ENCODE_FINISH(bl);
+}
+
+void EMetaBlob::dirlump::decode(bufferlist::iterator &bl)
+{
+ DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl)
+ ::decode(fnode, bl);
+ ::decode(state, bl);
+ ::decode(nfull, bl);
+ ::decode(nremote, bl);
+ ::decode(nnull, bl);
+ ::decode(dnbl, bl);
+ dn_decoded = false; // don't decode bits unless we need them.
+ DECODE_FINISH(bl);
+}
+
+void EMetaBlob::dirlump::dump(Formatter *f) const
+{
+ if (!dn_decoded) {
+ dirlump *me = const_cast<dirlump*>(this);
+ me->_decode_bits();
+ }
+ f->open_object_section("fnode");
+ fnode.dump(f);
+ f->close_section(); // fnode
+ f->dump_string("state", state_string());
+ f->dump_int("nfull", nfull);
+ f->dump_int("nremote", nremote);
+ f->dump_int("nnull", nnull);
+
+ f->open_array_section("full bits");
+ for (list<std::tr1::shared_ptr<fullbit> >::const_iterator
+ iter = dfull.begin(); iter != dfull.end(); ++iter) {
+ f->open_object_section("fullbit");
+ (*iter)->dump(f);
+ f->close_section(); // fullbit
+ }
+ f->close_section(); // full bits
+ f->open_array_section("remote bits");
+ for (list<remotebit>::const_iterator
+ iter = dremote.begin(); iter != dremote.end(); ++iter) {
+ f->open_object_section("remotebit");
+ (*iter).dump(f);
+ f->close_section(); // remotebit
+ }
+ f->close_section(); // remote bits
+ f->open_array_section("null bits");
+ for (list<nullbit>::const_iterator
+ iter = dnull.begin(); iter != dnull.end(); ++iter) {
+ f->open_object_section("null bit");
+ (*iter).dump(f);
+ f->close_section(); // null bit
+ }
+ f->close_section(); // null bits
+}
+
+void EMetaBlob::dirlump::generate_test_instances(list<dirlump*>& ls)
+{
+ ls.push_back(new dirlump());
+}
+
/**
- *
+ * EMetaBlob proper
*/
void EMetaBlob::replay(MDS *mds, LogSegment *logseg, MDSlaveUpdate *slaveup)