]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/SnapServer: handle MRemoveSnaps acks from mon
authorSage Weil <sage@redhat.com>
Fri, 31 May 2019 21:32:44 +0000 (16:32 -0500)
committerSage Weil <sage@redhat.com>
Tue, 2 Jul 2019 13:37:49 +0000 (08:37 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/MDSDaemon.cc
src/mds/SnapServer.cc
src/mds/SnapServer.h

index cbcb3ca301f88ef943931bdd74335ac75bd86705..6d3cad07b859d1861c878680ecd2d3ceb2252313 100644 (file)
@@ -1179,6 +1179,11 @@ bool MDSDaemon::handle_core_message(const cref_t<Message> &m)
     handle_mds_map(ref_cast<MMDSMap>(m));
     break;
 
+  case MSG_REMOVE_SNAPS:
+    ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON);
+    mds_rank->snapserver->handle_remove_snaps(ref_cast<MRemoveSnaps>(m));
+    break;
+
     // OSD
   case MSG_COMMAND:
     handle_command(ref_cast<MCommand>(m));
index 74b3d02e5ccd9e5ce50a801ad9097a000f5ae62b..78b41bd61211ba59182a102fe4ddbe972f07343c 100644 (file)
@@ -360,6 +360,36 @@ void SnapServer::check_osd_map(bool force)
   last_checked_osdmap = version;
 }
 
+void SnapServer::handle_remove_snaps(const cref_t<MRemoveSnaps> &m)
+{
+  dout(10) << __func__ << " " << *m << dendl;
+
+  map<int32_t, vector<snapid_t> > all_purged;
+  int num = 0;
+
+  for (const auto& [id, snaps] : need_to_purge) {
+    auto i = m->snaps.find(id);
+    if (i == m->snaps.end()) {
+      continue;
+    }
+    for (const auto& q : snaps) {
+      if (std::find(i->second.begin(), i->second.end(), q) != i->second.end()) {
+       dout(10) << " mon reports " << q << " is removed" << dendl;
+       all_purged[id].push_back(q);
+       ++num;
+      }
+    }
+  }
+
+  dout(10) << __func__ << " " << num << " now removed" << dendl;
+  if (num) {
+    bufferlist bl;
+    using ceph::encode;
+    encode(all_purged, bl);
+    do_server_update(bl);
+  }
+}
+
 
 void SnapServer::dump(Formatter *f) const
 {
index a0bc6adc6b1cfa370c20dfca2edfd226fe4305b7..8ea168802bb311f97df527a00ade6a25b91741a7 100644 (file)
@@ -18,6 +18,8 @@
 #include "MDSTableServer.h"
 #include "snap.h"
 
+#include "messages/MRemoveSnaps.h"
+
 class MDSRank;
 class MonClient;
 
@@ -91,6 +93,9 @@ protected:
   bool _notify_prep(version_t tid) override;
   void handle_query(const cref_t<MMDSTableRequest> &m) override;
 
+public:
+  void handle_remove_snaps(const cref_t<MRemoveSnaps> &m);
+
 public:
   SnapServer(MDSRank *m, MonClient *monc)
     : MDSTableServer(m, TABLE_SNAP), mon_client(monc), last_checked_osdmap(0) {}