]> git.proxmox.com Git - ceph.git/blob - ceph/src/mds/Server.h
bump version to 18.2.2-pve1
[ceph.git] / ceph / src / mds / Server.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_SERVER_H
16 #define CEPH_MDS_SERVER_H
17
18 #include <string_view>
19
20 #include <common/DecayCounter.h>
21
22 #include "include/common_fwd.h"
23
24 #include "messages/MClientReconnect.h"
25 #include "messages/MClientReply.h"
26 #include "messages/MClientRequest.h"
27 #include "messages/MClientSession.h"
28 #include "messages/MClientSnap.h"
29 #include "messages/MClientReclaim.h"
30 #include "messages/MClientReclaimReply.h"
31 #include "messages/MLock.h"
32
33 #include "CInode.h"
34 #include "MDSRank.h"
35 #include "Mutation.h"
36 #include "MDSContext.h"
37
38 class OSDMap;
39 class LogEvent;
40 class EMetaBlob;
41 class EUpdate;
42 class MDLog;
43 struct SnapInfo;
44 class MetricsHandler;
45
46 enum {
47 l_mdss_first = 1000,
48 l_mdss_dispatch_client_request,
49 l_mdss_dispatch_peer_request,
50 l_mdss_handle_client_request,
51 l_mdss_handle_client_session,
52 l_mdss_handle_peer_request,
53 l_mdss_req_create_latency,
54 l_mdss_req_getattr_latency,
55 l_mdss_req_getfilelock_latency,
56 l_mdss_req_link_latency,
57 l_mdss_req_lookup_latency,
58 l_mdss_req_lookuphash_latency,
59 l_mdss_req_lookupino_latency,
60 l_mdss_req_lookupname_latency,
61 l_mdss_req_lookupparent_latency,
62 l_mdss_req_lookupsnap_latency,
63 l_mdss_req_lssnap_latency,
64 l_mdss_req_mkdir_latency,
65 l_mdss_req_mknod_latency,
66 l_mdss_req_mksnap_latency,
67 l_mdss_req_open_latency,
68 l_mdss_req_readdir_latency,
69 l_mdss_req_rename_latency,
70 l_mdss_req_renamesnap_latency,
71 l_mdss_req_snapdiff_latency,
72 l_mdss_req_rmdir_latency,
73 l_mdss_req_rmsnap_latency,
74 l_mdss_req_rmxattr_latency,
75 l_mdss_req_setattr_latency,
76 l_mdss_req_setdirlayout_latency,
77 l_mdss_req_setfilelock_latency,
78 l_mdss_req_setlayout_latency,
79 l_mdss_req_setxattr_latency,
80 l_mdss_req_symlink_latency,
81 l_mdss_req_unlink_latency,
82 l_mdss_cap_revoke_eviction,
83 l_mdss_cap_acquisition_throttle,
84 l_mdss_req_getvxattr_latency,
85 l_mdss_last,
86 };
87
88 class Server {
89 public:
90 using clock = ceph::coarse_mono_clock;
91 using time = ceph::coarse_mono_time;
92
93 enum class RecallFlags : uint64_t {
94 NONE = 0,
95 STEADY = (1<<0),
96 ENFORCE_MAX = (1<<1),
97 TRIM = (1<<2),
98 ENFORCE_LIVENESS = (1<<3),
99 };
100
101 explicit Server(MDSRank *m, MetricsHandler *metrics_handler);
102 ~Server() {
103 g_ceph_context->get_perfcounters_collection()->remove(logger);
104 delete logger;
105 delete reconnect_done;
106 }
107
108 void create_logger();
109
110 // message handler
111 void dispatch(const cref_t<Message> &m);
112
113 void handle_osd_map();
114
115 // -- sessions and recovery --
116 bool waiting_for_reconnect(client_t c) const;
117 void dump_reconnect_status(Formatter *f) const;
118
119 time last_recalled() const {
120 return last_recall_state;
121 }
122
123 void handle_client_session(const cref_t<MClientSession> &m);
124 void _session_logged(Session *session, uint64_t state_seq, bool open, version_t pv,
125 const interval_set<inodeno_t>& inos_to_free, version_t piv,
126 const interval_set<inodeno_t>& inos_to_purge, LogSegment *ls);
127 version_t prepare_force_open_sessions(std::map<client_t,entity_inst_t> &cm,
128 std::map<client_t,client_metadata_t>& cmm,
129 std::map<client_t,std::pair<Session*,uint64_t> >& smap);
130 void finish_force_open_sessions(const std::map<client_t,std::pair<Session*,uint64_t> >& smap,
131 bool dec_import=true);
132 void flush_client_sessions(std::set<client_t>& client_set, MDSGatherBuilder& gather);
133 void finish_flush_session(Session *session, version_t seq);
134 void terminate_sessions();
135 void find_idle_sessions();
136
137 void kill_session(Session *session, Context *on_safe);
138 size_t apply_blocklist();
139 void journal_close_session(Session *session, int state, Context *on_safe);
140
141 size_t get_num_pending_reclaim() const { return client_reclaim_gather.size(); }
142 Session *find_session_by_uuid(std::string_view uuid);
143 void reclaim_session(Session *session, const cref_t<MClientReclaim> &m);
144 void finish_reclaim_session(Session *session, const ref_t<MClientReclaimReply> &reply=nullptr);
145 void handle_client_reclaim(const cref_t<MClientReclaim> &m);
146
147 void reconnect_clients(MDSContext *reconnect_done_);
148 void handle_client_reconnect(const cref_t<MClientReconnect> &m);
149 void infer_supported_features(Session *session, client_metadata_t& client_metadata);
150 void update_required_client_features();
151
152 //void process_reconnect_cap(CInode *in, int from, ceph_mds_cap_reconnect& capinfo);
153 void reconnect_gather_finish();
154 void reconnect_tick();
155 void recover_filelocks(CInode *in, bufferlist locks, int64_t client);
156
157 std::pair<bool, uint64_t> recall_client_state(MDSGatherBuilder* gather, RecallFlags=RecallFlags::NONE);
158 void force_clients_readonly();
159
160 // -- requests --
161 void handle_client_request(const cref_t<MClientRequest> &m);
162
163 void journal_and_reply(MDRequestRef& mdr, CInode *tracei, CDentry *tracedn,
164 LogEvent *le, MDSLogContextBase *fin);
165 void submit_mdlog_entry(LogEvent *le, MDSLogContextBase *fin,
166 MDRequestRef& mdr, std::string_view event);
167 void dispatch_client_request(MDRequestRef& mdr);
168 void perf_gather_op_latency(const cref_t<MClientRequest> &req, utime_t lat);
169 void early_reply(MDRequestRef& mdr, CInode *tracei, CDentry *tracedn);
170 void respond_to_request(MDRequestRef& mdr, int r = 0);
171 void set_trace_dist(const ref_t<MClientReply> &reply, CInode *in, CDentry *dn,
172 MDRequestRef& mdr);
173
174 void handle_peer_request(const cref_t<MMDSPeerRequest> &m);
175 void handle_peer_request_reply(const cref_t<MMDSPeerRequest> &m);
176 void dispatch_peer_request(MDRequestRef& mdr);
177 void handle_peer_auth_pin(MDRequestRef& mdr);
178 void handle_peer_auth_pin_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &ack);
179
180 // some helpers
181 bool check_fragment_space(MDRequestRef& mdr, CDir *in);
182 bool check_dir_max_entries(MDRequestRef& mdr, CDir *in);
183 bool check_access(MDRequestRef& mdr, CInode *in, unsigned mask);
184 bool _check_access(Session *session, CInode *in, unsigned mask, int caller_uid, int caller_gid, int setattr_uid, int setattr_gid);
185 CDentry *prepare_stray_dentry(MDRequestRef& mdr, CInode *in);
186 CInode* prepare_new_inode(MDRequestRef& mdr, CDir *dir, inodeno_t useino, unsigned mode,
187 const file_layout_t *layout=nullptr);
188 void journal_allocated_inos(MDRequestRef& mdr, EMetaBlob *blob);
189 void apply_allocated_inos(MDRequestRef& mdr, Session *session);
190
191 void _try_open_ino(MDRequestRef& mdr, int r, inodeno_t ino);
192 CInode* rdlock_path_pin_ref(MDRequestRef& mdr, bool want_auth,
193 bool no_want_auth=false);
194 CDentry* rdlock_path_xlock_dentry(MDRequestRef& mdr, bool create,
195 bool okexist=false, bool authexist=false,
196 bool want_layout=false);
197 std::pair<CDentry*, CDentry*>
198 rdlock_two_paths_xlock_destdn(MDRequestRef& mdr, bool xlock_srcdn);
199
200 CDir* try_open_auth_dirfrag(CInode *diri, frag_t fg, MDRequestRef& mdr);
201
202 // requests on existing inodes.
203 void handle_client_getattr(MDRequestRef& mdr, bool is_lookup);
204 void handle_client_lookup_ino(MDRequestRef& mdr,
205 bool want_parent, bool want_dentry);
206 void _lookup_snap_ino(MDRequestRef& mdr);
207 void _lookup_ino_2(MDRequestRef& mdr, int r);
208 void handle_client_readdir(MDRequestRef& mdr);
209 void handle_client_file_setlock(MDRequestRef& mdr);
210 void handle_client_file_readlock(MDRequestRef& mdr);
211
212 bool xlock_policylock(MDRequestRef& mdr, CInode *in,
213 bool want_layout=false, bool xlock_snaplock=false);
214 CInode* try_get_auth_inode(MDRequestRef& mdr, inodeno_t ino);
215 void handle_client_setattr(MDRequestRef& mdr);
216 void handle_client_setlayout(MDRequestRef& mdr);
217 void handle_client_setdirlayout(MDRequestRef& mdr);
218
219 int parse_quota_vxattr(std::string name, std::string value, quota_info_t *quota);
220 void create_quota_realm(CInode *in);
221 int parse_layout_vxattr_json(std::string name, std::string value,
222 const OSDMap& osdmap, file_layout_t *layout);
223 int parse_layout_vxattr_string(std::string name, std::string value, const OSDMap& osdmap,
224 file_layout_t *layout);
225 int parse_layout_vxattr(std::string name, std::string value, const OSDMap& osdmap,
226 file_layout_t *layout, bool validate=true);
227 int check_layout_vxattr(MDRequestRef& mdr,
228 std::string name,
229 std::string value,
230 file_layout_t *layout);
231 void handle_set_vxattr(MDRequestRef& mdr, CInode *cur);
232 void handle_remove_vxattr(MDRequestRef& mdr, CInode *cur);
233 void handle_client_getvxattr(MDRequestRef& mdr);
234 void handle_client_setxattr(MDRequestRef& mdr);
235 void handle_client_removexattr(MDRequestRef& mdr);
236
237 void handle_client_fsync(MDRequestRef& mdr);
238
239 // open
240 void handle_client_open(MDRequestRef& mdr);
241 void handle_client_openc(MDRequestRef& mdr); // O_CREAT variant.
242 void do_open_truncate(MDRequestRef& mdr, int cmode); // O_TRUNC variant.
243
244 // namespace changes
245 void handle_client_mknod(MDRequestRef& mdr);
246 void handle_client_mkdir(MDRequestRef& mdr);
247 void handle_client_symlink(MDRequestRef& mdr);
248
249 // link
250 void handle_client_link(MDRequestRef& mdr);
251 void _link_local(MDRequestRef& mdr, CDentry *dn, CInode *targeti, SnapRealm *target_realm);
252 void _link_local_finish(MDRequestRef& mdr, CDentry *dn, CInode *targeti,
253 version_t, version_t, bool);
254
255 void _link_remote(MDRequestRef& mdr, bool inc, CDentry *dn, CInode *targeti);
256 void _link_remote_finish(MDRequestRef& mdr, bool inc, CDentry *dn, CInode *targeti,
257 version_t);
258
259 void handle_peer_link_prep(MDRequestRef& mdr);
260 void _logged_peer_link(MDRequestRef& mdr, CInode *targeti, bool adjust_realm);
261 void _commit_peer_link(MDRequestRef& mdr, int r, CInode *targeti);
262 void _committed_peer(MDRequestRef& mdr); // use for rename, too
263 void handle_peer_link_prep_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &m);
264 void do_link_rollback(bufferlist &rbl, mds_rank_t leader, MDRequestRef& mdr);
265 void _link_rollback_finish(MutationRef& mut, MDRequestRef& mdr,
266 std::map<client_t,ref_t<MClientSnap>>& split);
267
268 // unlink
269 void handle_client_unlink(MDRequestRef& mdr);
270 bool _dir_is_nonempty_unlocked(MDRequestRef& mdr, CInode *rmdiri);
271 bool _dir_is_nonempty(MDRequestRef& mdr, CInode *rmdiri);
272 void _unlink_local(MDRequestRef& mdr, CDentry *dn, CDentry *straydn);
273 void _unlink_local_finish(MDRequestRef& mdr,
274 CDentry *dn, CDentry *straydn,
275 version_t);
276 bool _rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, std::vector<CDentry*>& trace, CDentry *straydn);
277 void handle_peer_rmdir_prep(MDRequestRef& mdr);
278 void _logged_peer_rmdir(MDRequestRef& mdr, CDentry *srcdn, CDentry *straydn);
279 void _commit_peer_rmdir(MDRequestRef& mdr, int r, CDentry *straydn);
280 void handle_peer_rmdir_prep_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &ack);
281 void do_rmdir_rollback(bufferlist &rbl, mds_rank_t leader, MDRequestRef& mdr);
282 void _rmdir_rollback_finish(MDRequestRef& mdr, metareqid_t reqid, CDentry *dn, CDentry *straydn);
283
284 // rename
285 void handle_client_rename(MDRequestRef& mdr);
286 void _rename_finish(MDRequestRef& mdr,
287 CDentry *srcdn, CDentry *destdn, CDentry *straydn);
288
289 void handle_client_lssnap(MDRequestRef& mdr);
290 void handle_client_mksnap(MDRequestRef& mdr);
291 void _mksnap_finish(MDRequestRef& mdr, CInode *diri, SnapInfo &info);
292 void handle_client_rmsnap(MDRequestRef& mdr);
293 void _rmsnap_finish(MDRequestRef& mdr, CInode *diri, snapid_t snapid);
294 void handle_client_renamesnap(MDRequestRef& mdr);
295 void _renamesnap_finish(MDRequestRef& mdr, CInode *diri, snapid_t snapid);
296 void handle_client_readdir_snapdiff(MDRequestRef& mdr);
297
298 // helpers
299 bool _rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, std::set<mds_rank_t> &witnesse,
300 std::vector<CDentry*>& srctrace, std::vector<CDentry*>& dsttrace, CDentry *straydn);
301 version_t _rename_prepare_import(MDRequestRef& mdr, CDentry *srcdn, bufferlist *client_map_bl);
302 bool _need_force_journal(CInode *diri, bool empty);
303 void _rename_prepare(MDRequestRef& mdr,
304 EMetaBlob *metablob, bufferlist *client_map_bl,
305 CDentry *srcdn, CDentry *destdn, std::string_view alternate_name,
306 CDentry *straydn);
307 /* set not_journaling=true if you're going to discard the results --
308 * this bypasses the asserts to make sure we're journaling the right
309 * things on the right nodes */
310 void _rename_apply(MDRequestRef& mdr, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
311
312 // slaving
313 void handle_peer_rename_prep(MDRequestRef& mdr);
314 void handle_peer_rename_prep_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &m);
315 void handle_peer_rename_notify_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &m);
316 void _peer_rename_sessions_flushed(MDRequestRef& mdr);
317 void _logged_peer_rename(MDRequestRef& mdr, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
318 void _commit_peer_rename(MDRequestRef& mdr, int r, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
319 void do_rename_rollback(bufferlist &rbl, mds_rank_t leader, MDRequestRef& mdr, bool finish_mdr=false);
320 void _rename_rollback_finish(MutationRef& mut, MDRequestRef& mdr, CDentry *srcdn, version_t srcdnpv,
321 CDentry *destdn, CDentry *staydn, std::map<client_t,ref_t<MClientSnap>> splits[2],
322 bool finish_mdr);
323
324 void evict_cap_revoke_non_responders();
325 void handle_conf_change(const std::set<std::string>& changed);
326
327 bool terminating_sessions = false;
328
329 std::set<client_t> client_reclaim_gather;
330
331 const bufferlist& get_snap_trace(Session *session, SnapRealm *realm) const;
332 const bufferlist& get_snap_trace(client_t client, SnapRealm *realm) const;
333
334 private:
335 friend class MDSContinuation;
336 friend class ServerContext;
337 friend class ServerLogContext;
338 friend class Batch_Getattr_Lookup;
339
340 // placeholder for validation handler to store xattr specific
341 // data
342 struct XattrInfo {
343 virtual ~XattrInfo() {
344 }
345 };
346
347 struct MirrorXattrInfo : XattrInfo {
348 std::string cluster_id;
349 std::string fs_id;
350
351 static const std::string MIRROR_INFO_REGEX;
352 static const std::string CLUSTER_ID;
353 static const std::string FS_ID;
354
355 MirrorXattrInfo(std::string_view cluster_id,
356 std::string_view fs_id)
357 : cluster_id(cluster_id),
358 fs_id(fs_id) {
359 }
360 };
361
362 struct XattrOp {
363 int op;
364 std::string xattr_name;
365 const bufferlist &xattr_value;
366 int flags = 0;
367
368 std::unique_ptr<XattrInfo> xinfo;
369
370 XattrOp(int op, std::string_view xattr_name, const bufferlist &xattr_value, int flags)
371 : op(op),
372 xattr_name(xattr_name),
373 xattr_value(xattr_value),
374 flags (flags) {
375 }
376 };
377
378 struct XattrHandler {
379 const std::string xattr_name;
380 const std::string description;
381
382 // basic checks are to be done in this handler. return -errno to
383 // reject xattr request (set or remove), zero to proceed. handlers
384 // may parse xattr value for verification if needed and have an
385 // option to store custom data in XattrOp::xinfo.
386 int (Server::*validate)(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
387 XattrOp *xattr_op);
388
389 // set xattr for an inode in xattr_map
390 void (Server::*setxattr)(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
391 const XattrOp &xattr_op);
392
393 // remove xattr for an inode from xattr_map
394 void (Server::*removexattr)(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
395 const XattrOp &xattr_op);
396 };
397
398 inline static const std::string DEFAULT_HANDLER = "<default>";
399 static const XattrHandler xattr_handlers[];
400
401 const XattrHandler* get_xattr_or_default_handler(std::string_view xattr_name);
402
403 // generic variant to set/remove xattr in/from xattr_map
404 int xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
405 const std::string &xattr_name, int op, int flags);
406 void xattr_set(InodeStoreBase::xattr_map_ptr xattrs, const std::string &xattr_name,
407 const bufferlist &xattr_value);
408 void xattr_rm(InodeStoreBase::xattr_map_ptr xattrs, const std::string &xattr_name);
409
410 // default xattr handlers
411 int default_xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
412 XattrOp *xattr_op);
413 void default_setxattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
414 const XattrOp &xattr_op);
415 void default_removexattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
416 const XattrOp &xattr_op);
417
418 // mirror info xattr handler
419 int parse_mirror_info_xattr(const std::string &name, const std::string &value,
420 std::string &cluster_id, std::string &fs_id);
421 int mirror_info_xattr_validate(CInode *cur, const InodeStoreBase::xattr_map_const_ptr xattrs,
422 XattrOp *xattr_op);
423 void mirror_info_setxattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
424 const XattrOp &xattr_op);
425 void mirror_info_removexattr_handler(CInode *cur, InodeStoreBase::xattr_map_ptr xattrs,
426 const XattrOp &xattr_op);
427
428 static bool is_ceph_vxattr(std::string_view xattr_name) {
429 return xattr_name.rfind("ceph.dir.layout", 0) == 0 ||
430 xattr_name.rfind("ceph.file.layout", 0) == 0 ||
431 xattr_name.rfind("ceph.quota", 0) == 0 ||
432 xattr_name == "ceph.dir.subvolume" ||
433 xattr_name == "ceph.dir.pin" ||
434 xattr_name == "ceph.dir.pin.random" ||
435 xattr_name == "ceph.dir.pin.distributed";
436 }
437
438 static bool is_ceph_dir_vxattr(std::string_view xattr_name) {
439 return (xattr_name == "ceph.dir.layout" ||
440 xattr_name == "ceph.dir.layout.json" ||
441 xattr_name == "ceph.dir.layout.object_size" ||
442 xattr_name == "ceph.dir.layout.stripe_unit" ||
443 xattr_name == "ceph.dir.layout.stripe_count" ||
444 xattr_name == "ceph.dir.layout.pool" ||
445 xattr_name == "ceph.dir.layout.pool_name" ||
446 xattr_name == "ceph.dir.layout.pool_id" ||
447 xattr_name == "ceph.dir.layout.pool_namespace" ||
448 xattr_name == "ceph.dir.pin" ||
449 xattr_name == "ceph.dir.pin.random" ||
450 xattr_name == "ceph.dir.pin.distributed");
451 }
452
453 static bool is_ceph_file_vxattr(std::string_view xattr_name) {
454 return (xattr_name == "ceph.file.layout" ||
455 xattr_name == "ceph.file.layout.json" ||
456 xattr_name == "ceph.file.layout.object_size" ||
457 xattr_name == "ceph.file.layout.stripe_unit" ||
458 xattr_name == "ceph.file.layout.stripe_count" ||
459 xattr_name == "ceph.file.layout.pool" ||
460 xattr_name == "ceph.file.layout.pool_name" ||
461 xattr_name == "ceph.file.layout.pool_id" ||
462 xattr_name == "ceph.file.layout.pool_namespace");
463 }
464
465 static bool is_allowed_ceph_xattr(std::string_view xattr_name) {
466 // not a ceph xattr -- allow!
467 if (xattr_name.rfind("ceph.", 0) != 0) {
468 return true;
469 }
470
471 return xattr_name == "ceph.mirror.info" ||
472 xattr_name == "ceph.mirror.dirty_snap_id";
473 }
474
475 void reply_client_request(MDRequestRef& mdr, const ref_t<MClientReply> &reply);
476 void flush_session(Session *session, MDSGatherBuilder& gather);
477
478 void _finalize_readdir(MDRequestRef& mdr,
479 CInode *diri,
480 CDir* dir,
481 bool start,
482 bool end,
483 __u16 flags,
484 __u32 numfiles,
485 bufferlist& dirbl,
486 bufferlist& dnbl);
487 void _readdir_diff(
488 utime_t now,
489 MDRequestRef& mdr,
490 CInode* diri,
491 CDir* dir,
492 SnapRealm* realm,
493 unsigned max_entries,
494 int bytes_left,
495 const std::string& offset_str,
496 uint32_t offset_hash,
497 unsigned req_flags,
498 bufferlist& dirbl);
499 bool build_snap_diff(
500 MDRequestRef& mdr,
501 CDir* dir,
502 int bytes_left,
503 dentry_key_t* skip_key,
504 snapid_t snapid_before,
505 snapid_t snapid,
506 const bufferlist& dnbl,
507 std::function<bool(CDentry*, CInode*, bool)> add_result_cb);
508
509 MDSRank *mds;
510 MDCache *mdcache;
511 MDLog *mdlog;
512 PerfCounters *logger = nullptr;
513
514 // OSDMap full status, used to generate CEPHFS_ENOSPC on some operations
515 bool is_full = false;
516
517 // State for while in reconnect
518 MDSContext *reconnect_done = nullptr;
519 int failed_reconnects = 0;
520 bool reconnect_evicting = false; // true if I am waiting for evictions to complete
521 // before proceeding to reconnect_gather_finish
522 time reconnect_start = clock::zero();
523 time reconnect_last_seen = clock::zero();
524 std::set<client_t> client_reconnect_gather; // clients i need a reconnect msg from.
525 std::set<client_t> client_reconnect_denied; // clients whose reconnect msg have been denied .
526
527 feature_bitset_t supported_features;
528 feature_bitset_t supported_metric_spec;
529 feature_bitset_t required_client_features;
530
531 bool forward_all_requests_to_auth = false;
532 bool replay_unsafe_with_closed_session = false;
533 double cap_revoke_eviction_timeout = 0;
534 uint64_t max_snaps_per_dir = 100;
535 // long snapshot names have the following format: "_<SNAPSHOT-NAME>_<INODE-NUMBER>"
536 uint64_t snapshot_name_max = NAME_MAX - 1 - 1 - 13;
537 unsigned delegate_inos_pct = 0;
538 uint64_t dir_max_entries = 0;
539 int64_t bal_fragment_size_max = 0;
540
541 double inject_rename_corrupt_dentry_first = 0.0;
542
543 DecayCounter recall_throttle;
544 time last_recall_state;
545
546 MetricsHandler *metrics_handler;
547
548 // Cache cap acquisition throttle configs
549 uint64_t max_caps_per_client;
550 uint64_t cap_acquisition_throttle;
551 double max_caps_throttle_ratio;
552 double caps_throttle_retry_request_timeout;
553
554 size_t alternate_name_max = g_conf().get_val<Option::size_t>("mds_alternate_name_max");
555 size_t fscrypt_last_block_max_size = g_conf().get_val<Option::size_t>("mds_fscrypt_last_block_max_size");
556 };
557
558 static inline constexpr auto operator|(Server::RecallFlags a, Server::RecallFlags b) {
559 using T = std::underlying_type<Server::RecallFlags>::type;
560 return static_cast<Server::RecallFlags>(static_cast<T>(a) | static_cast<T>(b));
561 }
562 static inline constexpr auto operator&(Server::RecallFlags a, Server::RecallFlags b) {
563 using T = std::underlying_type<Server::RecallFlags>::type;
564 return static_cast<Server::RecallFlags>(static_cast<T>(a) & static_cast<T>(b));
565 }
566 static inline std::ostream& operator<<(std::ostream& os, const Server::RecallFlags& f) {
567 using T = std::underlying_type<Server::RecallFlags>::type;
568 return os << "0x" << std::hex << static_cast<T>(f) << std::dec;
569 }
570 static inline constexpr bool operator!(const Server::RecallFlags& f) {
571 using T = std::underlying_type<Server::RecallFlags>::type;
572 return static_cast<T>(f) == static_cast<T>(0);
573 }
574 #endif