diff options
author | John Spray <john.spray@inktank.com> | 2014-03-25 14:30:59 +0100 |
---|---|---|
committer | John Spray <john.spray@inktank.com> | 2014-05-18 12:21:29 +0200 |
commit | e56b88fe13d5993e2013a83d9674e6eaef624708 (patch) | |
tree | 62ca63b19bfbdef4a952eb17365227a1e7e8c91f /src | |
parent | mds: Add get_paths method to EMetaBlob (diff) | |
download | ceph-e56b88fe13d5993e2013a83d9674e6eaef624708.tar.xz ceph-e56b88fe13d5993e2013a83d9674e6eaef624708.zip |
mds: Add ENoOp for padding journals
This allows us to implement journal splicing
without moving blocks around, and without modifying
the outer journal syntax.
Signed-off-by: John Spray <john.spray@inktank.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mds/LogEvent.cc | 37 | ||||
-rw-r--r-- | src/mds/LogEvent.h | 1 | ||||
-rw-r--r-- | src/mds/Makefile.am | 1 | ||||
-rw-r--r-- | src/mds/events/ENoOp.h | 34 | ||||
-rw-r--r-- | src/mds/journal.cc | 28 |
5 files changed, 100 insertions, 1 deletions
diff --git a/src/mds/LogEvent.cc b/src/mds/LogEvent.cc index 93e290a2220..c6c9ce725d1 100644 --- a/src/mds/LogEvent.cc +++ b/src/mds/LogEvent.cc @@ -36,6 +36,8 @@ #include "events/ETableClient.h" #include "events/ETableServer.h" +#include "events/ENoOp.h" + LogEvent *LogEvent::decode(bufferlist& bl) { @@ -82,6 +84,7 @@ std::string LogEvent::get_type_str() const case EVENT_COMMITTED: return "COMMITTED"; case EVENT_TABLECLIENT: return "TABLECLIENT"; case EVENT_TABLESERVER: return "TABLESERVER"; + case EVENT_NOOP: return "NOOP"; default: generic_dout(0) << "get_type_str: unknown type " << _type << dendl; @@ -90,7 +93,37 @@ std::string LogEvent::get_type_str() const } -LogEvent *LogEvent::decode_event(bufferlist& bl, bufferlist::iterator& p, __u32 type) +/* + * Resolve type string to type enum + * + * Return -1 if not found + */ +LogEvent::EventType LogEvent::str_to_type(std::string const &str) +{ + std::map<std::string, EventType> types; + types["SUBTREEMAP"] = EVENT_SUBTREEMAP; + types["SUBTREEMAP_TEST"] = EVENT_SUBTREEMAP_TEST; + types["EXPORT"] = EVENT_EXPORT; + types["IMPORTSTART"] = EVENT_IMPORTSTART; + types["IMPORTFINISH"] = EVENT_IMPORTFINISH; + types["FRAGMENT"] = EVENT_FRAGMENT; + types["RESETJOURNAL"] = EVENT_RESETJOURNAL; + types["SESSION"] = EVENT_SESSION; + types["SESSIONS_OLD"] = EVENT_SESSIONS_OLD; + types["SESSIONS"] = EVENT_SESSIONS; + types["UPDATE"] = EVENT_UPDATE; + types["SLAVEUPDATE"] = EVENT_SLAVEUPDATE; + types["OPEN"] = EVENT_OPEN; + types["COMMITTED"] = EVENT_COMMITTED; + types["TABLECLIENT"] = EVENT_TABLECLIENT; + types["TABLESERVER"] = EVENT_TABLESERVER; + types["NOOP"] = EVENT_NOOP; + + return types[str]; +} + + +LogEvent *LogEvent::decode_event(bufferlist& bl, bufferlist::iterator& p, LogEvent::EventType type) { int length = bl.length() - p.get_off(); generic_dout(15) << "decode_log_event type " << type << ", size " << length << dendl; @@ -122,6 +155,8 @@ LogEvent *LogEvent::decode_event(bufferlist& bl, bufferlist::iterator& p, __u32 case EVENT_TABLECLIENT: le = new ETableClient; break; case EVENT_TABLESERVER: le = new ETableServer; break; + case EVENT_NOOP: le = new ENoOp; break; + default: generic_dout(0) << "uh oh, unknown log event type " << type << " length " << length << dendl; return NULL; diff --git a/src/mds/LogEvent.h b/src/mds/LogEvent.h index 0c390efd18b..97a4233da6d 100644 --- a/src/mds/LogEvent.h +++ b/src/mds/LogEvent.h @@ -39,6 +39,7 @@ #define EVENT_TABLESERVER 43 #define EVENT_SUBTREEMAP_TEST 50 +#define EVENT_NOOP 51 #include "include/buffer.h" diff --git a/src/mds/Makefile.am b/src/mds/Makefile.am index 39f6c4a93c8..be30eb2c4b8 100644 --- a/src/mds/Makefile.am +++ b/src/mds/Makefile.am @@ -76,6 +76,7 @@ noinst_HEADERS += \ mds/events/EImportFinish.h \ mds/events/EImportStart.h \ mds/events/EMetaBlob.h \ + mds/events/ENoOp.h \ mds/events/EOpen.h \ mds/events/EResetJournal.h \ mds/events/ESession.h \ diff --git a/src/mds/events/ENoOp.h b/src/mds/events/ENoOp.h new file mode 100644 index 00000000000..dfba5c41462 --- /dev/null +++ b/src/mds/events/ENoOp.h @@ -0,0 +1,34 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net> + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_MDS_ENOOP_H +#define CEPH_MDS_ENOOP_H + +#include "../LogEvent.h" + +class ENoOp : public LogEvent { + uint32_t size; + +public: + ENoOp() : LogEvent(EVENT_NOOP), size(0) { } + ENoOp(uint32_t size_) : LogEvent(EVENT_NOOP), size(size){ } + + void encode(bufferlist& bl) const; + void decode(bufferlist::iterator& bl); + void dump(Formatter *f) const {} + + void replay(MDS *mds); +}; + +#endif diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 54115090445..5a160d73d15 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -20,6 +20,7 @@ #include "events/EMetaBlob.h" #include "events/EResetJournal.h" +#include "events/ENoOp.h" #include "events/EUpdate.h" #include "events/ESlaveUpdate.h" @@ -2921,3 +2922,30 @@ void EResetJournal::replay(MDS *mds) mds->mdcache->show_subtrees(); } + +void ENoOp::encode(bufferlist &bl) const +{ + ::encode(size, bl); + uint32_t const pad_bytes = size - sizeof(size); + uint32_t const pad = 0xdeadbeef; + for (unsigned int i = 0; i < pad_bytes / sizeof(uint32_t); ++i) { + ::encode(pad, bl); + } +} + + +void ENoOp::decode(bufferlist::iterator &bl) +{ + ::decode(size, bl); + if (bl.get_remaining() != (size - sizeof(size))) { + // This is spiritually an assertion, but expressing in a way that will let + // journal debug tools catch it and recognise a malformed entry. + throw buffer::end_of_buffer(); + } +} + + +void ENoOp::replay(MDS *mds) +{ + dout(4) << "ENoOp::replay, " << size << " bytes skipped in journal" << dendl; +} |