#include "events/ETableServer.h"
#include "common/debug.h"
+#include "messages/MMDSTableRequest.h"
+
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_mds
#undef dout_prefix
using namespace std;
+struct MDSTableServer::notify_info_t {
+ notify_info_t() {}
+ std::set<mds_rank_t> notify_ack_gather;
+ mds_rank_t mds;
+ ref_t<MMDSTableRequest> reply = NULL;
+ MDSContext *onfinish = nullptr;
+};
+
+MDSTableServer::MDSTableServer(MDSRank *m, int tab) :
+ MDSTable(m, get_mdstable_name(tab), false), table(tab) {}
+
+MDSTableServer::~MDSTableServer() = default;
+
+MDSTableServer::MDSTableServer(const MDSTableServer &) = default;
+MDSTableServer &MDSTableServer::operator=(const MDSTableServer &) = default;
+
+void MDSTableServer::_note_prepare(mds_rank_t mds, uint64_t reqid, bool replay) {
+ version++;
+ if (replay)
+ projected_version = version;
+ pending_for_mds[version].mds = mds;
+ pending_for_mds[version].reqid = reqid;
+ pending_for_mds[version].tid = version;
+}
+
+void MDSTableServer::_note_commit(uint64_t tid, bool replay) {
+ version++;
+ if (replay)
+ projected_version = version;
+ pending_for_mds.erase(tid);
+}
+
+void MDSTableServer::_note_rollback(uint64_t tid, bool replay) {
+ version++;
+ if (replay)
+ projected_version = version;
+ pending_for_mds.erase(tid);
+}
+
+void MDSTableServer::_note_server_update(bufferlist& bl, bool replay) {
+ version++;
+ if (replay)
+ projected_version = version;
+}
+
+void MDSTableServer::reset_state() {
+ pending_for_mds.clear();
+ ++version;
+}
+
void MDSTableServer::handle_request(const cref_t<MMDSTableRequest> &req)
{
ceph_assert(req->op >= 0);
recovered = true;
}
+void MDSTableServer::encode_state(bufferlist& bl) const {
+ encode_server_state(bl);
+ encode(pending_for_mds, bl);
+}
+
+void MDSTableServer::decode_state(bufferlist::const_iterator& bl) {
+ decode_server_state(bl);
+ decode(pending_for_mds, bl);
+}
+
void MDSTableServer::finish_recovery(set<mds_rank_t>& active)
{
dout(7) << __func__ << dendl;
#include "mdstypes.h" // for mds_table_pending_t
#include "mds_table_types.h" // for get_mdstable_name()
-#include "messages/MMDSTableRequest.h"
-
#include "common/ref.h" // for cref_t
class MDSContext;
+class MMDSTableRequest;
class MDSTableServer : public MDSTable {
public:
friend class C_ServerRecovery;
- MDSTableServer(MDSRank *m, int tab) :
- MDSTable(m, get_mdstable_name(tab), false), table(tab) {}
- ~MDSTableServer() override {}
+ MDSTableServer(MDSRank *m, int tab);
+ ~MDSTableServer();
+
+ // required by DencoderImplFeatureful::copy()
+ MDSTableServer(const MDSTableServer &);
+ MDSTableServer &operator=(const MDSTableServer &);
virtual void handle_query(const cref_t<MMDSTableRequest> &m) = 0;
virtual void _prepare(const bufferlist &bl, uint64_t reqid, mds_rank_t bymds, bufferlist& out) = 0;
virtual void _server_update(bufferlist& bl) { ceph_abort(); }
virtual bool _notify_prep(version_t tid) { return false; };
- void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false) {
- version++;
- if (replay)
- projected_version = version;
- pending_for_mds[version].mds = mds;
- pending_for_mds[version].reqid = reqid;
- pending_for_mds[version].tid = version;
- }
- void _note_commit(uint64_t tid, bool replay=false) {
- version++;
- if (replay)
- projected_version = version;
- pending_for_mds.erase(tid);
- }
- void _note_rollback(uint64_t tid, bool replay=false) {
- version++;
- if (replay)
- projected_version = version;
- pending_for_mds.erase(tid);
- }
- void _note_server_update(bufferlist& bl, bool replay=false) {
- version++;
- if (replay)
- projected_version = version;
- }
-
- void reset_state() override {
- pending_for_mds.clear();
- ++version;
- }
+ void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false);
+ void _note_commit(uint64_t tid, bool replay=false);
+ void _note_rollback(uint64_t tid, bool replay=false);
+ void _note_server_update(bufferlist& bl, bool replay=false);
+
+ void reset_state() override;
void handle_request(const cref_t<MMDSTableRequest> &m);
void do_server_update(bufferlist& bl);
virtual void encode_server_state(bufferlist& bl) const = 0;
virtual void decode_server_state(bufferlist::const_iterator& bl) = 0;
- void encode_state(bufferlist& bl) const override {
- encode_server_state(bl);
- encode(pending_for_mds, bl);
- }
- void decode_state(bufferlist::const_iterator& bl) override {
- decode_server_state(bl);
- decode(pending_for_mds, bl);
- }
+ void encode_state(bufferlist& bl) const override;
+ void decode_state(bufferlist::const_iterator& bl) override;
// recovery
void finish_recovery(std::set<mds_rank_t>& active);
bool recovered = false;
std::set<mds_rank_t> active_clients;
private:
- struct notify_info_t {
- notify_info_t() {}
- std::set<mds_rank_t> notify_ack_gather;
- mds_rank_t mds;
- ref_t<MMDSTableRequest> reply = NULL;
- MDSContext *onfinish = nullptr;
- };
+ struct notify_info_t;
friend class C_Prepare;
friend class C_Commit;