]>
git.proxmox.com Git - ceph.git/blob - 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
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.
18 #include <string_view>
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"
26 #include "common/LogClient.h"
27 #include "common/ceph_mutex.h"
28 #include "common/Timer.h"
29 #include "include/Context.h"
30 #include "include/types.h"
31 #include "mgr/MgrClient.h"
32 #include "msg/Dispatcher.h"
38 #define CEPH_MDS_PROTOCOL 36 /* cluster internal */
43 class MDSDaemon
: public Dispatcher
{
45 MDSDaemon(std::string_view n
, Messenger
*m
, MonClient
*mc
,
46 boost::asio::io_context
& ioctx
);
48 ~MDSDaemon() override
;
50 mono_time
get_starttime() const {
53 chrono::duration
<double> get_uptime() const {
54 mono_time now
= mono_clock::now();
55 return chrono::duration
<double>(now
-starttime
);
58 // handle a signal (e.g., SIGTERM)
59 void handle_signal(int signum
);
64 * Hint at whether we were shutdown gracefully (i.e. we were only
65 * in standby, or our rank was stopped). Should be removed once
66 * we handle shutdown properly (e.g. clear out all message queues)
67 * such that deleting xlists doesn't assert.
69 bool is_clean_shutdown();
71 /* Global MDS lock: every time someone takes this, they must
72 * also check the `stopping` flag. If stopping is true, you
73 * must either do nothing and immediately drop the lock, or
74 * never drop the lock again (i.e. call respawn()) */
75 ceph::mutex mds_lock
= ceph::make_mutex("MDSDaemon::mds_lock");
76 bool stopping
= false;
79 std::string gss_ktfile_client
{};
82 const char **orig_argv
;
86 // admin socket handling
87 friend class MDSSocketHook
;
89 // special message types
90 friend class C_MDS_Send_Command_Reply
;
93 void wait_for_omap_osds();
95 void set_up_admin_socket();
96 void clean_up_admin_socket();
97 void check_ops_in_flight(); // send off any slow ops to monitor
99 std::string_view command
,
100 const cmdmap_t
& cmdmap
,
102 const bufferlist
&inbl
,
103 std::function
<void(int,const std::string
&,bufferlist
&)> on_finish
);
105 void dump_status(Formatter
*f
);
108 * Terminate this daemon process.
110 * This function will return, but once it does so the calling thread
111 * must do no more work as all subsystems will have been shut down.
116 * Start a new daemon process with the same command line parameters that
117 * this process was run with, then terminate this process
123 bool handle_core_message(const cref_t
<Message
> &m
);
125 void handle_command(const cref_t
<MCommand
> &m
);
126 void handle_mds_map(const cref_t
<MMDSMap
> &m
);
132 Messenger
*messenger
;
134 boost::asio::io_context
& ioctx
;
136 std::unique_ptr
<MDSMap
> mdsmap
;
137 LogClient log_client
;
140 MDSRankDispatcher
*mds_rank
= nullptr;
142 // tick and other timer fun
143 Context
*tick_event
= nullptr;
144 class MDSSocketHook
*asok_hook
= nullptr;
147 bool ms_dispatch2(const ref_t
<Message
> &m
) override
;
148 int ms_handle_authentication(Connection
*con
) override
;
149 void ms_handle_accept(Connection
*con
) override
;
150 void ms_handle_connect(Connection
*con
) override
;
151 bool ms_handle_reset(Connection
*con
) override
;
152 void ms_handle_remote_reset(Connection
*con
) override
;
153 bool ms_handle_refused(Connection
*con
) override
;
155 bool parse_caps(const AuthCapsInfo
&, MDSAuthCaps
&);
157 mono_time starttime
= mono_clock::zero();