]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd-mirror: attempt to re-acquire leader lock if watcher recovered 22667/head
authorJason Dillaman <dillaman@redhat.com>
Thu, 31 May 2018 18:09:30 +0000 (14:09 -0400)
committerPrashant D <pdhange@redhat.com>
Thu, 21 Jun 2018 11:10:34 +0000 (07:10 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
(cherry picked from commit 69645f5433ce48281d3c6b70d979356c7ede2f88)

src/test/rbd_mirror/test_mock_LeaderWatcher.cc
src/tools/rbd_mirror/LeaderWatcher.cc
src/tools/rbd_mirror/LeaderWatcher.h

index 85c9c3c785c0dbded57c90922f3c1100bb1a51dc..0ece2c080aa9e16b28adc123490e4b1e92fa5be1 100644 (file)
@@ -42,6 +42,7 @@ struct MockManagedLock {
   MOCK_METHOD1(shut_down, void(Context *));
   MOCK_METHOD1(try_acquire_lock, void(Context *));
   MOCK_METHOD1(release_lock, void(Context *));
+  MOCK_METHOD0(reacquire_lock, void());
   MOCK_METHOD3(break_lock, void(const managed_lock::Locker &, bool, Context *));
   MOCK_METHOD2(get_locker, void(managed_lock::Locker *, Context *));
 
@@ -126,6 +127,10 @@ struct ManagedLock<MockTestImageCtx> {
     m_work_queue->queue(pre_release_ctx, 0);
   }
 
+  void reacquire_lock() {
+    MockManagedLock::get_instance().reacquire_lock();
+  }
+
   void get_locker(managed_lock::Locker *locker, Context *on_finish) {
     MockManagedLock::get_instance().get_locker(locker, on_finish);
   }
index 8f0c2c9654c7cac03b2a3e305daa34f42f160c5a..c3ebc28b54e6ac00ca1bcf035802c007bf74b085 100644 (file)
@@ -1086,6 +1086,13 @@ void LeaderWatcher<I>::handle_notify(uint64_t notify_id, uint64_t handle,
   apply_visitor(HandlePayloadVisitor(this, ctx), notify_message.payload);
 }
 
+template <typename I>
+void LeaderWatcher<I>::handle_rewatch_complete(int r) {
+  dout(5) << "r=" << r << dendl;
+
+  m_leader_lock->reacquire_lock();
+}
+
 template <typename I>
 void LeaderWatcher<I>::handle_payload(const HeartbeatPayload &payload,
                                       Context *on_notify_ack) {
index 14571357c093d9c494a5d3ba8d8122d5cc2856e5..8b37db0ee066129618be0095ed67d02872c3be08 100644 (file)
@@ -295,6 +295,8 @@ private:
   void handle_notify(uint64_t notify_id, uint64_t handle,
                      uint64_t notifier_id, bufferlist &bl) override;
 
+  void handle_rewatch_complete(int r) override;
+
   void handle_heartbeat(Context *on_ack);
   void handle_lock_acquired(Context *on_ack);
   void handle_lock_released(Context *on_ack);