]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/mon/OSDMonitor.h
update sources to 12.2.2
[ceph.git] / ceph / src / mon / OSDMonitor.h
index 44f013f27f756c15221ffb47c2c570ca9a592900..9767f10035780898e1f6ac141e08791b22082e50 100644 (file)
@@ -43,8 +43,6 @@ class MOSDMap;
 #include "erasure-code/ErasureCodeInterface.h"
 #include "mon/MonOpRequest.h"
 
-#define OSD_METADATA_PREFIX "osd_metadata"
-
 /// information about a particular peer's failure reports for one osd
 struct failure_reporter_t {
   utime_t failed_since;     ///< when they think it failed
@@ -147,7 +145,7 @@ public:
 
   bool check_failures(utime_t now);
   bool check_failure(utime_t now, int target_osd, failure_info_t& fi);
-  void force_failure(utime_t now, int target_osd);
+  void force_failure(int target_osd, int by);
 
   // the time of last msg(MSG_ALIVE and MSG_PGTEMP) proposed without delay
   utime_t last_attempted_minwait_time;
@@ -316,20 +314,20 @@ private:
                        ErasureCodeProfile &profile,
                        bool force,
                        ostream *ss);
-  int crush_ruleset_create_erasure(const string &name,
-                                  const string &profile,
-                                  int *ruleset,
-                                  ostream *ss);
-  int get_crush_ruleset(const string &ruleset_name,
-                       int *crush_ruleset,
+  int crush_rule_create_erasure(const string &name,
+                               const string &profile,
+                               int *rule,
+                               ostream *ss);
+  int get_crush_rule(const string &rule_name,
+                       int *crush_rule,
                        ostream *ss);
   int get_erasure_code(const string &erasure_code_profile,
                       ErasureCodeInterfaceRef *erasure_code,
                       ostream *ss) const;
-  int prepare_pool_crush_ruleset(const unsigned pool_type,
+  int prepare_pool_crush_rule(const unsigned pool_type,
                                 const string &erasure_code_profile,
-                                const string &ruleset_name,
-                                int *crush_ruleset,
+                                const string &rule_name,
+                                int *crush_rule,
                                 ostream *ss);
   bool erasure_code_profile_in_use(
     const mempool::osdmap::map<int64_t, pg_pool_t> &pools,
@@ -346,9 +344,10 @@ private:
                                const string &erasure_code_profile,
                                unsigned *stripe_width,
                                ostream *ss);
+  int check_pg_num(int64_t pool, int pg_num, int size, ostream* ss);
   int prepare_new_pool(string& name, uint64_t auid,
-                      int crush_ruleset,
-                      const string &crush_ruleset_name,
+                      int crush_rule,
+                      const string &crush_rule_name,
                        unsigned pg_num, unsigned pgp_num,
                       const string &erasure_code_profile,
                        const unsigned pool_type,
@@ -357,10 +356,9 @@ private:
                       ostream *ss);
   int prepare_new_pool(MonOpRequestRef op);
 
-  void update_pool_flags(int64_t pool_id, uint64_t flags);
+  void set_pool_flags(int64_t pool_id, uint64_t flags);
+  void clear_pool_flags(int64_t pool_id, uint64_t flags);
   bool update_pools_status();
-  void get_pools_health(list<pair<health_status_t,string> >& summary,
-                        list<pair<health_status_t,string> > *detail) const;
 
   bool prepare_set_flag(MonOpRequestRef op, int flag);
   bool prepare_unset_flag(MonOpRequestRef op, int flag);
@@ -429,6 +427,10 @@ private:
   OpTracker op_tracker;
 
   int load_metadata(int osd, map<string, string>& m, ostream *err);
+  void count_metadata(const string& field, Formatter *f);
+public:
+  void count_metadata(const string& field, map<string,int> *out);
+protected:
   int get_osd_objectstore_type(int osd, std::string *type);
   bool is_pool_currently_all_bluestore(int64_t pool_id, const pg_pool_t &pool,
                                       ostream *err);
@@ -449,11 +451,12 @@ private:
   // the epoch when the pg mapping was calculated
   epoch_t creating_pgs_epoch = 0;
   creating_pgs_t creating_pgs;
-  std::mutex creating_pgs_lock;
+  mutable std::mutex creating_pgs_lock;
 
   creating_pgs_t update_pending_pgs(const OSDMap::Incremental& inc);
-  void trim_creating_pgs(creating_pgs_t *creating_pgs, const PGMap& pgm);
-  void scan_for_creating_pgs(
+  void trim_creating_pgs(creating_pgs_t *creating_pgs,
+                        const ceph::unordered_map<pg_t,pg_stat_t>& pgm);
+  unsigned scan_for_creating_pgs(
     const mempool::osdmap::map<int64_t,pg_pool_t>& pools,
     const mempool::osdmap::set<int64_t>& removed_pools,
     utime_t modified,
@@ -461,15 +464,15 @@ private:
   pair<int32_t, pg_t> get_parent_pg(pg_t pgid) const;
   void update_creating_pgs();
   void check_pg_creates_subs();
-  epoch_t send_pg_creates(int osd, Connection *con, epoch_t next);
+  epoch_t send_pg_creates(int osd, Connection *con, epoch_t next) const;
+
+  int32_t _allocate_osd_id(int32_t* existing_id);
 
 public:
   OSDMonitor(CephContext *cct, Monitor *mn, Paxos *p, const string& service_name);
 
   void tick() override;  // check state, take actions
 
-  int parse_osd_id(const char *s, stringstream *pss);
-
   void get_health(list<pair<health_status_t,string> >& summary,
                  list<pair<health_status_t,string> > *detail,
                  CephContext *cct) const override;
@@ -477,8 +480,46 @@ public:
   bool prepare_command(MonOpRequestRef op);
   bool prepare_command_impl(MonOpRequestRef op, map<string,cmd_vartype>& cmdmap);
 
+  int validate_osd_create(
+      const int32_t id,
+      const uuid_d& uuid,
+      const bool check_osd_exists,
+      int32_t* existing_id,
+      stringstream& ss);
+  int prepare_command_osd_create(
+      const int32_t id,
+      const uuid_d& uuid,
+      int32_t* existing_id,
+      stringstream& ss);
+  void do_osd_create(const int32_t id, const uuid_d& uuid, int32_t* new_id);
+  int prepare_command_osd_purge(int32_t id, stringstream& ss);
+  int prepare_command_osd_destroy(int32_t id, stringstream& ss);
+  int _prepare_command_osd_crush_remove(
+      CrushWrapper &newcrush,
+      int32_t id,
+      int32_t ancestor,
+      bool has_ancestor,
+      bool unlink_only);
+  void do_osd_crush_remove(CrushWrapper& newcrush);
+  int prepare_command_osd_crush_remove(
+      CrushWrapper &newcrush,
+      int32_t id,
+      int32_t ancestor,
+      bool has_ancestor,
+      bool unlink_only);
+  int prepare_command_osd_remove(int32_t id);
+  int prepare_command_osd_new(
+      MonOpRequestRef op,
+      const map<string,cmd_vartype>& cmdmap,
+      const map<string,string>& secrets,
+      stringstream &ss,
+      Formatter *f);
+
   int prepare_command_pool_set(map<string,cmd_vartype> &cmdmap,
                                stringstream& ss);
+  int prepare_command_pool_application(const string &prefix,
+                                       map<string,cmd_vartype> &cmdmap,
+                                       stringstream& ss);
 
   bool handle_osd_timeouts(const utime_t &now,
                           std::map<int,utime_t> &last_osd_report);
@@ -501,6 +542,8 @@ public:
   void check_osdmap_sub(Subscription *sub);
   void check_pg_creates_sub(Subscription *sub);
 
+  void do_application_enable(int64_t pool_id, const std::string &app_name);
+
   void add_flag(int flag) {
     if (!(osdmap.flags & flag)) {
       if (pending_inc.new_flags < 0)