]>
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/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"
39 #define CEPH_MDS_PROTOCOL 36 /* cluster internal */
44 class MDSDaemon
: public Dispatcher
{
46 MDSDaemon(std::string_view n
, Messenger
*m
, MonClient
*mc
,
47 boost::asio::io_context
& ioctx
);
49 ~MDSDaemon() override
;
51 mono_time
get_starttime() const {
54 std::chrono::duration
<double> get_uptime() const {
55 mono_time now
= mono_clock::now();
56 return std::chrono::duration
<double>(now
-starttime
);
59 // handle a signal (e.g., SIGTERM)
60 void handle_signal(int signum
);
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.
70 bool is_clean_shutdown();
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;
79 class CommonSafeTimer
<ceph::fair_mutex
> timer
;
80 std::string gss_ktfile_client
{};
83 const char **orig_argv
;
87 // admin socket handling
88 friend class MDSSocketHook
;
90 // special message types
91 friend class C_MDS_Send_Command_Reply
;
94 void wait_for_omap_osds();
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
100 std::string_view command
,
101 const cmdmap_t
& cmdmap
,
103 const bufferlist
&inbl
,
104 std::function
<void(int,const std::string
&,bufferlist
&)> on_finish
);
106 void dump_status(Formatter
*f
);
109 * Terminate this daemon process.
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.
117 * Start a new daemon process with the same command line parameters that
118 * this process was run with, then terminate this process
124 bool handle_core_message(const cref_t
<Message
> &m
);
126 void handle_command(const cref_t
<MCommand
> &m
);
127 void handle_mds_map(const cref_t
<MMDSMap
> &m
);
133 Messenger
*messenger
;
135 boost::asio::io_context
& ioctx
;
137 std::unique_ptr
<MDSMap
> mdsmap
;
138 LogClient log_client
;
141 MDSRankDispatcher
*mds_rank
= nullptr;
143 // tick and other timer fun
144 Context
*tick_event
= nullptr;
145 class MDSSocketHook
*asok_hook
= nullptr;
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
;
156 bool parse_caps(const AuthCapsInfo
&, MDSAuthCaps
&);
158 mono_time starttime
= mono_clock::zero();