From: Sage Weil Date: Fri, 31 May 2019 21:32:44 +0000 (-0500) Subject: mds/SnapServer: handle MRemoveSnaps acks from mon X-Git-Tag: v15.1.0~2308^2~40 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ab405ab56036ad44f79e36f65031585a86b1e967;p=ceph.git mds/SnapServer: handle MRemoveSnaps acks from mon Signed-off-by: Sage Weil --- diff --git a/src/mds/MDSDaemon.cc b/src/mds/MDSDaemon.cc index cbcb3ca301f8..6d3cad07b859 100644 --- a/src/mds/MDSDaemon.cc +++ b/src/mds/MDSDaemon.cc @@ -1179,6 +1179,11 @@ bool MDSDaemon::handle_core_message(const cref_t &m) handle_mds_map(ref_cast(m)); break; + case MSG_REMOVE_SNAPS: + ALLOW_MESSAGES_FROM(CEPH_ENTITY_TYPE_MON); + mds_rank->snapserver->handle_remove_snaps(ref_cast(m)); + break; + // OSD case MSG_COMMAND: handle_command(ref_cast(m)); diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index 74b3d02e5ccd..78b41bd61211 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -360,6 +360,36 @@ void SnapServer::check_osd_map(bool force) last_checked_osdmap = version; } +void SnapServer::handle_remove_snaps(const cref_t &m) +{ + dout(10) << __func__ << " " << *m << dendl; + + map > 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 { diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index a0bc6adc6b1c..8ea168802bb3 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -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 &m) override; +public: + void handle_remove_snaps(const cref_t &m); + public: SnapServer(MDSRank *m, MonClient *monc) : MDSTableServer(m, TABLE_SNAP), mon_client(monc), last_checked_osdmap(0) {}