From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/mds/MDSTableClient.h | 99 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/mds/MDSTableClient.h (limited to 'src/mds/MDSTableClient.h') diff --git a/src/mds/MDSTableClient.h b/src/mds/MDSTableClient.h new file mode 100644 index 000000000..2952ec406 --- /dev/null +++ b/src/mds/MDSTableClient.h @@ -0,0 +1,99 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2004-2006 Sage Weil + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + * + */ + +#ifndef CEPH_MDSTABLECLIENT_H +#define CEPH_MDSTABLECLIENT_H + +#include "include/types.h" +#include "MDSContext.h" +#include "mds_table_types.h" + +#include "messages/MMDSTableRequest.h" + +class MDSRank; +class LogSegment; + +class MDSTableClient { +public: + MDSTableClient(MDSRank *m, int tab) : + mds(m), table(tab) {} + virtual ~MDSTableClient() {} + + void handle_request(const cref_t &m); + + void _prepare(bufferlist& mutation, version_t *ptid, bufferlist *pbl, MDSContext *onfinish); + void commit(version_t tid, LogSegment *ls); + + void resend_commits(); + void resend_prepares(); + + // for recovery (by me) + void got_journaled_agree(version_t tid, LogSegment *ls); + void got_journaled_ack(version_t tid); + + bool has_committed(version_t tid) const { + return pending_commit.count(tid) == 0; + } + void wait_for_ack(version_t tid, MDSContext *c) { + ack_waiters[tid].push_back(c); + } + + set get_journaled_tids() const { + set tids; + for (auto p : pending_commit) + tids.insert(p.first); + return tids; + } + + void handle_mds_failure(mds_rank_t mds); + + // child must implement + virtual void resend_queries() = 0; + virtual void handle_query_result(const cref_t &m) = 0; + virtual void handle_notify_prep(const cref_t &m) = 0; + virtual void notify_commit(version_t tid) = 0; +protected: + // prepares + struct _pending_prepare { + _pending_prepare() {} + _pending_prepare(MDSContext *c, version_t *pt, bufferlist *pb, bufferlist& m) : + onfinish(c), ptid(pt), pbl(pb), mutation(m) {} + + MDSContext *onfinish = nullptr; + version_t *ptid = nullptr; + bufferlist *pbl = nullptr; + bufferlist mutation; + }; + + friend class C_LoggedAck; + + void handle_reply(class MMDSTableQuery *m); + void _logged_ack(version_t tid); + + MDSRank *mds; + int table; + + uint64_t last_reqid = ~0ULL; + + bool server_ready = false; + + map pending_prepare; + map prepared_update; + list<_pending_prepare> waiting_for_reqid; + + // pending commits + map pending_commit; + map ack_waiters; +}; +#endif -- cgit v1.2.3