]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephfs-mirror: handle blocklist errors during rewatch
authorVenky Shankar <vshankar@redhat.com>
Wed, 16 Sep 2020 07:31:18 +0000 (03:31 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 24 Sep 2020 12:18:11 +0000 (08:18 -0400)
Signed-off-by: Venky Shankar <vshankar@redhat.com>
src/common/options.cc
src/tools/cephfs_mirror/FSMirror.cc
src/tools/cephfs_mirror/FSMirror.h
src/tools/cephfs_mirror/InstanceWatcher.cc
src/tools/cephfs_mirror/InstanceWatcher.h
src/tools/cephfs_mirror/MirrorWatcher.cc
src/tools/cephfs_mirror/MirrorWatcher.h

index e2ca57afbf145398134fb30be13c30b1a30d72fd..59cb7a8db6821046d4b7f5df209437fae09fc480 100644 (file)
@@ -8785,6 +8785,12 @@ std::vector<Option> get_cephfs_mirror_options() {
     .set_description("")
     .set_long_description(""),
 
+    Option("cephfs_mirror_restart_mirror_on_blocklist_interval", Option::TYPE_SECS, Option::LEVEL_ADVANCED)
+    .set_default(30)
+    .set_min(0)
+    .set_description("")
+    .set_long_description(""),
+
     });
 }
 
index c865d943c5c1dcba9cbf33b172a7e507d6ec22e4..9446c9f8f66140c39be968586fd041aa55179590 100644 (file)
@@ -423,6 +423,8 @@ void FSMirror::mirror_status(Formatter *f) {
   f->open_object_section("status");
   if (m_init_failed) {
     f->dump_string("state", "failed");
+  } else if (is_blocklisted(locker)) {
+    f->dump_string("state", "blocklisted");
   } else {
     f->open_object_section("peers");
     for ([[maybe_unused]] auto &[peer, peer_replayer] : m_peer_replayers) {
index cef0e57d7d867d6b675eea4ab16fe14d044a23e0..4cabf33e16d0eb0e22ba6c4d514789df5201718f 100644 (file)
@@ -42,10 +42,27 @@ public:
     return m_init_failed;
   }
 
+  bool is_blocklisted() {
+    std::scoped_lock locker(m_lock);
+    return is_blocklisted(locker);
+  }
+
   // admin socket helpers
   void mirror_status(Formatter *f);
 
 private:
+  bool is_blocklisted(const std::scoped_lock<ceph::mutex> &locker) const {
+    bool blocklisted = false;
+    if (m_instance_watcher) {
+      blocklisted = m_instance_watcher->is_blocklisted();
+    }
+    if (m_mirror_watcher) {
+      blocklisted |= m_mirror_watcher->is_blocklisted();
+    }
+
+    return blocklisted;
+  }
+
   struct SnapListener : public InstanceWatcher::Listener {
     FSMirror *fs_mirror;
 
index 393372f9904da553e2f24585b3f6e26c4331bddc..5775e572082cb85319918d36675e7436f78159be 100644 (file)
@@ -108,7 +108,17 @@ void InstanceWatcher::handle_notify(uint64_t notify_id, uint64_t handle,
 }
 
 void InstanceWatcher::handle_rewatch_complete(int r) {
-  dout(20) << ": r=" << r << dendl;
+  dout(5) << ": r=" << r << dendl;
+
+  if (r == -EBLOCKLISTED) {
+    dout(0) << ": client blocklisted" <<dendl;
+    std::scoped_lock locker(m_lock);
+    m_blocklisted = true;
+  } else if (r == -ENOENT) {
+    derr << ": mirroring object deleted" << dendl;
+  } else if (r < 0) {
+    derr << ": rewatch error: " << cpp_strerror(r) << dendl;
+  }
 }
 
 void InstanceWatcher::create_instance() {
index 72da8044edd3a1676dc603ebb5de4c356a7e07d0..8d12ce9344468413ba714daa4de9fcd7956860b2 100644 (file)
@@ -44,6 +44,11 @@ public:
                      uint64_t notifier_id, bufferlist& bl) override;
   void handle_rewatch_complete(int r) override;
 
+  bool is_blocklisted() {
+    std::scoped_lock locker(m_lock);
+    return m_blocklisted;
+  }
+
 private:
   librados::IoCtx &m_ioctx;
   Listener &m_listener;
@@ -53,6 +58,8 @@ private:
   Context *m_on_init_finish = nullptr;
   Context *m_on_shutdown_finish = nullptr;
 
+  bool m_blocklisted = false;
+
   void create_instance();
   void handle_create_instance(int r);
 
index 7aeaa4c07161d14465a6eab7f7fc2f0b16050027..4c4ffc0292affaaa355c41011b2d6003caed34af 100644 (file)
@@ -83,6 +83,20 @@ void MirrorWatcher::handle_notify(uint64_t notify_id, uint64_t handle,
   acknowledge_notify(notify_id, handle, outbl);
 }
 
+void MirrorWatcher::handle_rewatch_complete(int r) {
+  dout(5) << ": r=" << r << dendl;
+
+  if (r == -EBLOCKLISTED) {
+    dout(0) << ": client blocklisted" <<dendl;
+    std::scoped_lock locker(m_lock);
+    m_blocklisted = true;
+  } else if (r == -ENOENT) {
+    derr << ": mirroring object deleted" << dendl;
+  } else if (r < 0) {
+    derr << ": rewatch error: " << cpp_strerror(r) << dendl;
+  }
+}
+
 void MirrorWatcher::register_watcher() {
   dout(20) << dendl;
 
index d223e9f748c52621120d288c3ed1bdefc7c88508..ef427a8bb782ab230abd07310be3cccb44485516 100644 (file)
@@ -38,6 +38,12 @@ public:
 
   void handle_notify(uint64_t notify_id, uint64_t handle,
                      uint64_t notifier_id, bufferlist& bl) override;
+  void handle_rewatch_complete(int r) override;
+
+  bool is_blocklisted() {
+    std::scoped_lock locker(m_lock);
+    return m_blocklisted;
+  }
 
 private:
   librados::IoCtx &m_ioctx;
@@ -50,6 +56,8 @@ private:
   Context *m_on_init_finish = nullptr;
   Context *m_on_shutdown_finish = nullptr;
 
+  bool m_blocklisted = false;
+
   void register_watcher();
   void handle_register_watcher(int r);