]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: allocate and associate op tids to maint op journal events
authorJason Dillaman <dillaman@redhat.com>
Wed, 16 Dec 2015 15:48:08 +0000 (10:48 -0500)
committerJason Dillaman <dillaman@redhat.com>
Fri, 15 Jan 2016 15:40:28 +0000 (10:40 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
16 files changed:
src/librbd/Journal.cc
src/librbd/Journal.h
src/librbd/journal/Entries.cc
src/librbd/journal/Entries.h
src/librbd/operation/FlattenRequest.h
src/librbd/operation/RenameRequest.h
src/librbd/operation/Request.cc
src/librbd/operation/Request.h
src/librbd/operation/ResizeRequest.h
src/librbd/operation/SnapshotCreateRequest.h
src/librbd/operation/SnapshotProtectRequest.h
src/librbd/operation/SnapshotRemoveRequest.h
src/librbd/operation/SnapshotRenameRequest.h
src/librbd/operation/SnapshotRollbackRequest.h
src/librbd/operation/SnapshotUnprotectRequest.h
src/test/librbd/mock/MockJournal.h

index 54d071c79ea50652950d5f565fd5aa54657b3f93..882d13ab8edfda227b2937ad4db53ef9def7e7e8 100644 (file)
@@ -13,8 +13,6 @@
 #include "journal/Journaler.h"
 #include "journal/ReplayEntry.h"
 #include "common/errno.h"
-#include <boost/utility/enable_if.hpp>
-#include <boost/type_traits/is_base_of.hpp>
 
 #define dout_subsys ceph_subsys_rbd
 #undef dout_prefix
@@ -29,27 +27,6 @@ namespace {
 
 const std::string CLIENT_DESCRIPTION = "master image";
 
-struct SetOpRequestTid : public boost::static_visitor<void> {
-  uint64_t tid;
-
-  SetOpRequestTid(uint64_t _tid) : tid(_tid) {
-  }
-
-  template <typename Event>
-  typename boost::enable_if<boost::is_base_of<journal::OpEventBase, Event>,
-                            void>::type
-  operator()(Event &event) const {
-    event.tid = tid;
-  }
-
-  template <typename Event>
-  typename boost::disable_if<boost::is_base_of<journal::OpEventBase, Event>,
-                            void>::type
-  operator()(Event &event) const {
-    assert(false);
-  }
-};
-
 template <typename ImageCtxT>
 struct C_ReplayCommitted : public Context {
   typedef journal::TypeTraits<ImageCtxT> TypeTraits;
@@ -401,37 +378,29 @@ void Journal<I>::commit_io_event_extent(uint64_t tid, uint64_t offset,
 }
 
 template <typename I>
-uint64_t Journal<I>::append_op_event(journal::EventEntry &event_entry) {
+void Journal<I>::append_op_event(uint64_t op_tid,
+                                 journal::EventEntry &event_entry) {
   assert(m_image_ctx.owner_lock.is_locked());
 
-  uint64_t tid;
+  bufferlist bl;
+  ::encode(event_entry, bl);
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
-
-    Mutex::Locker event_locker(m_event_lock);
-    tid = ++m_event_tid;
-    assert(tid != 0);
-
-    // inject the generated tid into the provided event entry
-    boost::apply_visitor(SetOpRequestTid(tid), event_entry.event);
-
-    bufferlist bl;
-    ::encode(event_entry, bl);
     m_journaler->committed(m_journaler->append("", bl));
   }
 
   CephContext *cct = m_image_ctx.cct;
   ldout(cct, 10) << this << " " << __func__ << ": "
-                 << "event=" << event_entry.get_event_type() << ", "
-                 << "tid=" << tid << dendl;
-  return tid;
+                 << "op_tid=" << op_tid << ", "
+                 << "event=" << event_entry.get_event_type() << dendl;
 }
 
 template <typename I>
 void Journal<I>::commit_op_event(uint64_t tid, int r) {
   CephContext *cct = m_image_ctx.cct;
-  ldout(cct, 10) << this << " " << __func__ << ": tid=" << tid << dendl;
+  ldout(cct, 10) << this << " " << __func__ << ": tid=" << tid << ", "
+                 << "r=" << r << dendl;
 
   journal::EventEntry event_entry((journal::OpFinishEvent(tid, r)));
 
@@ -441,7 +410,6 @@ void Journal<I>::commit_op_event(uint64_t tid, int r) {
   {
     Mutex::Locker locker(m_lock);
     assert(m_state == STATE_READY);
-
     m_journaler->committed(m_journaler->append("", bl));
   }
 }
index 934b947372b7799b70dc38f8355687cd6056252c..f81e1a2350247bc7d6bc1c9b2c58d7b2d85ed86d 100644 (file)
@@ -5,6 +5,7 @@
 #define CEPH_LIBRBD_JOURNAL_H
 
 #include "include/int_types.h"
+#include "include/atomic.h"
 #include "include/Context.h"
 #include "include/interval_set.h"
 #include "include/unordered_map.h"
@@ -120,12 +121,18 @@ public:
   void commit_io_event_extent(uint64_t tid, uint64_t offset, uint64_t length,
                               int r);
 
-  uint64_t append_op_event(journal::EventEntry &event_entry);
-  void commit_op_event(uint64_t tid, int r);
+  void append_op_event(uint64_t op_tid, journal::EventEntry &event_entry);
+  void commit_op_event(uint64_t op_tid, int r);
 
   void flush_event(uint64_t tid, Context *on_safe);
   void wait_event(uint64_t tid, Context *on_safe);
 
+  uint64_t allocate_op_tid() {
+    uint64_t op_tid = m_op_tid.inc();
+    assert(op_tid != 0);
+    return op_tid;
+  }
+
 private:
   ImageCtxT &m_image_ctx;
 
@@ -208,6 +215,8 @@ private:
   uint64_t m_event_tid;
   Events m_events;
 
+  atomic_t m_op_tid;
+
   bool m_blocking_writes;
 
   journal::Replay<ImageCtxT> *m_journal_replay;
index fb4106bcfdd0f4fb709f4cf428389705c5e415b4..be350afd58a230d38556c06dd72659eaef31becb 100644 (file)
@@ -106,29 +106,47 @@ void AioFlushEvent::dump(Formatter *f) const {
 }
 
 void OpEventBase::encode(bufferlist& bl) const {
-  ::encode(tid, bl);
+  ::encode(op_tid, bl);
 }
 
 void OpEventBase::decode(__u8 version, bufferlist::iterator& it) {
-  ::decode(tid, it);
+  ::decode(op_tid, it);
 }
 
 void OpEventBase::dump(Formatter *f) const {
-  f->dump_unsigned("tid", tid);
+  f->dump_unsigned("op_tid", op_tid);
+}
+
+void OpFinishEvent::encode(bufferlist& bl) const {
+  OpEventBase::encode(bl);
+  ::encode(op_tid, bl);
+  ::encode(r, bl);
+}
+
+void OpFinishEvent::decode(__u8 version, bufferlist::iterator& it) {
+  OpEventBase::decode(version, it);
+  ::decode(op_tid, it);
+  ::decode(r, it);
+}
+
+void OpFinishEvent::dump(Formatter *f) const {
+  OpEventBase::dump(f);
+  f->dump_unsigned("op_tid", op_tid);
+  f->dump_int("result", r);
 }
 
 void SnapEventBase::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(snap_name, bl);
 }
 
 void SnapEventBase::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(snap_name, it);
 }
 
 void SnapEventBase::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_string("snap_name", snap_name);
 }
 
@@ -143,38 +161,38 @@ void SnapRenameEvent::decode(__u8 version, bufferlist::iterator& it) {
 }
 
 void SnapRenameEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  SnapEventBase::dump(f);
   f->dump_unsigned("src_snap_id", snap_id);
   f->dump_string("dest_snap_name", snap_name);
 }
 
 void RenameEvent::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(image_name, bl);
 }
 
 void RenameEvent::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(image_name, it);
 }
 
 void RenameEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_string("image_name", image_name);
 }
 
 void ResizeEvent::encode(bufferlist& bl) const {
-  OpStartEventBase::encode(bl);
+  OpEventBase::encode(bl);
   ::encode(size, bl);
 }
 
 void ResizeEvent::decode(__u8 version, bufferlist::iterator& it) {
-  OpStartEventBase::decode(version, it);
+  OpEventBase::decode(version, it);
   ::decode(size, it);
 }
 
 void ResizeEvent::dump(Formatter *f) const {
-  OpStartEventBase::dump(f);
+  OpEventBase::dump(f);
   f->dump_unsigned("size", size);
 }
 
@@ -278,24 +296,24 @@ void EventEntry::generate_test_instances(std::list<EventEntry *> &o) {
   o.push_back(new EventEntry(SnapRemoveEvent(345, "snap")));
 
   o.push_back(new EventEntry(SnapRenameEvent()));
-  o.push_back(new EventEntry(SnapRenameEvent(345, 1, "snap")));
+  o.push_back(new EventEntry(SnapRenameEvent(456, 1, "snap")));
 
   o.push_back(new EventEntry(SnapProtectEvent()));
-  o.push_back(new EventEntry(SnapProtectEvent(456, "snap")));
+  o.push_back(new EventEntry(SnapProtectEvent(567, "snap")));
 
   o.push_back(new EventEntry(SnapUnprotectEvent()));
-  o.push_back(new EventEntry(SnapUnprotectEvent(567, "snap")));
+  o.push_back(new EventEntry(SnapUnprotectEvent(678, "snap")));
 
   o.push_back(new EventEntry(SnapRollbackEvent()));
-  o.push_back(new EventEntry(SnapRollbackEvent(678, "snap")));
+  o.push_back(new EventEntry(SnapRollbackEvent(789, "snap")));
 
   o.push_back(new EventEntry(RenameEvent()));
-  o.push_back(new EventEntry(RenameEvent(789, "image name")));
+  o.push_back(new EventEntry(RenameEvent(890, "image name")));
 
   o.push_back(new EventEntry(ResizeEvent()));
-  o.push_back(new EventEntry(ResizeEvent(890, 1234)));
+  o.push_back(new EventEntry(ResizeEvent(901, 1234)));
 
-  o.push_back(new EventEntry(FlattenEvent(901)));
+  o.push_back(new EventEntry(FlattenEvent(123)));
 }
 
 } // namespace journal
index 089644e774317dcf76a50faa86d82ef84a457523..09218be749749b609f8f20288e347bf12bdc1be3 100644 (file)
@@ -78,26 +78,17 @@ struct AioFlushEvent {
 };
 
 struct OpEventBase {
-  uint64_t tid;
-
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  uint64_t op_tid;
 
 protected:
-  OpEventBase() : tid(0) {
+  OpEventBase() : op_tid(0) {
   }
-  OpEventBase(uint64_t _tid) : tid(_tid) {
+  OpEventBase(uint64_t op_tid) : op_tid(op_tid) {
   }
-  virtual ~OpEventBase() {}
-};
 
-struct OpStartEventBase : public OpEventBase {
-protected:
-  OpStartEventBase() {
-  }
-  OpStartEventBase(uint64_t tid) : OpEventBase(tid) {
-  }
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct OpFinishEvent : public OpEventBase {
@@ -107,22 +98,27 @@ struct OpFinishEvent : public OpEventBase {
 
   OpFinishEvent() : r(0) {
   }
-  OpFinishEvent(uint64_t tid, int _r) : OpEventBase(tid), r(_r) {
+  OpFinishEvent(uint64_t op_tid, int r) : OpEventBase(op_tid), r(r) {
   }
+
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct SnapEventBase : public OpStartEventBase {
+struct SnapEventBase : public OpEventBase {
   std::string snap_name;
 
+protected:
   SnapEventBase() {
   }
-  SnapEventBase(uint64_t tid, const std::string &_snap_name)
-    : OpStartEventBase(tid), snap_name(_snap_name) {
+  SnapEventBase(uint64_t op_tid, const std::string &_snap_name)
+    : OpEventBase(op_tid), snap_name(_snap_name) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct SnapCreateEvent : public SnapEventBase {
@@ -130,9 +126,13 @@ struct SnapCreateEvent : public SnapEventBase {
 
   SnapCreateEvent() {
   }
-  SnapCreateEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapCreateEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRemoveEvent : public SnapEventBase {
@@ -140,9 +140,13 @@ struct SnapRemoveEvent : public SnapEventBase {
 
   SnapRemoveEvent() {
   }
-  SnapRemoveEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapRemoveEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRenameEvent : public SnapEventBase {
@@ -152,14 +156,14 @@ struct SnapRenameEvent : public SnapEventBase {
 
   SnapRenameEvent() : snap_id(CEPH_NOSNAP) {
   }
-  SnapRenameEvent(uint64_t tid, uint64_t src_snap_id,
+  SnapRenameEvent(uint64_t op_tid, uint64_t src_snap_id,
                   const std::string &dest_snap_name)
-    : SnapEventBase(tid, dest_snap_name), snap_id(src_snap_id) {
+    : SnapEventBase(op_tid, dest_snap_name), snap_id(src_snap_id) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
 struct SnapProtectEvent : public SnapEventBase {
@@ -167,9 +171,13 @@ struct SnapProtectEvent : public SnapEventBase {
 
   SnapProtectEvent() {
   }
-  SnapProtectEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapProtectEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapUnprotectEvent : public SnapEventBase {
@@ -177,9 +185,13 @@ struct SnapUnprotectEvent : public SnapEventBase {
 
   SnapUnprotectEvent() {
   }
-  SnapUnprotectEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapUnprotectEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
 struct SnapRollbackEvent : public SnapEventBase {
@@ -187,50 +199,58 @@ struct SnapRollbackEvent : public SnapEventBase {
 
   SnapRollbackEvent() {
   }
-  SnapRollbackEvent(uint64_t tid, const std::string &snap_name)
-    : SnapEventBase(tid, snap_name) {
+  SnapRollbackEvent(uint64_t op_tid, const std::string &snap_name)
+    : SnapEventBase(op_tid, snap_name) {
   }
+
+  using SnapEventBase::encode;
+  using SnapEventBase::decode;
+  using SnapEventBase::dump;
 };
 
-struct RenameEvent : public OpStartEventBase {
+struct RenameEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_RENAME;
 
   std::string image_name;
 
   RenameEvent() {
   }
-  RenameEvent(uint64_t tid, const std::string &_image_name)
-    : OpStartEventBase(tid), image_name(_image_name) {
+  RenameEvent(uint64_t op_tid, const std::string &_image_name)
+    : OpEventBase(op_tid), image_name(_image_name) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct ResizeEvent : public OpStartEventBase {
+struct ResizeEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_RESIZE;
 
   uint64_t size;
 
   ResizeEvent() : size(0) {
   }
-  ResizeEvent(uint64_t tid, uint64_t _size)
-    : OpStartEventBase(tid), size(_size) {
+  ResizeEvent(uint64_t op_tid, uint64_t _size)
+    : OpEventBase(op_tid), size(_size) {
   }
 
-  virtual void encode(bufferlist& bl) const;
-  virtual void decode(__u8 version, bufferlist::iterator& it);
-  virtual void dump(Formatter *f) const;
+  void encode(bufferlist& bl) const;
+  void decode(__u8 version, bufferlist::iterator& it);
+  void dump(Formatter *f) const;
 };
 
-struct FlattenEvent : public OpStartEventBase {
+struct FlattenEvent : public OpEventBase {
   static const EventType EVENT_TYPE = EVENT_TYPE_FLATTEN;
 
   FlattenEvent() {
   }
-  FlattenEvent(uint64_t tid) : OpStartEventBase(tid) {
+  FlattenEvent(uint64_t op_tid) : OpEventBase(op_tid) {
   }
+
+  using OpEventBase::encode;
+  using OpEventBase::decode;
+  using OpEventBase::dump;
 };
 
 struct UnknownEvent {
index 693b051e14cf8f05bf342ad7cf503139176c2f9d..55e33f40e7881d1a51de48710532afe0d06815bf 100644 (file)
@@ -31,8 +31,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::FlattenEvent(0);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::FlattenEvent(op_tid);
   }
 
 private:
index 474ce5004bef689e37d719781bb00429f3f76d8a..6b47d0781a876949d2a0c82a1ca3b4fce05a7805 100644 (file)
@@ -59,8 +59,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::RenameEvent(0, m_dest_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::RenameEvent(op_tid, m_dest_name);
   }
 
 private:
index 6a96d85687ccc59b65382dcba774eb4f34ef1909..e751360838e0cd03c4d7dc74d425ce0443c3b533 100644 (file)
@@ -10,7 +10,7 @@ namespace operation {
 
 template <typename I>
 Request<I>::Request(I &image_ctx, Context *on_finish)
-  : AsyncRequest<I>(image_ctx, on_finish), m_tid(0) {
+  : AsyncRequest<I>(image_ctx, on_finish) {
 }
 
 template <typename I>
@@ -29,8 +29,9 @@ void Request<I>::send() {
         return;
       }
 
-      journal::EventEntry event_entry(create_event());
-      m_tid = image_ctx.journal->append_op_event(event_entry);
+      m_op_tid = image_ctx.journal->allocate_op_tid();
+      journal::EventEntry event_entry(create_event(m_op_tid));
+      image_ctx.journal->append_op_event(m_op_tid, event_entry);
     }
   }
 
@@ -42,12 +43,12 @@ void Request<I>::finish(int r) {
   {
     I &image_ctx = this->m_image_ctx;
     RWLock::RLocker snap_locker(image_ctx.snap_lock);
-    if (m_tid != 0 && image_ctx.journal != NULL &&
+    if (m_op_tid != 0 && image_ctx.journal != NULL &&
         !image_ctx.journal->is_journal_replaying()) {
       // ops will be canceled / completed before closing journal
       assert(image_ctx.journal->is_journal_ready());
 
-      image_ctx.journal->commit_op_event(m_tid, r);
+      image_ctx.journal->commit_op_event(m_op_tid, r);
     }
   }
 
index 68b22db746e85553963b564016d0515f5cd4b359..9432b26f0f4b5e78dfb04dda75e9672fdb81c4fa 100644 (file)
@@ -25,7 +25,7 @@ protected:
   virtual void finish(int r);
   virtual void send_op() = 0;
 
-  virtual journal::Event create_event() const = 0;
+  virtual journal::Event create_event(uint64_t op_tid) const = 0;
 
 private:
   struct C_WaitForJournalReady : public Context {
@@ -39,7 +39,7 @@ private:
     }
   };
 
-  uint64_t m_tid;
+  uint64_t m_op_tid = 0;
 
   void handle_journal_ready();
 };
index dc36ae399a3682ebda90ede79c5185605093432c..0ec1fe018621be2d8a610949902c7edc8d4d11da 100644 (file)
@@ -35,8 +35,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::ResizeEvent(0, m_new_size);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::ResizeEvent(op_tid, m_new_size);
   }
 
 private:
index 249bcafbc2e577a3924515e1eb7637dfce946ec7..abe5556c1c7d2caeb68e69e341003cdc7f598b11 100644 (file)
@@ -79,8 +79,8 @@ protected:
     return r;
   }
 
-  virtual journal::Event create_event() const {
-    return journal::SnapCreateEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapCreateEvent(op_tid, m_snap_name);
   }
 
 private:
index 02484e98e74281c4e09c56f748912c2f258ac37d..e8abfb27eb9150994cc5e86be5b09555437f09b0 100644 (file)
@@ -46,8 +46,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapProtectEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapProtectEvent(op_tid, m_snap_name);
   }
 
 private:
index 48e14ae74f837512ce0a4fbeb79a5e08dd536c41..39123ff8ee8775aa92cb587d01e23dd9d0a898f3 100644 (file)
@@ -63,8 +63,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRemoveEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRemoveEvent(op_tid, m_snap_name);
   }
 
 private:
index 19a72c75a50ae8f9f4074ddeb201eca2269ff2f0..503058d0b37adc066006a913e077759453ba0726 100644 (file)
@@ -42,8 +42,8 @@ public:
   SnapshotRenameRequest(ImageCtxT &image_ctx, Context *on_finish,
                         uint64_t snap_id, const std::string &snap_name);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRenameEvent(0, m_snap_id, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRenameEvent(op_tid, m_snap_id, m_snap_name);
   }
 
 protected:
index 54dd742a3da6d2f294e78135ca387b161ea02aab..5c6589a9317feade80e6c1c5d64ed7edc239af1d 100644 (file)
@@ -69,8 +69,8 @@ protected:
   virtual void send_op();
   virtual bool should_complete(int r);
 
-  virtual journal::Event create_event() const {
-    return journal::SnapRollbackEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapRollbackEvent(op_tid, m_snap_name);
   }
 
 private:
index 3b940c3acb4e55c59abfeaad3d65ee47a8fdc080..62467f25b266222c7d7f34c8d7ebdd0ab1156969 100644 (file)
@@ -64,8 +64,8 @@ protected:
     return 0;
   }
 
-  virtual journal::Event create_event() const {
-    return journal::SnapUnprotectEvent(0, m_snap_name);
+  virtual journal::Event create_event(uint64_t op_tid) const {
+    return journal::SnapUnprotectEvent(op_tid, m_snap_name);
   }
 
 private:
index f20acd353b43ad062d1285f87f114ecf558963ea..a8e077af361f67f910e7a4968612610ee1676895 100644 (file)
@@ -19,7 +19,8 @@ struct MockJournal {
   MOCK_METHOD1(open, void(Context *));
   MOCK_METHOD1(close, void(Context *));
 
-  MOCK_METHOD1(append_op_event, uint64_t(journal::EventEntry&));
+  MOCK_METHOD0(allocate_op_tid, uint64_t());
+  MOCK_METHOD2(append_op_event, void(uint64_t, journal::EventEntry&));
   MOCK_METHOD2(commit_op_event, void(uint64_t, int));
 };