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.
22 #include "msg/Dispatcher.h"
23 #include "include/CompatSet.h"
24 #include "include/types.h"
25 #include "include/Context.h"
26 #include "common/DecayCounter.h"
27 #include "common/perf_counters.h"
28 #include "common/Mutex.h"
29 #include "common/Cond.h"
30 #include "common/Timer.h"
31 #include "common/LogClient.h"
32 #include "common/TrackedOp.h"
33 #include "common/Finisher.h"
34 #include "common/cmdparse.h"
35 #include "mgr/MgrClient.h"
43 #define CEPH_MDS_PROTOCOL 30 /* cluster internal */
51 class MDSInternalContextBase
;
62 class AuthAuthorizeHandlerRegistry
;
64 class MDSDaemon
: public Dispatcher
, public md_config_obs_t
{
66 /* Global MDS lock: every time someone takes this, they must
67 * also check the `stopping` flag. If stopping is true, you
68 * must either do nothing and immediately drop the lock, or
69 * never drop the lock again (i.e. call respawn()) */
78 AuthAuthorizeHandlerRegistry
*authorize_handler_cluster_registry
;
79 AuthAuthorizeHandlerRegistry
*authorize_handler_service_registry
;
90 MDSRankDispatcher
*mds_rank
;
93 MDSDaemon(const std::string
&n
, Messenger
*m
, MonClient
*mc
);
94 ~MDSDaemon() override
;
96 const char **orig_argv
;
98 // handle a signal (e.g., SIGTERM)
99 void handle_signal(int signum
);
104 * Hint at whether we were shutdown gracefully (i.e. we were only
105 * in standby, or our rank was stopped). Should be removed once
106 * we handle shutdown properly (e.g. clear out all message queues)
107 * such that deleting xlists doesn't assert.
109 bool is_clean_shutdown();
111 // config observer bits
112 const char** get_tracked_conf_keys() const override
;
113 void handle_conf_change(const struct md_config_t
*conf
,
114 const std::set
<std::string
> &changed
) override
;
116 // tick and other timer fun
118 C_MDS_Tick
*tick_event
;
121 void wait_for_omap_osds();
124 bool ms_dispatch(Message
*m
) override
;
125 bool ms_get_authorizer(int dest_type
, AuthAuthorizer
**authorizer
, bool force_new
) override
;
126 bool ms_verify_authorizer(Connection
*con
, int peer_type
,
127 int protocol
, bufferlist
& authorizer_data
, bufferlist
& authorizer_reply
,
128 bool& isvalid
, CryptoKey
& session_key
) override
;
129 void ms_handle_accept(Connection
*con
) override
;
130 void ms_handle_connect(Connection
*con
) override
;
131 bool ms_handle_reset(Connection
*con
) override
;
132 void ms_handle_remote_reset(Connection
*con
) override
;
133 bool ms_handle_refused(Connection
*con
) override
;
136 // admin socket handling
137 friend class MDSSocketHook
;
138 class MDSSocketHook
*asok_hook
;
139 void set_up_admin_socket();
140 void clean_up_admin_socket();
141 void check_ops_in_flight(); // send off any slow ops to monitor
142 bool asok_command(string command
, cmdmap_t
& cmdmap
, string format
,
145 void dump_status(Formatter
*f
);
148 * Terminate this daemon process.
150 * This function will return, but once it does so the calling thread
151 * must do no more work as all subsystems will have been shut down.
156 * Start a new daemon process with the same command line parameters that
157 * this process was run with, then terminate this process
164 bool _dispatch(Message
*m
, bool new_msg
);
167 bool handle_core_message(Message
*m
);
169 // special message types
170 friend class C_MDS_Send_Command_Reply
;
171 static void send_command_reply(MCommand
*m
, MDSRank
* mds_rank
, int r
,
172 bufferlist outbl
, const std::string
& outs
);
174 const cmdmap_t
&cmdmap
,
180 void handle_command(class MCommand
*m
);
181 void handle_mds_map(class MMDSMap
*m
);
182 void _handle_mds_map(MDSMap
*oldmap
);