Skip to content

Commit 8c47f85

Browse files
committed
mds/MDSTableServer: forward-declare MMDSTableRequest
Signed-off-by: Max Kellermann <[email protected]>
1 parent d711d68 commit 8c47f85

File tree

2 files changed

+78
-50
lines changed

2 files changed

+78
-50
lines changed

src/mds/MDSTableServer.cc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,65 @@
2121
#include "events/ETableServer.h"
2222
#include "common/debug.h"
2323

24+
#include "messages/MMDSTableRequest.h"
25+
2426
#define dout_context g_ceph_context
2527
#define dout_subsys ceph_subsys_mds
2628
#undef dout_prefix
2729
#define dout_prefix *_dout << "mds." << rank << ".tableserver(" << get_mdstable_name(table) << ") "
2830

2931
using namespace std;
3032

33+
struct MDSTableServer::notify_info_t {
34+
notify_info_t() {}
35+
std::set<mds_rank_t> notify_ack_gather;
36+
mds_rank_t mds;
37+
ref_t<MMDSTableRequest> reply = NULL;
38+
MDSContext *onfinish = nullptr;
39+
};
40+
41+
MDSTableServer::MDSTableServer(MDSRank *m, int tab) :
42+
MDSTable(m, get_mdstable_name(tab), false), table(tab) {}
43+
44+
MDSTableServer::~MDSTableServer() = default;
45+
46+
MDSTableServer::MDSTableServer(const MDSTableServer &) = default;
47+
MDSTableServer &MDSTableServer::operator=(const MDSTableServer &) = default;
48+
49+
void MDSTableServer::_note_prepare(mds_rank_t mds, uint64_t reqid, bool replay) {
50+
version++;
51+
if (replay)
52+
projected_version = version;
53+
pending_for_mds[version].mds = mds;
54+
pending_for_mds[version].reqid = reqid;
55+
pending_for_mds[version].tid = version;
56+
}
57+
58+
void MDSTableServer::_note_commit(uint64_t tid, bool replay) {
59+
version++;
60+
if (replay)
61+
projected_version = version;
62+
pending_for_mds.erase(tid);
63+
}
64+
65+
void MDSTableServer::_note_rollback(uint64_t tid, bool replay) {
66+
version++;
67+
if (replay)
68+
projected_version = version;
69+
pending_for_mds.erase(tid);
70+
}
71+
72+
void MDSTableServer::_note_server_update(bufferlist& bl, bool replay) {
73+
version++;
74+
if (replay)
75+
projected_version = version;
76+
}
77+
78+
void MDSTableServer::reset_state() {
79+
pending_for_mds.clear();
80+
++version;
81+
}
82+
3183
void MDSTableServer::handle_request(const cref_t<MMDSTableRequest> &req)
3284
{
3385
ceph_assert(req->op >= 0);
@@ -297,6 +349,16 @@ void MDSTableServer::_do_server_recovery()
297349
recovered = true;
298350
}
299351

352+
void MDSTableServer::encode_state(bufferlist& bl) const {
353+
encode_server_state(bl);
354+
encode(pending_for_mds, bl);
355+
}
356+
357+
void MDSTableServer::decode_state(bufferlist::const_iterator& bl) {
358+
decode_server_state(bl);
359+
decode(pending_for_mds, bl);
360+
}
361+
300362
void MDSTableServer::finish_recovery(set<mds_rank_t>& active)
301363
{
302364
dout(7) << __func__ << dendl;

src/mds/MDSTableServer.h

Lines changed: 16 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@
2222
#include "mdstypes.h" // for mds_table_pending_t
2323
#include "mds_table_types.h" // for get_mdstable_name()
2424

25-
#include "messages/MMDSTableRequest.h"
26-
2725
#include "common/ref.h" // for cref_t
2826

2927
class MDSContext;
28+
class MMDSTableRequest;
3029

3130
class MDSTableServer : public MDSTable {
3231
public:
3332
friend class C_ServerRecovery;
3433

35-
MDSTableServer(MDSRank *m, int tab) :
36-
MDSTable(m, get_mdstable_name(tab), false), table(tab) {}
37-
~MDSTableServer() override {}
34+
MDSTableServer(MDSRank *m, int tab);
35+
~MDSTableServer();
36+
37+
// required by DencoderImplFeatureful::copy()
38+
MDSTableServer(const MDSTableServer &);
39+
MDSTableServer &operator=(const MDSTableServer &);
3840

3941
virtual void handle_query(const cref_t<MMDSTableRequest> &m) = 0;
4042
virtual void _prepare(const bufferlist &bl, uint64_t reqid, mds_rank_t bymds, bufferlist& out) = 0;
@@ -44,51 +46,21 @@ class MDSTableServer : public MDSTable {
4446
virtual void _server_update(bufferlist& bl) { ceph_abort(); }
4547
virtual bool _notify_prep(version_t tid) { return false; };
4648

47-
void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false) {
48-
version++;
49-
if (replay)
50-
projected_version = version;
51-
pending_for_mds[version].mds = mds;
52-
pending_for_mds[version].reqid = reqid;
53-
pending_for_mds[version].tid = version;
54-
}
55-
void _note_commit(uint64_t tid, bool replay=false) {
56-
version++;
57-
if (replay)
58-
projected_version = version;
59-
pending_for_mds.erase(tid);
60-
}
61-
void _note_rollback(uint64_t tid, bool replay=false) {
62-
version++;
63-
if (replay)
64-
projected_version = version;
65-
pending_for_mds.erase(tid);
66-
}
67-
void _note_server_update(bufferlist& bl, bool replay=false) {
68-
version++;
69-
if (replay)
70-
projected_version = version;
71-
}
72-
73-
void reset_state() override {
74-
pending_for_mds.clear();
75-
++version;
76-
}
49+
void _note_prepare(mds_rank_t mds, uint64_t reqid, bool replay=false);
50+
void _note_commit(uint64_t tid, bool replay=false);
51+
void _note_rollback(uint64_t tid, bool replay=false);
52+
void _note_server_update(bufferlist& bl, bool replay=false);
53+
54+
void reset_state() override;
7755

7856
void handle_request(const cref_t<MMDSTableRequest> &m);
7957
void do_server_update(bufferlist& bl);
8058

8159
virtual void encode_server_state(bufferlist& bl) const = 0;
8260
virtual void decode_server_state(bufferlist::const_iterator& bl) = 0;
8361

84-
void encode_state(bufferlist& bl) const override {
85-
encode_server_state(bl);
86-
encode(pending_for_mds, bl);
87-
}
88-
void decode_state(bufferlist::const_iterator& bl) override {
89-
decode_server_state(bl);
90-
decode(pending_for_mds, bl);
91-
}
62+
void encode_state(bufferlist& bl) const override;
63+
void decode_state(bufferlist::const_iterator& bl) override;
9264

9365
// recovery
9466
void finish_recovery(std::set<mds_rank_t>& active);
@@ -101,13 +73,7 @@ class MDSTableServer : public MDSTable {
10173
bool recovered = false;
10274
std::set<mds_rank_t> active_clients;
10375
private:
104-
struct notify_info_t {
105-
notify_info_t() {}
106-
std::set<mds_rank_t> notify_ack_gather;
107-
mds_rank_t mds;
108-
ref_t<MMDSTableRequest> reply = NULL;
109-
MDSContext *onfinish = nullptr;
110-
};
76+
struct notify_info_t;
11177

11278
friend class C_Prepare;
11379
friend class C_Commit;

0 commit comments

Comments
 (0)