]>
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
{
27 set
<mds_rank_t
> active_clients
;
29 map
<version_t
,mds_table_pending_t
> pending_for_mds
; // ** child should encode this! **
30 set
<version_t
> committing_tids
;
32 struct notify_info_t
{
33 set
<mds_rank_t
> notify_ack_gather
;
35 MMDSTableRequest::ref reply
;
37 notify_info_t() : reply(NULL
), onfinish(NULL
) {}
39 map
<version_t
, notify_info_t
> pending_notifies
;
41 void handle_prepare(const MMDSTableRequest::const_ref
&m
);
42 void _prepare_logged(const MMDSTableRequest::const_ref
&m
, version_t tid
);
43 friend class C_Prepare
;
45 void handle_commit(const MMDSTableRequest::const_ref
&m
);
46 void _commit_logged(const MMDSTableRequest::const_ref
&m
);
47 friend class C_Commit
;
49 void handle_rollback(const MMDSTableRequest::const_ref
&m
);
50 void _rollback_logged(const MMDSTableRequest::const_ref
&m
);
51 friend class C_Rollback
;
53 void _server_update_logged(bufferlist
& bl
);
54 friend class C_ServerUpdate
;
56 void handle_notify_ack(const MMDSTableRequest::const_ref
&m
);
59 virtual void handle_query(const MMDSTableRequest::const_ref
&m
) = 0;
60 virtual void _prepare(const bufferlist
&bl
, uint64_t reqid
, mds_rank_t bymds
, bufferlist
& out
) = 0;
61 virtual void _get_reply_buffer(version_t tid
, bufferlist
*pbl
) const = 0;
62 virtual void _commit(version_t tid
, MMDSTableRequest::const_ref req
) = 0;
63 virtual void _rollback(version_t tid
) = 0;
64 virtual void _server_update(bufferlist
& bl
) { ceph_abort(); }
65 virtual bool _notify_prep(version_t tid
) { return false; };
67 void _note_prepare(mds_rank_t mds
, uint64_t reqid
, bool replay
=false) {
70 projected_version
= version
;
71 pending_for_mds
[version
].mds
= mds
;
72 pending_for_mds
[version
].reqid
= reqid
;
73 pending_for_mds
[version
].tid
= version
;
75 void _note_commit(uint64_t tid
, bool replay
=false) {
78 projected_version
= version
;
79 pending_for_mds
.erase(tid
);
81 void _note_rollback(uint64_t tid
, bool replay
=false) {
84 projected_version
= version
;
85 pending_for_mds
.erase(tid
);
87 void _note_server_update(bufferlist
& bl
, bool replay
=false) {
90 projected_version
= version
;
93 MDSTableServer(MDSRank
*m
, int tab
) :
94 MDSTable(m
, get_mdstable_name(tab
), false), table(tab
), recovered(false) {}
95 ~MDSTableServer() override
{}
97 void reset_state() override
{
98 pending_for_mds
.clear();
102 void handle_request(const MMDSTableRequest::const_ref
&m
);
103 void do_server_update(bufferlist
& bl
);
105 virtual void encode_server_state(bufferlist
& bl
) const = 0;
106 virtual void decode_server_state(bufferlist::const_iterator
& bl
) = 0;
108 void encode_state(bufferlist
& bl
) const override
{
109 encode_server_state(bl
);
110 encode(pending_for_mds
, bl
);
112 void decode_state(bufferlist::const_iterator
& bl
) override
{
113 decode_server_state(bl
);
114 decode(pending_for_mds
, bl
);
118 void finish_recovery(set
<mds_rank_t
>& active
);
119 void _do_server_recovery();
120 friend class C_ServerRecovery
;
122 void handle_mds_recovery(mds_rank_t who
);
123 void handle_mds_failure_or_stop(mds_rank_t who
);