]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mds/Server.h
update ceph source to reef 18.2.0
[ceph.git] / ceph / src / mds / Server.h
index 7297fd56b62313a8907844df9dd39b1253ddfa54..a269d6cb4790512ddeee95e40cfbcfdcdc0281ec 100644 (file)
@@ -80,6 +80,7 @@ enum {
   l_mdss_req_unlink_latency,
   l_mdss_cap_revoke_eviction,
   l_mdss_cap_acquisition_throttle,
+  l_mdss_req_getvxattr_latency,
   l_mdss_last,
 };
 
@@ -95,6 +96,7 @@ public:
     TRIM = (1<<2),
     ENFORCE_LIVENESS = (1<<3),
   };
+
   explicit Server(MDSRank *m, MetricsHandler *metrics_handler);
   ~Server() {
     g_ceph_context->get_perfcounters_collection()->remove(logger);
@@ -121,18 +123,18 @@ public:
   void _session_logged(Session *session, uint64_t state_seq, bool open, version_t pv,
                       const interval_set<inodeno_t>& inos_to_free, version_t piv,
                       const interval_set<inodeno_t>& inos_to_purge, LogSegment *ls);
-  version_t prepare_force_open_sessions(map<client_t,entity_inst_t> &cm,
-                                       map<client_t,client_metadata_t>& cmm,
-                                       map<client_t,pair<Session*,uint64_t> >& smap);
-  void finish_force_open_sessions(const map<client_t,pair<Session*,uint64_t> >& smap,
+  version_t prepare_force_open_sessions(std::map<client_t,entity_inst_t> &cm,
+                                       std::map<client_t,client_metadata_t>& cmm,
+                                       std::map<client_t,std::pair<Session*,uint64_t> >& smap);
+  void finish_force_open_sessions(const std::map<client_t,std::pair<Session*,uint64_t> >& smap,
                                  bool dec_import=true);
-  void flush_client_sessions(set<client_t>& client_set, MDSGatherBuilder& gather);
+  void flush_client_sessions(std::set<client_t>& client_set, MDSGatherBuilder& gather);
   void finish_flush_session(Session *session, version_t seq);
   void terminate_sessions();
   void find_idle_sessions();
 
   void kill_session(Session *session, Context *on_safe);
-  size_t apply_blocklist(const std::set<entity_addr_t> &blocklist);
+  size_t apply_blocklist();
   void journal_close_session(Session *session, int state, Context *on_safe);
 
   size_t get_num_pending_reclaim() const { return client_reclaim_gather.size(); }
@@ -156,6 +158,7 @@ public:
 
   // -- requests --
   void handle_client_request(const cref_t<MClientRequest> &m);
+  void handle_client_reply(const cref_t<MClientReply> &m);
 
   void journal_and_reply(MDRequestRef& mdr, CInode *tracei, CDentry *tracedn,
                         LogEvent *le, MDSLogContextBase *fin);
@@ -176,6 +179,7 @@ public:
 
   // some helpers
   bool check_fragment_space(MDRequestRef& mdr, CDir *in);
+  bool check_dir_max_entries(MDRequestRef& mdr, CDir *in);
   bool check_access(MDRequestRef& mdr, CInode *in, unsigned mask);
   bool _check_access(Session *session, CInode *in, unsigned mask, int caller_uid, int caller_gid, int setattr_uid, int setattr_gid);
   CDentry *prepare_stray_dentry(MDRequestRef& mdr, CInode *in);
@@ -184,10 +188,12 @@ public:
   void journal_allocated_inos(MDRequestRef& mdr, EMetaBlob *blob);
   void apply_allocated_inos(MDRequestRef& mdr, Session *session);
 
+  void _try_open_ino(MDRequestRef& mdr, int r, inodeno_t ino);
   CInode* rdlock_path_pin_ref(MDRequestRef& mdr, bool want_auth,
                              bool no_want_auth=false);
   CDentry* rdlock_path_xlock_dentry(MDRequestRef& mdr, bool create,
-                                   bool okexist=false, bool want_layout=false);
+                                   bool okexist=false, bool authexist=false,
+                                   bool want_layout=false);
   std::pair<CDentry*, CDentry*>
            rdlock_two_paths_xlock_destdn(MDRequestRef& mdr, bool xlock_srcdn);
 
@@ -210,21 +216,32 @@ public:
   void handle_client_setlayout(MDRequestRef& mdr);
   void handle_client_setdirlayout(MDRequestRef& mdr);
 
-  int parse_quota_vxattr(string name, string value, quota_info_t *quota);
+  int parse_quota_vxattr(std::string name, std::string value, quota_info_t *quota);
   void create_quota_realm(CInode *in);
-  int parse_layout_vxattr(string name, string value, const OSDMap& osdmap,
+  int parse_layout_vxattr_json(std::string name, std::string value,
+                              const OSDMap& osdmap, file_layout_t *layout);
+  int parse_layout_vxattr_string(std::string name, std::string value, const OSDMap& osdmap,
+                                file_layout_t *layout);
+  int parse_layout_vxattr(std::string name, std::string value, const OSDMap& osdmap,
                          file_layout_t *layout, bool validate=true);
   int check_layout_vxattr(MDRequestRef& mdr,
-                          string name,
-                          string value,
+                          std::string name,
+                          std::string value,
                           file_layout_t *layout);
   void handle_set_vxattr(MDRequestRef& mdr, CInode *cur);
   void handle_remove_vxattr(MDRequestRef& mdr, CInode *cur);
+  void handle_client_getvxattr(MDRequestRef& mdr);
   void handle_client_setxattr(MDRequestRef& mdr);
   void handle_client_removexattr(MDRequestRef& mdr);
 
   void handle_client_fsync(MDRequestRef& mdr);
 
+  bool is_unlink_pending(CDentry *dn);
+  void wait_for_pending_unlink(CDentry *dn, MDRequestRef& mdr);
+
+  bool is_reintegrate_pending(CDentry *dn);
+  void wait_for_pending_reintegrate(CDentry *dn, MDRequestRef& mdr);
+
   // open
   void handle_client_open(MDRequestRef& mdr);
   void handle_client_openc(MDRequestRef& mdr);  // O_CREAT variant.
@@ -252,7 +269,7 @@ public:
   void handle_peer_link_prep_ack(MDRequestRef& mdr, const cref_t<MMDSPeerRequest> &m);
   void do_link_rollback(bufferlist &rbl, mds_rank_t leader, MDRequestRef& mdr);
   void _link_rollback_finish(MutationRef& mut, MDRequestRef& mdr,
-                            map<client_t,ref_t<MClientSnap>>& split);
+                            std::map<client_t,ref_t<MClientSnap>>& split);
 
   // unlink
   void handle_client_unlink(MDRequestRef& mdr);
@@ -262,7 +279,7 @@ public:
   void _unlink_local_finish(MDRequestRef& mdr,
                            CDentry *dn, CDentry *straydn,
                            version_t);
-  bool _rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, vector<CDentry*>& trace, CDentry *straydn);
+  bool _rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, std::vector<CDentry*>& trace, CDentry *straydn);
   void handle_peer_rmdir_prep(MDRequestRef& mdr);
   void _logged_peer_rmdir(MDRequestRef& mdr, CDentry *srcdn, CDentry *straydn);
   void _commit_peer_rmdir(MDRequestRef& mdr, int r, CDentry *straydn);
@@ -284,8 +301,8 @@ public:
   void _renamesnap_finish(MDRequestRef& mdr, CInode *diri, snapid_t snapid);
 
   // helpers
-  bool _rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set<mds_rank_t> &witnesse,
-                              vector<CDentry*>& srctrace, vector<CDentry*>& dsttrace, CDentry *straydn);
+  bool _rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, std::set<mds_rank_t> &witnesse,
+                              std::vector<CDentry*>& srctrace, std::vector<CDentry*>& dsttrace, CDentry *straydn);
   version_t _rename_prepare_import(MDRequestRef& mdr, CDentry *srcdn, bufferlist *client_map_bl);
   bool _need_force_journal(CInode *diri, bool empty);
   void _rename_prepare(MDRequestRef& mdr,
@@ -306,7 +323,7 @@ public:
   void _commit_peer_rename(MDRequestRef& mdr, int r, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
   void do_rename_rollback(bufferlist &rbl, mds_rank_t leader, MDRequestRef& mdr, bool finish_mdr=false);
   void _rename_rollback_finish(MutationRef& mut, MDRequestRef& mdr, CDentry *srcdn, version_t srcdnpv,
-                              CDentry *destdn, CDentry *staydn, map<client_t,ref_t<MClientSnap>> splits[2],
+                              CDentry *destdn, CDentry *staydn, std::map<client_t,ref_t<MClientSnap>> splits[2],
                               bool finish_mdr);
 
   void evict_cap_revoke_non_responders();
@@ -314,7 +331,10 @@ public:
 
   bool terminating_sessions = false;
 
-  set<client_t> client_reclaim_gather;
+  std::set<client_t> client_reclaim_gather;
+
+  const bufferlist& get_snap_trace(Session *session, SnapRealm *realm) const;
+  const bufferlist& get_snap_trace(client_t client, SnapRealm *realm) const;
 
 private:
   friend class MDSContinuation;
@@ -414,10 +434,37 @@ private:
     return xattr_name.rfind("ceph.dir.layout", 0) == 0 ||
            xattr_name.rfind("ceph.file.layout", 0) == 0 ||
            xattr_name.rfind("ceph.quota", 0) == 0 ||
-           xattr_name == "ceph.dir.subvolume"sv ||
-           xattr_name == "ceph.dir.pin"sv ||
-           xattr_name == "ceph.dir.pin.random"sv ||
-           xattr_name == "ceph.dir.pin.distributed"sv;
+           xattr_name == "ceph.dir.subvolume" ||
+           xattr_name == "ceph.dir.pin" ||
+           xattr_name == "ceph.dir.pin.random" ||
+           xattr_name == "ceph.dir.pin.distributed";
+  }
+
+  static bool is_ceph_dir_vxattr(std::string_view xattr_name) {
+    return (xattr_name == "ceph.dir.layout" ||
+           xattr_name == "ceph.dir.layout.json" ||
+           xattr_name == "ceph.dir.layout.object_size" ||
+           xattr_name == "ceph.dir.layout.stripe_unit" ||
+           xattr_name == "ceph.dir.layout.stripe_count" ||
+           xattr_name == "ceph.dir.layout.pool" ||
+           xattr_name == "ceph.dir.layout.pool_name" ||
+           xattr_name == "ceph.dir.layout.pool_id" ||
+           xattr_name == "ceph.dir.layout.pool_namespace" ||
+           xattr_name == "ceph.dir.pin" ||
+           xattr_name == "ceph.dir.pin.random" ||
+           xattr_name == "ceph.dir.pin.distributed");
+  }
+
+  static bool is_ceph_file_vxattr(std::string_view xattr_name) {
+    return (xattr_name == "ceph.file.layout" ||
+           xattr_name == "ceph.file.layout.json" ||
+           xattr_name == "ceph.file.layout.object_size" ||
+           xattr_name == "ceph.file.layout.stripe_unit" ||
+           xattr_name == "ceph.file.layout.stripe_count" ||
+           xattr_name == "ceph.file.layout.pool" ||
+           xattr_name == "ceph.file.layout.pool_name" ||
+           xattr_name == "ceph.file.layout.pool_id" ||
+           xattr_name == "ceph.file.layout.pool_namespace");
   }
 
   static bool is_allowed_ceph_xattr(std::string_view xattr_name) {
@@ -448,17 +495,24 @@ private:
                             // before proceeding to reconnect_gather_finish
   time reconnect_start = clock::zero();
   time reconnect_last_seen = clock::zero();
-  set<client_t> client_reconnect_gather;  // clients i need a reconnect msg from.
-  set<client_t> client_reconnect_denied;  // clients whose reconnect msg have been denied .
+  std::set<client_t> client_reconnect_gather;  // clients i need a reconnect msg from.
+  std::set<client_t> client_reconnect_denied;  // clients whose reconnect msg have been denied .
 
   feature_bitset_t supported_features;
+  feature_bitset_t supported_metric_spec;
   feature_bitset_t required_client_features;
 
   bool forward_all_requests_to_auth = false;
   bool replay_unsafe_with_closed_session = false;
   double cap_revoke_eviction_timeout = 0;
   uint64_t max_snaps_per_dir = 100;
+  // long snapshot names have the following format: "_<SNAPSHOT-NAME>_<INODE-NUMBER>"
+  uint64_t snapshot_name_max = NAME_MAX - 1 - 1 - 13;
   unsigned delegate_inos_pct = 0;
+  uint64_t dir_max_entries = 0;
+  int64_t bal_fragment_size_max = 0;
+
+  double inject_rename_corrupt_dentry_first = 0.0;
 
   DecayCounter recall_throttle;
   time last_recall_state;
@@ -472,6 +526,7 @@ private:
   double caps_throttle_retry_request_timeout;
 
   size_t alternate_name_max = g_conf().get_val<Option::size_t>("mds_alternate_name_max");
+  size_t fscrypt_last_block_max_size = g_conf().get_val<Option::size_t>("mds_fscrypt_last_block_max_size");
 };
 
 static inline constexpr auto operator|(Server::RecallFlags a, Server::RecallFlags b) {