]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: switched entry tags to use id instead of string
authorJason Dillaman <dillaman@redhat.com>
Mon, 1 Feb 2016 23:16:38 +0000 (18:16 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 5 Feb 2016 18:03:57 +0000 (13:03 -0500)
Later commits will add the ability to allocate tags and
associate them with registered clients.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
28 files changed:
src/cls/journal/cls_journal_types.cc
src/cls/journal/cls_journal_types.h
src/journal/Entry.cc
src/journal/Entry.h
src/journal/FutureImpl.cc
src/journal/FutureImpl.h
src/journal/JournalMetadata.cc
src/journal/JournalMetadata.h
src/journal/JournalPlayer.cc
src/journal/JournalPlayer.h
src/journal/JournalRecorder.cc
src/journal/JournalRecorder.h
src/journal/Journaler.cc
src/journal/Journaler.h
src/journal/ObjectPlayer.cc
src/journal/ObjectPlayer.h
src/librbd/Journal.cc
src/test/cls_journal/test_cls_journal.cc
src/test/journal/test_Entry.cc
src/test/journal/test_FutureImpl.cc
src/test/journal/test_JournalMetadata.cc
src/test/journal/test_JournalPlayer.cc
src/test/journal/test_JournalRecorder.cc
src/test/journal/test_JournalTrimmer.cc
src/test/journal/test_ObjectPlayer.cc
src/test/journal/test_ObjectRecorder.cc
src/test/librbd/test_mock_Journal.cc
src/tools/rbd/action/Journal.cc

index 3084d108521a12930d229d354298e406a38d8e87..f66a5a480334a3336ede307438f4cd309be4fb74 100644 (file)
@@ -3,56 +3,32 @@
 
 #include "cls/journal/cls_journal_types.h"
 #include "common/Formatter.h"
-#include <set>
 
 namespace cls {
 namespace journal {
 
 void EntryPosition::encode(bufferlist& bl) const {
   ENCODE_START(1, 1, bl);
-  ::encode(tag, bl);
-  ::encode(tid, bl);
+  ::encode(tag_tid, bl);
+  ::encode(entry_tid, bl);
   ENCODE_FINISH(bl);
 }
 
 void EntryPosition::decode(bufferlist::iterator& iter) {
   DECODE_START(1, iter);
-  ::decode(tag, iter);
-  ::decode(tid, iter);
+  ::decode(tag_tid, iter);
+  ::decode(entry_tid, iter);
   DECODE_FINISH(iter);
 }
 
 void EntryPosition::dump(Formatter *f) const {
-  f->dump_string("tag", tag);
-  f->dump_unsigned("tid", tid);
+  f->dump_unsigned("tag_tid", tag_tid);
+  f->dump_unsigned("entry_tid", entry_tid);
 }
 
 void EntryPosition::generate_test_instances(std::list<EntryPosition *> &o) {
   o.push_back(new EntryPosition());
-  o.push_back(new EntryPosition("id", 2));
-}
-
-bool ObjectSetPosition::operator<(const ObjectSetPosition& rhs) const {
-  if (entry_positions.size() < rhs.entry_positions.size()) {
-    return true;
-  } else if (entry_positions.size() > rhs.entry_positions.size()) {
-    return false;
-  }
-
-  std::map<std::string, uint64_t> rhs_tids;
-  for (EntryPositions::const_iterator it = rhs.entry_positions.begin();
-       it != rhs.entry_positions.end(); ++it) {
-    rhs_tids[it->tag] = it->tid;
-  }
-
-  for (EntryPositions::const_iterator it = entry_positions.begin();
-       it != entry_positions.end(); ++it) {
-    const EntryPosition &entry_position = *it;
-    if (entry_position.tid < rhs_tids[entry_position.tag]) {
-      return true;
-    }
-  }
-  return false;
+  o.push_back(new EntryPosition(1, 2));
 }
 
 void ObjectSetPosition::encode(bufferlist& bl) const {
@@ -86,8 +62,8 @@ void ObjectSetPosition::generate_test_instances(
   o.push_back(new ObjectSetPosition());
 
   EntryPositions entry_positions;
-  entry_positions.push_back(EntryPosition("tag1", 120));
-  entry_positions.push_back(EntryPosition("tag2", 121));
+  entry_positions.push_back(EntryPosition(1, 120));
+  entry_positions.push_back(EntryPosition(2, 121));
   o.push_back(new ObjectSetPosition(1, entry_positions));
 }
 
@@ -120,15 +96,15 @@ void Client::generate_test_instances(std::list<Client *> &o) {
   o.push_back(new Client("id", "desc"));
 
   EntryPositions entry_positions;
-  entry_positions.push_back(EntryPosition("tag1", 120));
-  entry_positions.push_back(EntryPosition("tag1", 121));
+  entry_positions.push_back(EntryPosition(1, 120));
+  entry_positions.push_back(EntryPosition(2, 121));
   o.push_back(new Client("id", "desc", ObjectSetPosition(1, entry_positions)));
 }
 
 std::ostream &operator<<(std::ostream &os,
                          const EntryPosition &entry_position) {
-  os << "[tag=" << entry_position.tag << ", tid="
-     << entry_position.tid << "]";
+  os << "[tag_tid=" << entry_position.tag_tid << ", entry_tid="
+     << entry_position.entry_tid << "]";
   return os;
 }
 
index 934873977ecd3fff71b054d5deac66421ba2f456..da23680914cee991252fccdffbe96b60e2c863d9 100644 (file)
@@ -19,21 +19,28 @@ namespace cls {
 namespace journal {
 
 struct EntryPosition {
-  std::string tag;
-  uint64_t tid;
+  uint64_t tag_tid;
+  uint64_t entry_tid;
 
-  EntryPosition() : tid(0) {}
-  EntryPosition(const std::string& _tag, uint64_t _tid)
-    : tag(_tag), tid(_tid) {}
+  EntryPosition() : tag_tid(0), entry_tid(0) {}
+  EntryPosition(uint64_t _tag_tid, uint64_t _entry_tid)
+    : tag_tid(_tag_tid), entry_tid(_entry_tid) {}
 
   inline bool operator==(const EntryPosition& rhs) const {
-    return (tag == rhs.tag && tid == rhs.tid);
+    return (tag_tid == rhs.tag_tid && entry_tid == rhs.entry_tid);
   }
 
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& iter);
   void dump(Formatter *f) const;
 
+  inline bool operator<(const EntryPosition &rhs) const {
+    if (tag_tid != rhs.tag_tid) {
+      return tag_tid < rhs.tag_tid;
+    }
+    return entry_tid < rhs.entry_tid;
+  }
+
   static void generate_test_instances(std::list<EntryPosition *> &o);
 };
 
@@ -48,18 +55,15 @@ struct ObjectSetPosition {
                     const EntryPositions &_entry_positions)
     : object_number(_object_number), entry_positions(_entry_positions) {}
 
-  bool operator<(const ObjectSetPosition& rhs) const;
-  inline bool operator<=(const ObjectSetPosition& rhs) const {
-    return (*this == rhs || *this < rhs);
-  }
-  inline bool operator==(const ObjectSetPosition &rhs) const {
-    return (entry_positions == rhs.entry_positions);
-  }
-
   void encode(bufferlist& bl) const;
   void decode(bufferlist::iterator& iter);
   void dump(Formatter *f) const;
 
+  inline bool operator==(const ObjectSetPosition &rhs) const {
+    return (object_number == rhs.object_number &&
+            entry_positions == rhs.entry_positions);
+  }
+
   static void generate_test_instances(std::list<ObjectSetPosition *> &o);
 };
 
index bd26ebe1ee749caf7f760176ea7de8268785c62f..af6c6997b15bec4dee2b96af8919a301c5de4bc3 100644 (file)
@@ -15,7 +15,7 @@ namespace journal {
 
 namespace {
 
-const uint32_t HEADER_FIXED_SIZE = 17; /// preamble, version, tid
+const uint32_t HEADER_FIXED_SIZE = 25; /// preamble, version, entry tid, tag id
 
 } // anonymous namespace
 
@@ -23,10 +23,10 @@ void Entry::encode(bufferlist &bl) const {
   bufferlist data_bl;
   ::encode(preamble, data_bl);
   ::encode(static_cast<uint8_t>(1), data_bl);
-  ::encode(m_tid, data_bl);
+  ::encode(m_entry_tid, data_bl);
+  ::encode(m_tag_tid, data_bl);
   assert(HEADER_FIXED_SIZE == data_bl.length());
 
-  ::encode(m_tag, data_bl);
   ::encode(m_data, data_bl);
 
   uint32_t crc = data_bl.crc32c(0);
@@ -49,8 +49,8 @@ void Entry::decode(bufferlist::iterator &iter) {
     throw buffer::malformed_input("unknown version: " + stringify(version));
   }
 
-  ::decode(m_tid, iter);
-  ::decode(m_tag, iter);
+  ::decode(m_entry_tid, iter);
+  ::decode(m_tag_tid, iter);
   ::decode(m_data, iter);
   uint32_t end_offset = iter.get_off();
 
@@ -67,8 +67,8 @@ void Entry::decode(bufferlist::iterator &iter) {
 }
 
 void Entry::dump(Formatter *f) const {
-  f->dump_string("tag", m_tag);
-  f->dump_unsigned("tid", m_tid);
+  f->dump_unsigned("tag_tid", m_tag_tid);
+  f->dump_unsigned("entry_tid", m_entry_tid);
 
   std::stringstream data;
   m_data.hexdump(data);
@@ -89,19 +89,6 @@ bool Entry::is_readable(bufferlist::iterator iter, uint32_t *bytes_needed) {
   }
   iter.advance(HEADER_FIXED_SIZE - sizeof(bl_preamble));
 
-  if (iter.get_remaining() < sizeof(uint32_t)) {
-    *bytes_needed = sizeof(uint32_t) - iter.get_remaining();
-    return false;
-  }
-  uint32_t tag_size;
-  ::decode(tag_size, iter);
-
-  if (iter.get_remaining() < tag_size) {
-    *bytes_needed = tag_size - iter.get_remaining();
-    return false;
-  }
-  iter.advance(tag_size);
-
   if (iter.get_remaining() < sizeof(uint32_t)) {
     *bytes_needed = sizeof(uint32_t) - iter.get_remaining();
     return false;
@@ -134,21 +121,22 @@ bool Entry::is_readable(bufferlist::iterator iter, uint32_t *bytes_needed) {
 }
 
 void Entry::generate_test_instances(std::list<Entry *> &o) {
-  o.push_back(new Entry("tag1", 123, bufferlist()));
+  o.push_back(new Entry(1, 123, bufferlist()));
 
   bufferlist bl;
   bl.append("data");
-  o.push_back(new Entry("tag2", 123, bl));
+  o.push_back(new Entry(2, 123, bl));
 }
 
 bool Entry::operator==(const Entry& rhs) const {
-  return (m_tag == rhs.m_tag && m_tid == rhs.m_tid &&
+  return (m_tag_tid == rhs.m_tag_tid && m_entry_tid == rhs.m_entry_tid &&
           const_cast<bufferlist&>(m_data).contents_equal(
             const_cast<bufferlist&>(rhs.m_data)));
 }
 
 std::ostream &operator<<(std::ostream &os, const Entry &entry) {
-  os << "Entry[tag=" << entry.get_tag() << ", tid=" << entry.get_tid() << ", "
+  os << "Entry[tag_tid=" << entry.get_tag_tid() << ", "
+     << "entry_tid=" << entry.get_entry_tid() << ", "
      << "data size=" << entry.get_data().length() << "]";
   return os;
 }
index 9e85df4c7dd17c433d88db5cd9912c2704eb77e4..3d0a0d0e50e81be93b27a39a3c76a3333c01ce8a 100644 (file)
@@ -18,17 +18,17 @@ namespace journal {
 
 class Entry {
 public:
-  Entry() : m_tid() {}
-  Entry(const std::string &tag, uint64_t tid, const bufferlist &data)
-    : m_tag(tag), m_tid(tid), m_data(data)
+  Entry() : m_tag_tid(0), m_entry_tid() {}
+  Entry(uint64_t tag_tid, uint64_t entry_tid, const bufferlist &data)
+    : m_tag_tid(tag_tid), m_entry_tid(entry_tid), m_data(data)
   {
   }
 
-  inline const std::string &get_tag() const {
-    return m_tag;
+  inline uint64_t get_tag_tid() const {
+    return m_tag_tid;
   }
-  inline uint64_t get_tid() const {
-    return m_tid;
+  inline uint64_t get_entry_tid() const {
+    return m_entry_tid;
   }
   inline const bufferlist &get_data() const {
     return m_data;
@@ -46,8 +46,8 @@ public:
 private:
   static const uint64_t preamble = 0x3141592653589793;
 
-  std::string m_tag;
-  uint64_t m_tid;
+  uint64_t m_tag_tid;
+  uint64_t m_entry_tid;
   bufferlist m_data;
 };
 
index 0ccb46fa90feef8b8070746f656cee758e589061..c3344ba7d1e9c10309b44e1bc14287cfbf42018b 100644 (file)
@@ -7,10 +7,10 @@
 
 namespace journal {
 
-FutureImpl::FutureImpl(Finisher &finisher, const std::string &tag, uint64_t tid,
+FutureImpl::FutureImpl(Finisher &finisher, uint64_t tag_tid, uint64_t entry_tid,
                        uint64_t commit_tid)
-  : RefCountedObject(NULL, 0), m_finisher(finisher), m_tag(tag), m_tid(tid),
-    m_commit_tid(commit_tid),
+  : RefCountedObject(NULL, 0), m_finisher(finisher), m_tag_tid(tag_tid),
+    m_entry_tid(entry_tid), m_commit_tid(commit_tid),
     m_lock(utils::unique_lock_name("FutureImpl::m_lock", this)), m_safe(false),
     m_consistent(false), m_return_value(0), m_flush_state(FLUSH_STATE_NONE),
     m_consistent_ack(this) {
@@ -137,7 +137,9 @@ void FutureImpl::finish_unlock() {
 }
 
 std::ostream &operator<<(std::ostream &os, const FutureImpl &future) {
-  os << "Future[tag=" << future.m_tag << ", tid=" << future.m_tid << "]";
+  os << "Future[tag_tid=" << future.m_tag_tid << ", "
+     << "entry_tid=" << future.m_entry_tid << ", "
+     << "commit_tid=" << future.m_commit_tid << "]";
   return os;
 }
 
index 855c95889389da9a11288c6443211c0bd7088412..e77f04993471925d5fa2d598f20edcbb855d4427 100644 (file)
@@ -31,16 +31,16 @@ public:
   };
   typedef boost::intrusive_ptr<FlushHandler> FlushHandlerPtr;
 
-  FutureImpl(Finisher &finisher, const std::string &tag, uint64_t tid,
+  FutureImpl(Finisher &finisher, uint64_t tag_tid, uint64_t entry_tid,
              uint64_t commit_tid);
 
   void init(const FutureImplPtr &prev_future);
 
-  inline const std::string &get_tag() const {
-    return m_tag;
+  inline uint64_t get_tag_tid() const {
+    return m_tag_tid;
   }
-  inline uint64_t get_tid() const {
-    return m_tid;
+  inline uint64_t get_entry_tid() const {
+    return m_entry_tid;
   }
   inline uint64_t get_commit_tid() const {
     return m_commit_tid;
@@ -96,8 +96,8 @@ private:
   };
 
   Finisher &m_finisher;
-  std::string m_tag;
-  uint64_t m_tid;
+  uint64_t m_tag_tid;
+  uint64_t m_entry_tid;
   uint64_t m_commit_tid;
 
   mutable Mutex m_lock;
index c8eececcb6c2177f226c307f4b2fc93b3203851f..33221f94ffd4ddcc66ab5a31678631efa309022d 100644 (file)
@@ -7,6 +7,7 @@
 #include "common/Finisher.h"
 #include "common/Timer.h"
 #include "cls/journal/cls_journal_client.h"
+#include <functional>
 #include <set>
 
 #define dout_subsys ceph_subsys_journaler
@@ -17,6 +18,39 @@ namespace journal {
 
 using namespace cls::journal;
 
+namespace {
+
+// does not compare object number
+inline bool entry_positions_less_equal(const ObjectSetPosition &lhs,
+                                       const ObjectSetPosition &rhs) {
+  if (lhs.entry_positions == rhs.entry_positions) {
+    return true;
+  }
+
+  if (lhs.entry_positions.size() < rhs.entry_positions.size()) {
+    return true;
+  } else if (rhs.entry_positions.size() > rhs.entry_positions.size()) {
+    return false;
+  }
+
+  std::map<uint64_t, uint64_t> rhs_tids;
+  for (EntryPositions::const_iterator it = rhs.entry_positions.begin();
+       it != rhs.entry_positions.end(); ++it) {
+    rhs_tids[it->tag_tid] = it->entry_tid;
+  }
+
+  for (EntryPositions::const_iterator it = lhs.entry_positions.begin();
+       it != lhs.entry_positions.end(); ++it) {
+    const EntryPosition &entry_position = *it;
+    if (entry_position.entry_tid < rhs_tids[entry_position.tag_tid]) {
+      return true;
+    }
+  }
+  return false;
+}
+
+} // anonymous namespace
+
 JournalMetadata::JournalMetadata(librados::IoCtx &ioctx,
                                  const std::string &oid,
                                  const std::string &client_id,
@@ -216,8 +250,8 @@ void JournalMetadata::set_commit_position(
     Mutex::Locker locker(m_lock);
     ldout(m_cct, 20) << __func__ << ": current=" << m_client.commit_position
                      << ", new=" << commit_position << dendl;
-    if (commit_position <= m_client.commit_position ||
-        commit_position <= m_commit_position) {
+    if (entry_positions_less_equal(commit_position, m_client.commit_position) ||
+        entry_positions_less_equal(commit_position, m_commit_position)) {
       stale_ctx = on_safe;
     } else {
       stale_ctx = m_commit_position_ctx;
@@ -234,25 +268,25 @@ void JournalMetadata::set_commit_position(
   }
 }
 
-void JournalMetadata::reserve_tid(const std::string &tag, uint64_t tid) {
+void JournalMetadata::reserve_entry_tid(uint64_t tag_tid, uint64_t entry_tid) {
   Mutex::Locker locker(m_lock);
-  uint64_t &allocated_tid = m_allocated_tids[tag];
-  if (allocated_tid <= tid) {
-    allocated_tid = tid + 1;
+  uint64_t &allocated_entry_tid = m_allocated_entry_tids[tag_tid];
+  if (allocated_entry_tid <= entry_tid) {
+    allocated_entry_tid = entry_tid + 1;
   }
 }
 
-bool JournalMetadata::get_last_allocated_tid(const std::string &tag,
-                                             uint64_t *tid) const {
+bool JournalMetadata::get_last_allocated_entry_tid(uint64_t tag_tid,
+                                                   uint64_t *entry_tid) const {
   Mutex::Locker locker(m_lock);
 
-  AllocatedTids::const_iterator it = m_allocated_tids.find(tag);
-  if (it == m_allocated_tids.end()) {
+  AllocatedEntryTids::const_iterator it = m_allocated_entry_tids.find(tag_tid);
+  if (it == m_allocated_entry_tids.end()) {
     return false;
   }
 
   assert(it->second > 0);
-  *tid = it->second - 1;
+  *entry_tid = it->second - 1;
   return true;
 }
 
@@ -393,15 +427,17 @@ void JournalMetadata::handle_watch_error(int err) {
 }
 
 uint64_t JournalMetadata::allocate_commit_tid(uint64_t object_num,
-                                              const std::string &tag,
-                                              uint64_t tid) {
+                                              uint64_t tag_tid,
+                                              uint64_t entry_tid) {
   Mutex::Locker locker(m_lock);
   uint64_t commit_tid = ++m_commit_tid;
-  m_pending_commit_tids[commit_tid] = CommitEntry(object_num, tag, tid);
+  m_pending_commit_tids[commit_tid] = CommitEntry(object_num, tag_tid,
+                                                  entry_tid);
 
   ldout(m_cct, 20) << "allocated commit tid: commit_tid=" << commit_tid << " ["
                    << "object_num=" << object_num << ", "
-                   << "tag=" << tag << ", tid=" << tid << "]" << dendl;
+                   << "tag_tid=" << tag_tid << ", entry_tid=" << entry_tid << "]"
+                   << dendl;
   return commit_tid;
 }
 
@@ -434,12 +470,13 @@ bool JournalMetadata::committed(uint64_t commit_tid,
 
     object_set_position->object_number = commit_entry.object_num;
     if (!object_set_position->entry_positions.empty() &&
-        object_set_position->entry_positions.front().tag == commit_entry.tag) {
+        object_set_position->entry_positions.front().tag_tid ==
+          commit_entry.tag_tid) {
       object_set_position->entry_positions.front() = EntryPosition(
-        commit_entry.tag, commit_entry.tid);
+        commit_entry.tag_tid, commit_entry.entry_tid);
     } else {
       object_set_position->entry_positions.push_front(EntryPosition(
-        commit_entry.tag, commit_entry.tid));
+        commit_entry.tag_tid, commit_entry.entry_tid));
     }
     m_pending_commit_tids.erase(it);
     update_commit_position = true;
@@ -447,10 +484,10 @@ bool JournalMetadata::committed(uint64_t commit_tid,
 
   if (update_commit_position) {
     // prune the position to have unique tags in commit-order
-    std::set<std::string> in_use_tags;
+    std::set<uint64_t> in_use_tag_tids;
     EntryPositions::iterator it = object_set_position->entry_positions.begin();
     while (it != object_set_position->entry_positions.end()) {
-      if (!in_use_tags.insert(it->tag).second) {
+      if (!in_use_tag_tids.insert(it->tag_tid).second) {
         it = object_set_position->entry_positions.erase(it);
       } else {
         ++it;
index d15bbca7ba1d67663bb9b86ed659dd4fa223dd0b..f87ae2424a44ad8925158c4b59b5bca2961246c8 100644 (file)
@@ -103,34 +103,35 @@ public:
     *registered_clients = m_registered_clients;
   }
 
-  inline uint64_t allocate_tid(const std::string &tag) {
+  inline uint64_t allocate_entry_tid(uint64_t tag_tid) {
     Mutex::Locker locker(m_lock);
-    return m_allocated_tids[tag]++;
+    return m_allocated_entry_tids[tag_tid]++;
   }
-  void reserve_tid(const std::string &tag, uint64_t tid);
-  bool get_last_allocated_tid(const std::string &tag, uint64_t *tid) const;
+  void reserve_entry_tid(uint64_t tag_tid, uint64_t entry_tid);
+  bool get_last_allocated_entry_tid(uint64_t tag_tid, uint64_t *entry_tid) const;
 
-  uint64_t allocate_commit_tid(uint64_t object_num, const std::string &tag,
-                               uint64_t tid);
+  uint64_t allocate_commit_tid(uint64_t object_num, uint64_t tag_tid,
+                               uint64_t entry_tid);
   bool committed(uint64_t commit_tid, ObjectSetPosition *object_set_position);
 
   void notify_update();
   void async_notify_update();
 
 private:
-  typedef std::map<std::string, uint64_t> AllocatedTids;
+  typedef std::map<uint64_t, uint64_t> AllocatedEntryTids;
   typedef std::list<Listener*> Listeners;
 
   struct CommitEntry {
     uint64_t object_num;
-    std::string tag;
-    uint64_t tid;
+    uint64_t tag_tid;
+    uint64_t entry_tid;
     bool committed;
 
-    CommitEntry() : object_num(0), tid(0), committed(false) {
+    CommitEntry() : object_num(0), tag_tid(0), entry_tid(0), committed(false) {
     }
-    CommitEntry(uint64_t _object_num, const std::string &_tag, uint64_t _tid)
-      : object_num(_object_num), tag(_tag), tid(_tid), committed(false) {
+    CommitEntry(uint64_t _object_num, uint64_t _tag_tid, uint64_t _entry_tid)
+      : object_num(_object_num), tag_tid(_tag_tid), entry_tid(_entry_tid),
+        committed(false) {
     }
   };
   typedef std::map<uint64_t, CommitEntry> CommitTids;
@@ -284,7 +285,7 @@ private:
   RegisteredClients m_registered_clients;
   Client m_client;
 
-  AllocatedTids m_allocated_tids;
+  AllocatedEntryTids m_allocated_entry_tids;
 
   size_t m_update_notifications;
   Cond m_update_cond;
index a2355f520635c8d699b74759c6a80d2b0ab4bdb7..45505a37708c805d7b6e8b0bf11d47ff3d213203 100644 (file)
@@ -55,7 +55,7 @@ JournalPlayer::JournalPlayer(librados::IoCtx &ioctx,
     m_journal_metadata(journal_metadata), m_replay_handler(replay_handler),
     m_lock("JournalPlayer::m_lock"), m_state(STATE_INIT), m_splay_offset(0),
     m_watch_enabled(false), m_watch_scheduled(false), m_watch_interval(0),
-    m_commit_object(0) {
+    m_commit_object(0), m_commit_tag_tid(0) {
   m_replay_handler->get();
   m_ioctx.dup(ioctx);
   m_cct = reinterpret_cast<CephContext *>(m_ioctx.cct());
@@ -66,13 +66,13 @@ JournalPlayer::JournalPlayer(librados::IoCtx &ioctx,
     uint8_t splay_width = m_journal_metadata->get_splay_width();
     m_splay_offset = commit_position.object_number % splay_width;
     m_commit_object = commit_position.object_number;
-    m_commit_tag = commit_position.entry_positions.front().tag;
+    m_commit_tag_tid = commit_position.entry_positions.front().tag_tid;
 
     for (EntryPositions::const_iterator it =
            commit_position.entry_positions.begin();
          it != commit_position.entry_positions.end(); ++it) {
       const EntryPosition &entry_position = *it;
-      m_commit_tids[entry_position.tag] = entry_position.tid;
+      m_commit_tids[entry_position.tag_tid] = entry_position.entry_tid;
     }
   }
 }
@@ -156,9 +156,10 @@ bool JournalPlayer::try_pop_front(Entry *entry, uint64_t *commit_tid) {
   object_player->front(entry);
   object_player->pop_front();
 
-  uint64_t last_tid;
-  if (m_journal_metadata->get_last_allocated_tid(entry->get_tag(), &last_tid) &&
-      entry->get_tid() != last_tid + 1) {
+  uint64_t last_entry_tid;
+  if (m_journal_metadata->get_last_allocated_entry_tid(
+        entry->get_tag_tid(), &last_entry_tid) &&
+      entry->get_entry_tid() != last_entry_tid + 1) {
     lderr(m_cct) << "missing prior journal entry: " << *entry << dendl;
 
     m_state = STATE_ERROR;
@@ -171,10 +172,10 @@ bool JournalPlayer::try_pop_front(Entry *entry, uint64_t *commit_tid) {
   if (!object_player->empty()) {
     Entry peek_entry;
     object_player->front(&peek_entry);
-    if (peek_entry.get_tag() == entry->get_tag() ||
-        (m_journal_metadata->get_last_allocated_tid(peek_entry.get_tag(),
-                                                    &last_tid) &&
-         last_tid + 1 != peek_entry.get_tid())) {
+    if (peek_entry.get_tag_tid() == entry->get_tag_tid() ||
+        (m_journal_metadata->get_last_allocated_entry_tid(
+           peek_entry.get_tag_tid(), &last_entry_tid) &&
+         last_entry_tid + 1 != peek_entry.get_entry_tid())) {
       advance_splay_object();
     }
   } else {
@@ -182,9 +183,11 @@ bool JournalPlayer::try_pop_front(Entry *entry, uint64_t *commit_tid) {
     remove_empty_object_player(object_player);
   }
 
-  m_journal_metadata->reserve_tid(entry->get_tag(), entry->get_tid());
+  m_journal_metadata->reserve_entry_tid(entry->get_tag_tid(),
+                                        entry->get_entry_tid());
   *commit_tid = m_journal_metadata->allocate_commit_tid(
-    object_player->get_object_number(), entry->get_tag(), entry->get_tid());
+    object_player->get_object_number(), entry->get_tag_tid(),
+    entry->get_entry_tid());
   return true;
 }
 
@@ -249,14 +252,15 @@ int JournalPlayer::process_prefetch(uint64_t object_number) {
       Entry entry;
       while (!m_commit_tids.empty() && !object_player->empty()) {
         object_player->front(&entry);
-        if (entry.get_tid() > m_commit_tids[entry.get_tag()]) {
+        if (entry.get_entry_tid() > m_commit_tids[entry.get_tag_tid()]) {
           ldout(m_cct, 10) << "located next uncommitted entry: " << entry
                            << dendl;
           break;
         }
 
         ldout(m_cct, 20) << "skipping committed entry: " << entry << dendl;
-        m_journal_metadata->reserve_tid(entry.get_tag(), entry.get_tid());
+        m_journal_metadata->reserve_entry_tid(entry.get_tag_tid(),
+                                              entry.get_entry_tid());
         object_player->pop_front();
       }
 
@@ -269,7 +273,7 @@ int JournalPlayer::process_prefetch(uint64_t object_number) {
         } else {
           Entry entry;
           object_player->front(&entry);
-          if (entry.get_tag() == m_commit_tag) {
+          if (entry.get_tag_tid() == m_commit_tag_tid) {
             advance_splay_object();
           }
         }
index 49680adac75b3bc7420b99a41df02fbb0fb267e6..1e7bdff23b6edb3e20cf46168bb1bc5ad062b019 100644 (file)
@@ -40,7 +40,7 @@ public:
 
 private:
   typedef std::set<uint8_t> PrefetchSplayOffsets;
-  typedef std::map<std::string, uint64_t> AllocatedTids;
+  typedef std::map<uint64_t, uint64_t> AllocatedEntryTids;
   typedef std::map<uint64_t, ObjectPlayerPtr> ObjectPlayers;
   typedef std::map<uint8_t, ObjectPlayers> SplayedObjectPlayers;
 
@@ -96,8 +96,8 @@ private:
   PrefetchSplayOffsets m_prefetch_splay_offsets;
   SplayedObjectPlayers m_object_players;
   uint64_t m_commit_object;
-  std::string m_commit_tag;
-  AllocatedTids m_commit_tids;
+  uint64_t m_commit_tag_tid;
+  AllocatedEntryTids m_commit_tids;
 
   void advance_splay_object();
 
index e65228bd91ca1578f89d0f4ada5876f9603e1647..21ecc2c90a74aa727528b7e98935ffaa673d877c 100644 (file)
@@ -70,24 +70,25 @@ JournalRecorder::~JournalRecorder() {
   m_journal_metadata->remove_listener(&m_listener);
 }
 
-Future JournalRecorder::append(const std::string &tag,
+Future JournalRecorder::append(uint64_t tag_tid,
                                const bufferlist &payload_bl) {
   Mutex::Locker locker(m_lock);
 
-  uint64_t tid = m_journal_metadata->allocate_tid(tag);
+  uint64_t entry_tid = m_journal_metadata->allocate_entry_tid(tag_tid);
   uint8_t splay_width = m_journal_metadata->get_splay_width();
-  uint8_t splay_offset = tid % splay_width;
+  uint8_t splay_offset = entry_tid % splay_width;
 
   ObjectRecorderPtr object_ptr = get_object(splay_offset);
   uint64_t commit_tid = m_journal_metadata->allocate_commit_tid(
-    object_ptr->get_object_number(), tagtid);
+    object_ptr->get_object_number(), tag_tid, entry_tid);
   FutureImplPtr future(new FutureImpl(m_journal_metadata->get_finisher(),
-                                      tagtid, commit_tid));
+                                      tag_tid, entry_tid, commit_tid));
   future->init(m_prev_future);
   m_prev_future = future;
 
   bufferlist entry_bl;
-  ::encode(Entry(future->get_tag(), future->get_tid(), payload_bl), entry_bl);
+  ::encode(Entry(future->get_tag_tid(), future->get_entry_tid(), payload_bl),
+           entry_bl);
 
   AppendBuffers append_buffers;
   append_buffers.push_back(std::make_pair(future, entry_bl));
index 58b988e9f66b199929791f13f92be7c30ffbc24b..be92298a4838396f32acd2eb282fc61434172868 100644 (file)
@@ -28,7 +28,7 @@ public:
                   double flush_age);
   ~JournalRecorder();
 
-  Future append(const std::string &tag, const bufferlist &bl);
+  Future append(uint64_t tag_tid, const bufferlist &bl);
   void flush(Context *on_safe);
 
   ObjectRecorderPtr get_object(uint8_t splay_offset);
index 25a50b89bed5ffcbaf34321212646b8775f1c975..171021fe24e268dce2947e4aea19fdd8a6e9f4c2 100644 (file)
@@ -179,7 +179,7 @@ void Journaler::start_live_replay(ReplayHandler *replay_handler,
 }
 
 bool Journaler::try_pop_front(ReplayEntry *replay_entry,
-                             std::string* tag) {
+                             uint64_t *tag_tid) {
   assert(m_player != NULL);
 
   Entry entry;
@@ -189,8 +189,8 @@ bool Journaler::try_pop_front(ReplayEntry *replay_entry,
   }
 
   *replay_entry = ReplayEntry(entry.get_data(), commit_tid);
-  if (tag != NULL) {
-    *tag = entry.get_tag();
+  if (tag_tid != nullptr) {
+    *tag_tid = entry.get_tag_tid();
   }
   return true;
 }
@@ -229,8 +229,8 @@ void Journaler::stop_append(Context *on_safe) {
   m_recorder = NULL;
 }
 
-Future Journaler::append(const std::string &tag, const bufferlist &payload_bl) {
-  return m_recorder->append(tag, payload_bl);
+Future Journaler::append(uint64_t tag_tid, const bufferlist &payload_bl) {
+  return m_recorder->append(tag_tid, payload_bl);
 }
 
 void Journaler::flush(Context *on_safe) {
index 27f77c72cd75a4574072287234d9d275e4a25e6a..42e5b0e41eebc2e71a030ce7311e90891008aec1 100644 (file)
@@ -47,11 +47,11 @@ public:
 
   void start_replay(ReplayHandler *replay_handler);
   void start_live_replay(ReplayHandler *replay_handler, double interval);
-  bool try_pop_front(ReplayEntry *replay_entry, std::string* tag = NULL);
+  bool try_pop_front(ReplayEntry *replay_entry, uint64_t *tag_tid = nullptr);
   void stop_replay();
 
   void start_append(int flush_interval, uint64_t flush_bytes, double flush_age);
-  Future append(const std::string &tag, const bufferlist &bl);
+  Future append(uint64_t tag_tid, const bufferlist &bl);
   void flush(Context *on_safe);
   void stop_append(Context *on_safe);
 
index 9d58d8e1e153ce867858b21c1e7b91ffded89819..56459a5bc684d9b91419c2b5a2c8993f299cae02 100644 (file)
@@ -142,7 +142,8 @@ int ObjectPlayer::handle_fetch_complete(int r, const bufferlist &bl) {
     ::decode(entry, iter);
     ldout(m_cct, 20) << ": " << entry << " decoded" << dendl;
 
-    EntryKey entry_key(std::make_pair(entry.get_tag(), entry.get_tid()));
+    EntryKey entry_key(std::make_pair(entry.get_tag_tid(),
+                                      entry.get_entry_tid()));
     if (m_entry_keys.find(entry_key) == m_entry_keys.end()) {
       m_entry_keys[entry_key] = m_entries.insert(m_entries.end(), entry);
     } else {
index 5fb9c2723158251f7aa222b20c8400e0f01f7ac8..22b51f620225e7d30acd5271a00a3aa19aa59ea5 100644 (file)
@@ -68,7 +68,7 @@ public:
   }
 
 private:
-  typedef std::pair<std::string, uint64_t> EntryKey;
+  typedef std::pair<uint64_t, uint64_t> EntryKey;
   typedef boost::unordered_map<EntryKey, Entries::iterator> EntryKeys;
 
   struct C_Fetch : public Context {
index 3b52f522eefbd8f3866d5a260fd4f8625365af6f..d55a527888a1919133e5a939a4bceb9033cbbbbf 100644 (file)
@@ -290,7 +290,8 @@ uint64_t Journal<I>::append_io_event(AioCompletion *aio_comp,
     tid = ++m_event_tid;
     assert(tid != 0);
 
-    future = m_journaler->append("", bl);
+    // TODO: use allocated tag_id
+    future = m_journaler->append(0, bl);
     m_events[tid] = Event(future, aio_comp, requests, offset, length);
   }
 
@@ -374,7 +375,9 @@ void Journal<I>::append_op_event(uint64_t op_tid,
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
-    future = m_journaler->append("", bl);
+
+    // TODO: use allocated tag_id
+    future = m_journaler->append(0, bl);
   }
 
   on_safe = create_async_context_callback(m_image_ctx, on_safe);
@@ -401,7 +404,9 @@ void Journal<I>::commit_op_event(uint64_t op_tid, int r) {
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
-    future = m_journaler->append("", bl);
+
+    // TODO: use allocated tag_id
+    future = m_journaler->append(0, bl);
   }
 
   future.flush(new C_OpEventSafe(this, op_tid, future, nullptr));
index b6405ff0fa99143a5e2aa69fd3c4a35fffbd318f..4187ec206441f5ca327418223252cab9f38daa67 100644 (file)
@@ -249,8 +249,8 @@ TEST_F(TestClsJournal, ClientCommit) {
 
   cls::journal::EntryPositions entry_positions;
   entry_positions = {
-    cls::journal::EntryPosition("tag1", 120),
-    cls::journal::EntryPosition("tag2", 121)};
+    cls::journal::EntryPosition(234, 120),
+    cls::journal::EntryPosition(235, 121)};
   cls::journal::ObjectSetPosition object_set_position(
     1, entry_positions);
 
@@ -277,9 +277,9 @@ TEST_F(TestClsJournal, ClientCommitInvalid) {
 
   cls::journal::EntryPositions entry_positions;
   entry_positions = {
-    cls::journal::EntryPosition("tag1", 120),
-    cls::journal::EntryPosition("tag1", 121),
-    cls::journal::EntryPosition("tag2", 121)};
+    cls::journal::EntryPosition(234, 120),
+    cls::journal::EntryPosition(234, 121),
+    cls::journal::EntryPosition(235, 121)};
   cls::journal::ObjectSetPosition object_set_position(
     1, entry_positions);
 
index e042978d4f9db2d9e648482dee4e158565f91785..44fbb0fe2304c62f615ac5d97adeda9c27c69d04 100644 (file)
@@ -9,8 +9,8 @@ class TestEntry : public ::testing::Test {
 
 TEST_F(TestEntry, DefaultConstructor) {
   journal::Entry entry;
-  ASSERT_EQ(0U, entry.get_tid());
-  ASSERT_EQ("", entry.get_tag());
+  ASSERT_EQ(0U, entry.get_entry_tid());
+  ASSERT_EQ(0U, entry.get_tag_tid());
 
   bufferlist data(entry.get_data());
   bufferlist expected_data;
@@ -20,7 +20,7 @@ TEST_F(TestEntry, DefaultConstructor) {
 TEST_F(TestEntry, Constructor) {
   bufferlist data;
   data.append("data");
-  journal::Entry entry("tag", 123, data);
+  journal::Entry entry(234, 123, data);
 
   data.clear();
   data = entry.get_data();
@@ -28,15 +28,15 @@ TEST_F(TestEntry, Constructor) {
   bufferlist expected_data;
   expected_data.append("data");
 
-  ASSERT_EQ(123U, entry.get_tid());
-  ASSERT_EQ("tag", entry.get_tag());
+  ASSERT_EQ(123U, entry.get_entry_tid());
+  ASSERT_EQ(234U, entry.get_tag_tid());
   ASSERT_TRUE(data.contents_equal(expected_data));
 }
 
 TEST_F(TestEntry, IsReadable) {
   bufferlist data;
   data.append("data");
-  journal::Entry entry("tag", 123, data);
+  journal::Entry entry(234, 123, data);
 
   bufferlist full_bl;
   ::encode(entry, full_bl);
@@ -58,7 +58,7 @@ TEST_F(TestEntry, IsReadable) {
 TEST_F(TestEntry, IsReadableBadPreamble) {
   bufferlist data;
   data.append("data");
-  journal::Entry entry("tag", 123, data);
+  journal::Entry entry(234, 123, data);
 
   uint64_t stray_bytes = 0x1122334455667788;
   bufferlist full_bl;
@@ -78,7 +78,7 @@ TEST_F(TestEntry, IsReadableBadPreamble) {
 TEST_F(TestEntry, IsReadableBadCRC) {
   bufferlist data;
   data.append("data");
-  journal::Entry entry("tag", 123, data);
+  journal::Entry entry(234, 123, data);
 
   bufferlist full_bl;
   ::encode(entry, full_bl);
index 5d5bb04c1d71f2246f7c798e36da08bb78b5a7f7..3a45a8d9b5fd08a141aba697f552c452e025f83c 100644 (file)
@@ -40,12 +40,12 @@ public:
     m_finisher->start();
   }
 
-  journal::FutureImplPtr create_future(const std::string &tag, uint64_t tid,
+  journal::FutureImplPtr create_future(uint64_t tag_tid, uint64_t entry_tid,
                                        uint64_t commit_tid,
                                        const journal::FutureImplPtr &prev =
                                          journal::FutureImplPtr()) {
     journal::FutureImplPtr future(new journal::FutureImpl(*m_finisher,
-                                                          tagtid,
+                                                          tag_tid, entry_tid,
                                                           commit_tid));
     future->init(prev);
     return future;
@@ -60,20 +60,20 @@ public:
 };
 
 TEST_F(TestFutureImpl, Getters) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
-  ASSERT_EQ("tag", future->get_tag());
-  ASSERT_EQ(123U, future->get_tid());
+  journal::FutureImplPtr future = create_future(234, 123, 456);
+  ASSERT_EQ(234U, future->get_tag_tid());
+  ASSERT_EQ(123U, future->get_entry_tid());
   ASSERT_EQ(456U, future->get_commit_tid());
 }
 
 TEST_F(TestFutureImpl, Attach) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   ASSERT_FALSE(future->attach(&m_flush_handler));
   ASSERT_EQ(1U, m_flush_handler.refs);
 }
 
 TEST_F(TestFutureImpl, AttachWithPendingFlush) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   future->flush(NULL);
 
   ASSERT_TRUE(future->attach(&m_flush_handler));
@@ -81,21 +81,21 @@ TEST_F(TestFutureImpl, AttachWithPendingFlush) {
 }
 
 TEST_F(TestFutureImpl, Detach) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   ASSERT_FALSE(future->attach(&m_flush_handler));
   future->detach();
   ASSERT_EQ(0U, m_flush_handler.refs);
 }
 
 TEST_F(TestFutureImpl, DetachImplicit) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   ASSERT_FALSE(future->attach(&m_flush_handler));
   future.reset();
   ASSERT_EQ(0U, m_flush_handler.refs);
 }
 
 TEST_F(TestFutureImpl, Flush) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   ASSERT_FALSE(future->attach(&m_flush_handler));
 
   C_SaferCond cond;
@@ -107,7 +107,7 @@ TEST_F(TestFutureImpl, Flush) {
 }
 
 TEST_F(TestFutureImpl, FlushWithoutContext) {
-  journal::FutureImplPtr future = create_future("tag", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   ASSERT_FALSE(future->attach(&m_flush_handler));
 
   future->flush(NULL);
@@ -118,9 +118,9 @@ TEST_F(TestFutureImpl, FlushWithoutContext) {
 }
 
 TEST_F(TestFutureImpl, FlushChain) {
-  journal::FutureImplPtr future1 = create_future("tag1", 123, 456);
-  journal::FutureImplPtr future2 = create_future("tag1", 124, 457, future1);
-  journal::FutureImplPtr future3 = create_future("tag2", 1, 458, future2);
+  journal::FutureImplPtr future1 = create_future(234, 123, 456);
+  journal::FutureImplPtr future2 = create_future(234, 124, 457, future1);
+  journal::FutureImplPtr future3 = create_future(235, 1, 458, future2);
   ASSERT_FALSE(future1->attach(&m_flush_handler));
   ASSERT_FALSE(future2->attach(&m_flush_handler));
   ASSERT_FALSE(future3->attach(&m_flush_handler));
@@ -144,8 +144,8 @@ TEST_F(TestFutureImpl, FlushChain) {
 }
 
 TEST_F(TestFutureImpl, FlushInProgress) {
-  journal::FutureImplPtr future1 = create_future("tag1", 123, 456);
-  journal::FutureImplPtr future2 = create_future("tag1", 124, 457, future1);
+  journal::FutureImplPtr future1 = create_future(234, 123, 456);
+  journal::FutureImplPtr future2 = create_future(234, 124, 457, future1);
   ASSERT_FALSE(future1->attach(&m_flush_handler));
   ASSERT_FALSE(future2->attach(&m_flush_handler));
 
@@ -159,7 +159,7 @@ TEST_F(TestFutureImpl, FlushInProgress) {
 }
 
 TEST_F(TestFutureImpl, FlushAlreadyComplete) {
-  journal::FutureImplPtr future = create_future("tag1", 123, 456);
+  journal::FutureImplPtr future = create_future(234, 123, 456);
   future->safe(-EIO);
 
   C_SaferCond cond;
@@ -168,7 +168,7 @@ TEST_F(TestFutureImpl, FlushAlreadyComplete) {
 }
 
 TEST_F(TestFutureImpl, Wait) {
-  journal::FutureImplPtr future = create_future("tag", 1, 456);
+  journal::FutureImplPtr future = create_future(234, 1, 456);
 
   C_SaferCond cond;
   future->wait(&cond);
@@ -177,7 +177,7 @@ TEST_F(TestFutureImpl, Wait) {
 }
 
 TEST_F(TestFutureImpl, WaitAlreadyComplete) {
-  journal::FutureImplPtr future = create_future("tag", 1, 456);
+  journal::FutureImplPtr future = create_future(234, 1, 456);
   future->safe(-EEXIST);
 
   C_SaferCond cond;
@@ -186,8 +186,8 @@ TEST_F(TestFutureImpl, WaitAlreadyComplete) {
 }
 
 TEST_F(TestFutureImpl, SafePreservesError) {
-  journal::FutureImplPtr future1 = create_future("tag1", 123, 456);
-  journal::FutureImplPtr future2 = create_future("tag1", 124, 457, future1);
+  journal::FutureImplPtr future1 = create_future(234, 123, 456);
+  journal::FutureImplPtr future2 = create_future(234, 124, 457, future1);
 
   future1->safe(-EIO);
   future2->safe(-EEXIST);
@@ -196,8 +196,8 @@ TEST_F(TestFutureImpl, SafePreservesError) {
 }
 
 TEST_F(TestFutureImpl, ConsistentPreservesError) {
-  journal::FutureImplPtr future1 = create_future("tag1", 123, 456);
-  journal::FutureImplPtr future2 = create_future("tag1", 124, 457, future1);
+  journal::FutureImplPtr future1 = create_future(234, 123, 456);
+  journal::FutureImplPtr future2 = create_future(234, 124, 457, future1);
 
   future2->safe(-EEXIST);
   future1->safe(-EIO);
index e0bd918dc2706094d171e78393984b15816bb4af..1a97ae7c46a8d0fce47cea587e945ce1b2e21e09 100644 (file)
@@ -70,7 +70,7 @@ TEST_F(TestJournalMetadata, SetCommitPositions) {
 
   journal::JournalMetadata::EntryPositions entry_positions;
   entry_positions = {
-    cls::journal::EntryPosition("tag1", 122)};
+    cls::journal::EntryPosition(123, 122)};
   commit_position = journal::JournalMetadata::ObjectSetPosition(1, entry_positions);
 
   C_SaferCond cond;
index c4c2f92319435a05be88269878e1b873f76d1e05..66363272bd479add58f054c75ac3692ecfb9e840 100644 (file)
@@ -31,10 +31,6 @@ public:
     virtual void get() {}
     virtual void put() {}
 
-    virtual bool filter_entry(const std::string &tag) {
-      return false;
-    }
-
     virtual void handle_entries_available() {
       Mutex::Locker locker(lock);
       entries_available = true;
@@ -70,10 +66,10 @@ public:
     return RadosTestFixture::client_commit(oid, "client", position);
   }
 
-  journal::Entry create_entry(const std::string &tag, uint64_t tid) {
+  journal::Entry create_entry(uint64_t tag_tid, uint64_t entry_tid) {
     bufferlist payload_bl;
     payload_bl.append("playload");
-    return journal::Entry(tagtid, payload_bl);
+    return journal::Entry(tag_tid, entry_tid, payload_bl);
   }
 
   journal::JournalMetadataPtr create_metadata(const std::string &oid) {
@@ -134,9 +130,9 @@ public:
   }
 
   int write_entry(const std::string &oid, uint64_t object_num,
-                  const std::string &tag, uint64_t tid) {
+                  uint64_t tag_tid, uint64_t entry_tid) {
     bufferlist bl;
-    ::encode(create_entry(tagtid), bl);
+    ::encode(create_entry(tag_tid, entry_tid), bl);
     return append(oid + "." + stringify(object_num), bl);
   }
 
@@ -149,7 +145,7 @@ TEST_F(TestJournalPlayer, Prefetch) {
 
   journal::JournalPlayer::EntryPositions positions;
   positions = {
-    cls::journal::EntryPosition("tag1", 122) };
+    cls::journal::EntryPosition(234, 122) };
   cls::journal::ObjectSetPosition commit_position(0, positions);
 
   ASSERT_EQ(0, create(oid));
@@ -161,10 +157,10 @@ TEST_F(TestJournalPlayer, Prefetch) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 125));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 124));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 125));
 
   player->prefetch();
 
@@ -174,13 +170,13 @@ TEST_F(TestJournalPlayer, Prefetch) {
 
   Entries expected_entries;
   expected_entries = {
-    create_entry("tag1", 123),
-    create_entry("tag1", 124),
-    create_entry("tag1", 125)};
+    create_entry(234, 123),
+    create_entry(234, 124),
+    create_entry(234, 125)};
   ASSERT_EQ(expected_entries, entries);
 
   uint64_t last_tid;
-  ASSERT_TRUE(metadata->get_last_allocated_tid("tag1", &last_tid));
+  ASSERT_TRUE(metadata->get_last_allocated_entry_tid(234, &last_tid));
   ASSERT_EQ(125U, last_tid);
 }
 
@@ -189,7 +185,7 @@ TEST_F(TestJournalPlayer, PrefetchSkip) {
 
   journal::JournalPlayer::EntryPositions positions;
   positions = {
-    cls::journal::EntryPosition("tag1", 125) };
+    cls::journal::EntryPosition(234, 125) };
   cls::journal::ObjectSetPosition commit_position(0, positions);
 
   ASSERT_EQ(0, create(oid));
@@ -201,10 +197,10 @@ TEST_F(TestJournalPlayer, PrefetchSkip) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 125));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 124));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 125));
 
   player->prefetch();
 
@@ -213,7 +209,7 @@ TEST_F(TestJournalPlayer, PrefetchSkip) {
   ASSERT_TRUE(wait_for_complete(player));
 
   uint64_t last_tid;
-  ASSERT_TRUE(metadata->get_last_allocated_tid("tag1", &last_tid));
+  ASSERT_TRUE(metadata->get_last_allocated_entry_tid(234, &last_tid));
   ASSERT_EQ(125U, last_tid);
 }
 
@@ -231,8 +227,8 @@ TEST_F(TestJournalPlayer, PrefetchWithoutCommit) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
 
   player->prefetch();
 
@@ -242,8 +238,8 @@ TEST_F(TestJournalPlayer, PrefetchWithoutCommit) {
 
   Entries expected_entries;
   expected_entries = {
-    create_entry("tag1", 122),
-    create_entry("tag1", 123)};
+    create_entry(234, 122),
+    create_entry(234, 123)};
   ASSERT_EQ(expected_entries, entries);
 }
 
@@ -252,8 +248,8 @@ TEST_F(TestJournalPlayer, PrefetchMultipleTags) {
 
   journal::JournalPlayer::EntryPositions positions;
   positions = {
-    cls::journal::EntryPosition("tag1", 122),
-    cls::journal::EntryPosition("tag2", 1)};
+    cls::journal::EntryPosition(234, 122),
+    cls::journal::EntryPosition(345, 1)};
   cls::journal::ObjectSetPosition commit_position(0, positions);
 
   ASSERT_EQ(0, create(oid));
@@ -265,14 +261,14 @@ TEST_F(TestJournalPlayer, PrefetchMultipleTags) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 120));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag2", 0));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 121));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag2", 1));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag2", 2));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 120));
+  ASSERT_EQ(0, write_entry(oid, 0, 345, 0));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 121));
+  ASSERT_EQ(0, write_entry(oid, 1, 345, 1));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 124));
+  ASSERT_EQ(0, write_entry(oid, 0, 345, 2));
 
   player->prefetch();
 
@@ -281,9 +277,9 @@ TEST_F(TestJournalPlayer, PrefetchMultipleTags) {
   ASSERT_TRUE(wait_for_complete(player));
 
   uint64_t last_tid;
-  ASSERT_TRUE(metadata->get_last_allocated_tid("tag1", &last_tid));
+  ASSERT_TRUE(metadata->get_last_allocated_entry_tid(234, &last_tid));
   ASSERT_EQ(124U, last_tid);
-  ASSERT_TRUE(metadata->get_last_allocated_tid("tag2", &last_tid));
+  ASSERT_TRUE(metadata->get_last_allocated_entry_tid(345, &last_tid));
   ASSERT_EQ(2U, last_tid);
 }
 
@@ -301,10 +297,10 @@ TEST_F(TestJournalPlayer, PrefetchCorruptSequence) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 120));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag2", 0));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 121));
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 120));
+  ASSERT_EQ(0, write_entry(oid, 0, 345, 0));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 121));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 124));
 
   player->prefetch();
   Entries entries;
@@ -322,7 +318,7 @@ TEST_F(TestJournalPlayer, PrefetchAndWatch) {
 
   journal::JournalPlayer::EntryPositions positions;
   positions = {
-    cls::journal::EntryPosition("tag1", 122)};
+    cls::journal::EntryPosition(234, 122)};
   cls::journal::ObjectSetPosition commit_position(0, positions);
 
   ASSERT_EQ(0, create(oid));
@@ -334,22 +330,22 @@ TEST_F(TestJournalPlayer, PrefetchAndWatch) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
 
   player->prefetch_and_watch(0.25);
 
   Entries entries;
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
   ASSERT_TRUE(wait_for_entries(player, 1, &entries));
 
   Entries expected_entries;
-  expected_entries = {create_entry("tag1", 123)};
+  expected_entries = {create_entry(234, 123)};
   ASSERT_EQ(expected_entries, entries);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 124));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 124));
   ASSERT_TRUE(wait_for_entries(player, 1, &entries));
 
-  expected_entries = {create_entry("tag1", 124)};
+  expected_entries = {create_entry(234, 124)};
   ASSERT_EQ(expected_entries, entries);
 }
 
@@ -368,11 +364,11 @@ TEST_F(TestJournalPlayer, PrefetchSkippedObject) {
 
   journal::JournalPlayer *player = create_player(oid, metadata);
 
-  ASSERT_EQ(0, write_entry(oid, 0, "tag1", 122));
-  ASSERT_EQ(0, write_entry(oid, 1, "tag1", 123));
-  ASSERT_EQ(0, write_entry(oid, 5, "tag1", 124));
-  ASSERT_EQ(0, write_entry(oid, 6, "tag1", 125));
-  ASSERT_EQ(0, write_entry(oid, 7, "tag1", 126));
+  ASSERT_EQ(0, write_entry(oid, 0, 234, 122));
+  ASSERT_EQ(0, write_entry(oid, 1, 234, 123));
+  ASSERT_EQ(0, write_entry(oid, 5, 234, 124));
+  ASSERT_EQ(0, write_entry(oid, 6, 234, 125));
+  ASSERT_EQ(0, write_entry(oid, 7, 234, 126));
 
   player->prefetch();
 
@@ -382,14 +378,14 @@ TEST_F(TestJournalPlayer, PrefetchSkippedObject) {
 
   Entries expected_entries;
   expected_entries = {
-    create_entry("tag1", 122),
-    create_entry("tag1", 123),
-    create_entry("tag1", 124),
-    create_entry("tag1", 125),
-    create_entry("tag1", 126)};
+    create_entry(234, 122),
+    create_entry(234, 123),
+    create_entry(234, 124),
+    create_entry(234, 125),
+    create_entry(234, 126)};
   ASSERT_EQ(expected_entries, entries);
 
   uint64_t last_tid;
-  ASSERT_TRUE(metadata->get_last_allocated_tid("tag1", &last_tid));
+  ASSERT_TRUE(metadata->get_last_allocated_entry_tid(234, &last_tid));
   ASSERT_EQ(126U, last_tid);
 }
index 73b3f35b2d1ca9d3c081d88fd2d2e1e22229c615..099c9a28b007a26e2f65cdffb6ca6f9506517b4b 100644 (file)
@@ -50,7 +50,7 @@ TEST_F(TestJournalRecorder, Append) {
 
   journal::JournalRecorder *recorder = create_recorder(oid, metadata);
 
-  journal::Future future1 = recorder->append("tag1", create_payload("payload"));
+  journal::Future future1 = recorder->append(123, create_payload("payload"));
 
   C_SaferCond cond;
   future1.flush(&cond);
@@ -68,8 +68,8 @@ TEST_F(TestJournalRecorder, AppendKnownOverflow) {
 
   journal::JournalRecorder *recorder = create_recorder(oid, metadata);
 
-  recorder->append("tag1", create_payload(std::string(1 << 12, '1')));
-  journal::Future future2 = recorder->append("tag1", create_payload(std::string(1, '2')));
+  recorder->append(123, create_payload(std::string(1 << 12, '1')));
+  journal::Future future2 = recorder->append(123, create_payload(std::string(1, '2')));
 
   C_SaferCond cond;
   future2.flush(&cond);
@@ -90,10 +90,10 @@ TEST_F(TestJournalRecorder, AppendDelayedOverflow) {
   journal::JournalRecorder *recorder1 = create_recorder(oid, metadata);
   journal::JournalRecorder *recorder2 = create_recorder(oid, metadata);
 
-  recorder1->append("tag1", create_payload(std::string(1, '1')));
-  recorder2->append("tag2", create_payload(std::string(1 << 12, '2')));
+  recorder1->append(123, create_payload(std::string(1, '1')));
+  recorder2->append(234, create_payload(std::string(1 << 12, '2')));
 
-  journal::Future future = recorder2->append("tag1", create_payload(std::string(1, '3')));
+  journal::Future future = recorder2->append(123, create_payload(std::string(1, '3')));
 
   C_SaferCond cond;
   future.flush(&cond);
@@ -112,8 +112,8 @@ TEST_F(TestJournalRecorder, FutureFlush) {
 
   journal::JournalRecorder *recorder = create_recorder(oid, metadata);
 
-  journal::Future future1 = recorder->append("tag1", create_payload("payload1"));
-  journal::Future future2 = recorder->append("tag1", create_payload("payload2"));
+  journal::Future future1 = recorder->append(123, create_payload("payload1"));
+  journal::Future future2 = recorder->append(123, create_payload("payload2"));
 
   C_SaferCond cond;
   future2.flush(&cond);
@@ -132,8 +132,8 @@ TEST_F(TestJournalRecorder, Flush) {
 
   journal::JournalRecorder *recorder = create_recorder(oid, metadata);
 
-  journal::Future future1 = recorder->append("tag1", create_payload("payload1"));
-  journal::Future future2 = recorder->append("tag1", create_payload("payload2"));
+  journal::Future future1 = recorder->append(123, create_payload("payload1"));
+  journal::Future future2 = recorder->append(123, create_payload("payload2"));
 
   C_SaferCond cond1;
   recorder->flush(&cond1);
index 18572aa609ce1d0da116d79fce141f09f07f8f69..896f80c88faec46430ae8ecd811c89501f3c8df3 100644 (file)
@@ -27,7 +27,7 @@ public:
                      const std::string &oid, uint64_t object_num,
                      const std::string &payload, uint64_t *commit_tid) {
     int r = append(oid + "." + stringify(object_num), create_payload(payload));
-    uint64_t tid = metadata->allocate_commit_tid(object_num, "tag", 123);
+    uint64_t tid = metadata->allocate_commit_tid(object_num, 234, 123);
     if (commit_tid != NULL) {
       *commit_tid = tid;
     }
index 3e9a2afd7ab62d995f099612f300315a0164ca9e..86bf3ca5bfc2f974993b5e6e8c651fc06ec7a4db 100644 (file)
@@ -27,8 +27,8 @@ public:
 TEST_F(TestObjectPlayer, Fetch) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(std::string(24, '1')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 124, create_payload(std::string(24, '1')));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -52,9 +52,9 @@ TEST_F(TestObjectPlayer, Fetch) {
 TEST_F(TestObjectPlayer, FetchLarge) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123,
+  journal::Entry entry1(234, 123,
                         create_payload(std::string(8192 - 33, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(""));
+  journal::Entry entry2(234, 124, create_payload(""));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -78,8 +78,8 @@ TEST_F(TestObjectPlayer, FetchLarge) {
 TEST_F(TestObjectPlayer, FetchDeDup) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 123, create_payload(std::string(24, '2')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 123, create_payload(std::string(24, '2')));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -128,8 +128,8 @@ TEST_F(TestObjectPlayer, FetchError) {
 TEST_F(TestObjectPlayer, FetchCorrupt) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(std::string(24, '2')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 124, create_payload(std::string(24, '2')));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -154,8 +154,8 @@ TEST_F(TestObjectPlayer, FetchCorrupt) {
 TEST_F(TestObjectPlayer, FetchAppend) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(std::string(24, '2')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 124, create_payload(std::string(24, '2')));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -192,8 +192,8 @@ TEST_F(TestObjectPlayer, FetchAppend) {
 TEST_F(TestObjectPlayer, PopEntry) {
   std::string oid = get_temp_oid();
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(std::string(24, '1')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 124, create_payload(std::string(24, '1')));
 
   bufferlist bl;
   ::encode(entry1, bl);
@@ -227,8 +227,8 @@ TEST_F(TestObjectPlayer, Watch) {
   C_SaferCond cond1;
   object->watch(&cond1, 0.1);
 
-  journal::Entry entry1("tag1", 123, create_payload(std::string(24, '1')));
-  journal::Entry entry2("tag1", 124, create_payload(std::string(24, '1')));
+  journal::Entry entry1(234, 123, create_payload(std::string(24, '1')));
+  journal::Entry entry2(234, 124, create_payload(std::string(24, '1')));
 
   bufferlist bl;
   ::encode(entry1, bl);
index 8c2743028774d20633caccea3621aa3db2e037f8..9d3d0e51c379ab9634a06336376ef0095d0b7135 100644 (file)
@@ -80,11 +80,10 @@ public:
     m_flush_age = i;
   }
 
-  journal::AppendBuffer create_append_buffer(const std::string &tag,
-                                             uint64_t tid,
+  journal::AppendBuffer create_append_buffer(uint64_t tag_tid, uint64_t entry_tid,
                                              const std::string &payload) {
     journal::FutureImplPtr future(new journal::FutureImpl(*m_finisher,
-                                                          tagtid, 456));
+                                                          tag_tid, entry_tid, 456));
     future->init(journal::FutureImplPtr());
 
     bufferlist bl;
@@ -107,14 +106,14 @@ TEST_F(TestObjectRecorder, Append) {
 
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
   ASSERT_FALSE(object->append(append_buffers));
   ASSERT_EQ(1U, object->get_pending_appends());
 
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                              "payload");
   append_buffers = {append_buffer2};
   ASSERT_FALSE(object->append(append_buffers));
@@ -132,14 +131,14 @@ TEST_F(TestObjectRecorder, AppendFlushByCount) {
   set_flush_interval(2);
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
   ASSERT_FALSE(object->append(append_buffers));
   ASSERT_EQ(1U, object->get_pending_appends());
 
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                              "payload");
   append_buffers = {append_buffer2};
   ASSERT_FALSE(object->append(append_buffers));
@@ -156,14 +155,14 @@ TEST_F(TestObjectRecorder, AppendFlushByBytes) {
   set_flush_bytes(10);
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
   ASSERT_FALSE(object->append(append_buffers));
   ASSERT_EQ(1U, object->get_pending_appends());
 
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                              "payload");
   append_buffers = {append_buffer2};
   ASSERT_FALSE(object->append(append_buffers));
@@ -180,13 +179,13 @@ TEST_F(TestObjectRecorder, AppendFlushByAge) {
   set_flush_age(0.1);
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
   ASSERT_FALSE(object->append(append_buffers));
 
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                              "payload");
   append_buffers = {append_buffer2};
   ASSERT_FALSE(object->append(append_buffers));
@@ -203,13 +202,13 @@ TEST_F(TestObjectRecorder, AppendFilledObject) {
   journal::ObjectRecorderPtr object = create_object(oid, 12);
 
   std::string payload(2048, '1');
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                               payload);
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
   ASSERT_FALSE(object->append(append_buffers));
 
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                               payload);
   append_buffers = {append_buffer2};
   ASSERT_TRUE(object->append(append_buffers));
@@ -225,7 +224,7 @@ TEST_F(TestObjectRecorder, Flush) {
 
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1};
@@ -247,7 +246,7 @@ TEST_F(TestObjectRecorder, FlushFuture) {
 
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer = create_append_buffer(234, 123,
                                                              "payload");
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer};
@@ -267,7 +266,7 @@ TEST_F(TestObjectRecorder, FlushDetachedFuture) {
 
   journal::ObjectRecorderPtr object = create_object(oid, 24);
 
-  journal::AppendBuffer append_buffer = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer = create_append_buffer(234, 123,
                                                              "payload");
 
   journal::AppendBuffers append_buffers;
@@ -290,9 +289,9 @@ TEST_F(TestObjectRecorder, Overflow) {
   journal::ObjectRecorderPtr object2 = create_object(oid, 12);
 
   std::string payload(2048, '1');
-  journal::AppendBuffer append_buffer1 = create_append_buffer("tag", 123,
+  journal::AppendBuffer append_buffer1 = create_append_buffer(234, 123,
                                                               payload);
-  journal::AppendBuffer append_buffer2 = create_append_buffer("tag", 124,
+  journal::AppendBuffer append_buffer2 = create_append_buffer(234, 124,
                                                               payload);
   journal::AppendBuffers append_buffers;
   append_buffers = {append_buffer1, append_buffer2};
@@ -303,7 +302,7 @@ TEST_F(TestObjectRecorder, Overflow) {
   ASSERT_EQ(0, cond.wait());
   ASSERT_EQ(0U, object1->get_pending_appends());
 
-  journal::AppendBuffer append_buffer3 = create_append_buffer("bar", 123,
+  journal::AppendBuffer append_buffer3 = create_append_buffer(456, 123,
                                                               payload);
   append_buffers = {append_buffer3};
 
index 1007dded762a99af3bd9d9b08cb535cb6ae42f99..9c99129502e0fa57d73ecd2c603138e6e0854e0d 100644 (file)
@@ -91,7 +91,7 @@ struct MockJournaler {
 
   MOCK_METHOD3(start_append, void(int flush_interval, uint64_t flush_bytes,
                                   double flush_age));
-  MOCK_METHOD2(append, MockFutureProxy(const std::string &tag,
+  MOCK_METHOD2(append, MockFutureProxy(uint64_t tag_id,
                                        const bufferlist &bl));
   MOCK_METHOD1(flush, void(Context *on_safe));
   MOCK_METHOD1(stop_append, void(Context *on_safe));
@@ -145,8 +145,8 @@ struct MockJournalerProxy {
                                                flush_age);
   }
 
-  MockFutureProxy append(const std::string &tag, const bufferlist &bl) {
-    return MockJournaler::get_instance().append(tag, bl);
+  MockFutureProxy append(uint64_t tag_id, const bufferlist &bl) {
+    return MockJournaler::get_instance().append(tag_id, bl);
   }
 
   void flush(Context *on_safe) {
index 14d1453a50feae1418f5a8906342d44a291ff345..7b13fe3be384f9f5148f52de034cd1016ffeb611 100644 (file)
@@ -279,12 +279,12 @@ protected:
     int r = 0;
     while (true) {
       ::journal::ReplayEntry replay_entry;
-      std::string tag;
-      if (!m_journaler.try_pop_front(&replay_entry, &tag)) {
+      uint64_t tag_id;
+      if (!m_journaler.try_pop_front(&replay_entry, &tag_id)) {
        break;
       }
 
-      r = process_entry(replay_entry, tag);
+      r = process_entry(replay_entry, tag_id);
       if (r < 0) {
        break;
       }
@@ -292,7 +292,7 @@ protected:
   }
 
   virtual int process_entry(::journal::ReplayEntry replay_entry,
-                           std::string& tag) = 0;
+                           uint64_t tag_id) = 0;
 
   void handle_replay_complete(int r) {
     m_journaler.stop_replay();
@@ -354,10 +354,10 @@ private:
   };
 
   int process_entry(::journal::ReplayEntry replay_entry,
-                   std::string& tag) {
+                   uint64_t tag_id) {
     m_s.total++;
     if (m_verbose) {
-      std::cout << "Entry: tag=" << tag << ", commit_tid="
+      std::cout << "Entry: tag_id=" << tag_id << ", commit_tid="
                << replay_entry.get_commit_tid() << std::endl;
     }
     bufferlist data = replay_entry.get_data();
@@ -381,27 +381,27 @@ static int do_inspect_journal(librados::IoCtx& io_ctx,
 }
 
 struct ExportEntry {
-  std::string tag;
+  uint64_t tag_id;
   uint64_t commit_tid;
   int type;
   bufferlist entry;
 
-  ExportEntry() : tag(), commit_tid(0), type(0), entry() {}
+  ExportEntry() : tag_id(0), commit_tid(0), type(0), entry() {}
 
-  ExportEntry(const std::string& tag, uint64_t commit_tid, int type,
+  ExportEntry(uint64_t tag_id, uint64_t commit_tid, int type,
              const bufferlist& entry)
-    : tag(tag), commit_tid(commit_tid), type(type), entry(entry) {
+    : tag_id(tag_id), commit_tid(commit_tid), type(type), entry(entry) {
   }
 
   void dump(Formatter *f) const {
-    ::encode_json("tag", tag, f);
+    ::encode_json("tag_id", tag_id, f);
     ::encode_json("commit_tid", commit_tid, f);
     ::encode_json("type", type, f);
     ::encode_json("entry", entry, f);
   }
 
   void decode_json(JSONObj *obj) {
-    JSONDecoder::decode_json("tag", tag, obj);
+    JSONDecoder::decode_json("tag_id", tag_id, obj);
     JSONDecoder::decode_json("commit_tid", commit_tid, obj);
     JSONDecoder::decode_json("type", type, obj);
     JSONDecoder::decode_json("entry", entry, obj);
@@ -448,7 +448,7 @@ private:
   };
 
   int process_entry(::journal::ReplayEntry replay_entry,
-                   std::string& tag) {
+                   uint64_t tag_id) {
     m_s.total++;
     int type = -1;
     bufferlist entry = replay_entry.get_data();
@@ -461,7 +461,8 @@ private:
     } else {
       type = event_entry.get_event_type();
     }
-    ExportEntry export_entry(tag, replay_entry.get_commit_tid(), type, entry);
+    ExportEntry export_entry(tag_id, replay_entry.get_commit_tid(), type,
+                             entry);
     JSONFormatter f;
     ::encode_json("event_entry", export_entry, &f);
     std::ostringstream oss;
@@ -651,7 +652,7 @@ public:
       librbd::journal::EventEntry event_entry;
       r = inspect_entry(e.entry, event_entry, m_verbose);
       if (r < 0) {
-       std::cerr << "rbd: corrupted entry " << n << ": tag=" << e.tag
+       std::cerr << "rbd: corrupted entry " << n << ": tag_tid=" << e.tag_id
                  << ", commit_tid=" << e.commit_tid << std::endl;
        if (m_no_error) {
          r1 = r;
@@ -660,7 +661,7 @@ public:
          break;
        }
       }
-      m_journaler.append(e.tag, e.entry);
+      m_journaler.append(e.tag_id, e.entry);
       error_count--;
     }