]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/MDSDaemon.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / mds / MDSDaemon.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2004-2006 Sage Weil <sage@newdream.net>
7 *
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.
12 *
13 */
14
15 #ifndef CEPH_MDS_H
16 #define CEPH_MDS_H
17
18 #include <string_view>
19
20 #include "messages/MCommand.h"
21 #include "messages/MCommandReply.h"
22 #include "messages/MGenericMessage.h"
23 #include "messages/MMDSMap.h"
24 #include "messages/MMonCommand.h"
25
26 #include "common/LogClient.h"
27 #include "common/ceph_mutex.h"
28 #include "common/fair_mutex.h"
29 #include "common/Timer.h"
30 #include "include/Context.h"
31 #include "include/types.h"
32 #include "mgr/MgrClient.h"
33 #include "msg/Dispatcher.h"
34
35 #include "Beacon.h"
36 #include "MDSMap.h"
37 #include "MDSRank.h"
38
39 #define CEPH_MDS_PROTOCOL 36 /* cluster internal */
40
41 class Messenger;
42 class MonClient;
43
44 class MDSDaemon : public Dispatcher {
45 public:
46 MDSDaemon(std::string_view n, Messenger *m, MonClient *mc,
47 boost::asio::io_context& ioctx);
48
49 ~MDSDaemon() override;
50
51 mono_time get_starttime() const {
52 return starttime;
53 }
54 std::chrono::duration<double> get_uptime() const {
55 mono_time now = mono_clock::now();
56 return std::chrono::duration<double>(now-starttime);
57 }
58
59 // handle a signal (e.g., SIGTERM)
60 void handle_signal(int signum);
61
62 int init();
63
64 /**
65 * Hint at whether we were shutdown gracefully (i.e. we were only
66 * in standby, or our rank was stopped). Should be removed once
67 * we handle shutdown properly (e.g. clear out all message queues)
68 * such that deleting xlists doesn't assert.
69 */
70 bool is_clean_shutdown();
71
72 /* Global MDS lock: every time someone takes this, they must
73 * also check the `stopping` flag. If stopping is true, you
74 * must either do nothing and immediately drop the lock, or
75 * never drop the lock again (i.e. call respawn()) */
76 ceph::fair_mutex mds_lock{"MDSDaemon::mds_lock"};
77 bool stopping = false;
78
79 class CommonSafeTimer<ceph::fair_mutex> timer;
80 std::string gss_ktfile_client{};
81
82 int orig_argc;
83 const char **orig_argv;
84
85
86 protected:
87 // admin socket handling
88 friend class MDSSocketHook;
89
90 // special message types
91 friend class C_MDS_Send_Command_Reply;
92
93 void reset_tick();
94 void wait_for_omap_osds();
95
96 void set_up_admin_socket();
97 void clean_up_admin_socket();
98 void check_ops_in_flight(); // send off any slow ops to monitor
99 void asok_command(
100 std::string_view command,
101 const cmdmap_t& cmdmap,
102 Formatter *f,
103 const bufferlist &inbl,
104 std::function<void(int,const std::string&,bufferlist&)> on_finish);
105
106 void dump_status(Formatter *f);
107
108 /**
109 * Terminate this daemon process.
110 *
111 * This function will return, but once it does so the calling thread
112 * must do no more work as all subsystems will have been shut down.
113 */
114 void suicide();
115
116 /**
117 * Start a new daemon process with the same command line parameters that
118 * this process was run with, then terminate this process
119 */
120 void respawn();
121
122 void tick();
123
124 bool handle_core_message(const cref_t<Message> &m);
125
126 void handle_command(const cref_t<MCommand> &m);
127 void handle_mds_map(const cref_t<MMDSMap> &m);
128
129 Beacon beacon;
130
131 std::string name;
132
133 Messenger *messenger;
134 MonClient *monc;
135 boost::asio::io_context& ioctx;
136 MgrClient mgrc;
137 std::unique_ptr<MDSMap> mdsmap;
138 LogClient log_client;
139 LogChannelRef clog;
140
141 MDSRankDispatcher *mds_rank = nullptr;
142
143 // tick and other timer fun
144 Context *tick_event = nullptr;
145 class MDSSocketHook *asok_hook = nullptr;
146
147 private:
148 bool ms_dispatch2(const ref_t<Message> &m) override;
149 int ms_handle_fast_authentication(Connection *con) override;
150 void ms_handle_accept(Connection *con) override;
151 void ms_handle_connect(Connection *con) override;
152 bool ms_handle_reset(Connection *con) override;
153 void ms_handle_remote_reset(Connection *con) override;
154 bool ms_handle_refused(Connection *con) override;
155
156 bool parse_caps(const AuthCapsInfo&, MDSAuthCaps&);
157
158 mono_time starttime = mono_clock::zero();
159 };
160
161 #endif