From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/mds/MDSPinger.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 src/mds/MDSPinger.h (limited to 'src/mds/MDSPinger.h') 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 + +#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 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 ping_state_by_rank; +}; + +#endif // CEPH_MDS_PINGER_H -- cgit v1.2.3