]>
git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSTableServer.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef CEPH_MDSTABLESERVER_H
16 #define CEPH_MDSTABLESERVER_H
19 #include "MDSContext.h"
21 #include "messages/MMDSTableRequest.h"
23 class MDSTableServer
: public MDSTable
{
25 friend class C_ServerRecovery
;
27 MDSTableServer(MDSRank
*m
, int tab
) :
28 MDSTable(m
, get_mdstable_name(tab
), false), table(tab
) {}
29 ~MDSTableServer() override
{}
31 virtual void handle_query(const cref_t
<MMDSTableRequest
> &m
) = 0;
32 virtual void _prepare(const bufferlist
&bl
, uint64_t reqid
, mds_rank_t bymds
, bufferlist
& out
) = 0;
33 virtual void _get_reply_buffer(version_t tid
, bufferlist
*pbl
) const = 0;
34 virtual void _commit(version_t tid
, cref_t
<MMDSTableRequest
> req
) = 0;
35 virtual void _rollback(version_t tid
) = 0;
36 virtual void _server_update(bufferlist
& bl
) { ceph_abort(); }
37 virtual bool _notify_prep(version_t tid
) { return false; };
39 void _note_prepare(mds_rank_t mds
, uint64_t reqid
, bool replay
=false) {
42 projected_version
= version
;
43 pending_for_mds
[version
].mds
= mds
;
44 pending_for_mds
[version
].reqid
= reqid
;
45 pending_for_mds
[version
].tid
= version
;
47 void _note_commit(uint64_t tid
, bool replay
=false) {
50 projected_version
= version
;
51 pending_for_mds
.erase(tid
);
53 void _note_rollback(uint64_t tid
, bool replay
=false) {
56 projected_version
= version
;
57 pending_for_mds
.erase(tid
);
59 void _note_server_update(bufferlist
& bl
, bool replay
=false) {
62 projected_version
= version
;
65 void reset_state() override
{
66 pending_for_mds
.clear();
70 void handle_request(const cref_t
<MMDSTableRequest
> &m
);
71 void do_server_update(bufferlist
& bl
);
73 virtual void encode_server_state(bufferlist
& bl
) const = 0;
74 virtual void decode_server_state(bufferlist::const_iterator
& bl
) = 0;
76 void encode_state(bufferlist
& bl
) const override
{
77 encode_server_state(bl
);
78 encode(pending_for_mds
, bl
);
80 void decode_state(bufferlist::const_iterator
& bl
) override
{
81 decode_server_state(bl
);
82 decode(pending_for_mds
, bl
);
86 void finish_recovery(set
<mds_rank_t
>& active
);
87 void _do_server_recovery();
89 void handle_mds_recovery(mds_rank_t who
);
90 void handle_mds_failure_or_stop(mds_rank_t who
);
93 bool recovered
= false;
94 set
<mds_rank_t
> active_clients
;
96 struct notify_info_t
{
98 set
<mds_rank_t
> notify_ack_gather
;
100 ref_t
<MMDSTableRequest
> reply
= NULL
;
101 MDSContext
*onfinish
= nullptr;
104 friend class C_Prepare
;
105 friend class C_Commit
;
106 friend class C_Rollback
;
107 friend class C_ServerUpdate
;
109 void handle_prepare(const cref_t
<MMDSTableRequest
> &m
);
110 void _prepare_logged(const cref_t
<MMDSTableRequest
> &m
, version_t tid
);
112 void handle_commit(const cref_t
<MMDSTableRequest
> &m
);
113 void _commit_logged(const cref_t
<MMDSTableRequest
> &m
);
115 void handle_rollback(const cref_t
<MMDSTableRequest
> &m
);
116 void _rollback_logged(const cref_t
<MMDSTableRequest
> &m
);
118 void _server_update_logged(bufferlist
& bl
);
120 void handle_notify_ack(const cref_t
<MMDSTableRequest
> &m
);
122 map
<version_t
,mds_table_pending_t
> pending_for_mds
; // ** child should encode this! **
123 set
<version_t
> committing_tids
;
125 map
<version_t
, notify_info_t
> pending_notifies
;