summaryrefslogtreecommitdiffstats
path: root/src/mds/MDSPinger.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-21 11:54:28 +0000
commite6918187568dbd01842d8d1d2c808ce16a894239 (patch)
tree64f88b554b444a49f656b6c656111a145cbbaa28 /src/mds/MDSPinger.h
parentInitial commit. (diff)
downloadceph-b26c4052f3542036551aa9dec9caa4226e456195.tar.xz
ceph-b26c4052f3542036551aa9dec9caa4226e456195.zip
Adding upstream version 18.2.2.upstream/18.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/mds/MDSPinger.h')
-rw-r--r--src/mds/MDSPinger.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/mds/MDSPinger.h b/src/mds/MDSPinger.h
new file mode 100644
index 000000000..51c3ebeeb
--- /dev/null
+++ b/src/mds/MDSPinger.h
@@ -0,0 +1,61 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_MDS_PINGER_H
+#define CEPH_MDS_PINGER_H
+
+#include <map>
+
+#include "include/types.h"
+
+#include "msg/msg_types.h"
+#include "common/ceph_mutex.h"
+#include "common/ceph_time.h"
+#include "messages/MMDSPing.h"
+
+#include "mdstypes.h"
+
+class MDSRank;
+
+class MDSPinger {
+public:
+ MDSPinger(MDSRank *mds);
+
+ // send a ping message to an mds rank. initialize ping state if
+ // required.
+ void send_ping(mds_rank_t rank, const entity_addrvec_t &addr);
+
+ // check if a pong response is valid. a pong reponse from an
+ // mds is valid if at least one ping message was sent to the
+ // mds and the sequence number in the pong is outstanding.
+ bool pong_received(mds_rank_t rank, version_t seq);
+
+ // reset the ping state for a given rank
+ void reset_ping(mds_rank_t rank);
+
+ // check if a rank is lagging (based on pong response) responding
+ // to a ping message.
+ bool is_rank_lagging(mds_rank_t rank);
+
+private:
+ using clock = ceph::coarse_mono_clock;
+ using time = ceph::coarse_mono_time;
+
+ // Initial Sequence Number (ISN) of the first ping message sent
+ // by rank 0 to other active ranks (incuding itself).
+ static constexpr uint64_t MDS_PINGER_ISN = 1;
+
+ struct PingState {
+ version_t last_seq = MDS_PINGER_ISN;
+ std::map<version_t, time> seq_time_map;
+ time last_acked_time = clock::now();
+ };
+
+ MDSRank *mds;
+ // drop this lock when calling ->send_message_mds() else mds might
+ // deadlock
+ ceph::mutex lock = ceph::make_mutex("MDSPinger::lock");
+ std::map<mds_rank_t, PingState> ping_state_by_rank;
+};
+
+#endif // CEPH_MDS_PINGER_H