]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: pool_opts_t: int -> int64_t
authorSage Weil <sage@redhat.com>
Wed, 28 Nov 2018 22:27:14 +0000 (16:27 -0600)
committerSage Weil <sage@redhat.com>
Tue, 18 Dec 2018 19:30:54 +0000 (13:30 -0600)
Encode int32_t for pre-nautilus maps.

Fix up accessors.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mon/OSDMonitor.cc
src/os/bluestore/BlueStore.cc
src/osd/PG.cc
src/osd/PrimaryLogPG.h
src/osd/osd_types.cc
src/osd/osd_types.h

index 9b90f19d316b2afcaec6ddfddf7573461f4964f7..f73c48599d39f8c5c720563e7fef6ec169a26f92 100644 (file)
@@ -5330,7 +5330,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
             pool_opts_t::key_t key = pool_opts_t::get_opt_desc(i->first).key;
             if (p->opts.is_set(key)) {
               if(*it == CSUM_TYPE) {
-                int val;
+                int64_t val;
                 p->opts.get(pool_opts_t::CSUM_TYPE, &val);
                 f->dump_string(i->first.c_str(), Checksummer::get_csum_type_string(val));
               } else {
@@ -5492,7 +5492,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op)
              pool_opts_t::key_t key = pool_opts_t::get_opt_desc(i->first).key;
              if (p->opts.is_set(key)) {
                 if(key == pool_opts_t::CSUM_TYPE) {
-                  int val;
+                  int64_t val;
                   p->opts.get(key, &val);
                  ss << i->first << ": " << Checksummer::get_csum_type_string(val) << "\n";
                 } else {
@@ -6818,7 +6818,7 @@ int OSDMonitor::prepare_new_pool(string& name,
   pi->set_pgp_num(pi->get_pg_num());
   pi->set_pgp_num_target(pgp_num);
   if (pg_num_min) {
-    pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast<int>(pg_num_min));
+    pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast<int64_t>(pg_num_min));
   }
 
   pi->last_change = pending_inc.epoch;
@@ -7427,7 +7427,7 @@ int OSDMonitor::prepare_command_pool_set(const cmdmap_t& cmdmap,
       if (n == 0) {
        p.opts.unset(desc.key);
       } else {
-       p.opts.set(desc.key, static_cast<int>(n));
+       p.opts.set(desc.key, static_cast<int64_t>(n));
       }
       break;
     case pool_opts_t::DOUBLE:
index 08c6f57907a6987f6102130596cce9deb9482f91..3e27fd69210467d37e61f1272c0fede62dd7b27c 100644 (file)
@@ -11620,16 +11620,16 @@ int BlueStore::_do_alloc_write(
   }
 
   // checksum
-  int csum = csum_type.load();
+  int64_t csum = csum_type.load();
   csum = select_option(
     "csum_type",
     csum,
     [&]() {
-      int val;
+      int64_t val;
       if (coll->pool_opts.get(pool_opts_t::CSUM_TYPE, &val)) {
-        return  boost::optional<int>(val);
+        return boost::optional<int64_t>(val);
       }
-      return boost::optional<int>();
+      return boost::optional<int64_t>();
     }
   );
 
@@ -12014,7 +12014,7 @@ void BlueStore::_choose_write_options(
         "compression_max_blob_size",
         comp_max_blob_size.load(),
         [&]() {
-          int val;
+          int64_t val;
           if (c->pool_opts.get(pool_opts_t::COMPRESSION_MAX_BLOB_SIZE, &val)) {
            return boost::optional<uint64_t>((uint64_t)val);
           }
@@ -12028,7 +12028,7 @@ void BlueStore::_choose_write_options(
         "compression_min_blob_size",
         comp_min_blob_size.load(),
         [&]() {
-          int val;
+          int64_t val;
           if (c->pool_opts.get(pool_opts_t::COMPRESSION_MIN_BLOB_SIZE, &val)) {
            return boost::optional<uint64_t>((uint64_t)val);
           }
index 49345cc2a61ccdc7e73beb93c3b8285475614fef..6ac9b4b9849f5d0318b013e2b5541622f8c407ef 100644 (file)
@@ -2333,7 +2333,7 @@ bool PG::queue_scrub()
 unsigned PG::get_scrub_priority()
 {
   // a higher value -> a higher priority
-  int pool_scrub_priority = 0;
+  int64_t pool_scrub_priority = 0;
   pool.info.opts.get(pool_opts_t::SCRUB_PRIORITY, &pool_scrub_priority);
   return pool_scrub_priority > 0 ? pool_scrub_priority : cct->_conf->osd_scrub_priority;
 }
@@ -2441,7 +2441,7 @@ inline int PG::clamp_recovery_priority(int priority)
 unsigned PG::get_recovery_priority()
 {
   // a higher value -> a higher priority
-  int ret = 0;
+  int64_t ret = 0;
 
   if (state & PG_STATE_FORCED_RECOVERY) {
     ret = OSD_RECOVERY_PRIORITY_FORCED;
@@ -2475,7 +2475,7 @@ unsigned PG::get_backfill_priority()
     }
 
     // Adjust with pool's recovery priority
-    int pool_recovery_priority = 0;
+    int64_t pool_recovery_priority = 0;
     pool.info.opts.get(pool_opts_t::RECOVERY_PRIORITY, &pool_recovery_priority);
 
     ret = clamp_recovery_priority(pool_recovery_priority + ret);
index bffb2ee98ae39ae1c2f026eb5f1a05adcd84b0ac..81574aad341fdca108bc7c961401860782da0e19 100644 (file)
@@ -1481,9 +1481,9 @@ private:
   hobject_t get_temp_recovery_object(const hobject_t& target,
                                     eversion_t version) override;
   int get_recovery_op_priority() const {
-      int pri = 0;
-      pool.info.opts.get(pool_opts_t::RECOVERY_OP_PRIORITY, &pri);
-      return  pri > 0 ? pri : cct->_conf->osd_recovery_op_priority;
+    int64_t pri = 0;
+    pool.info.opts.get(pool_opts_t::RECOVERY_OP_PRIORITY, &pri);
+    return  pri > 0 ? pri : cct->_conf->osd_recovery_op_priority;
   }
   void log_missing(unsigned missing,
                        const boost::optional<hobject_t> &head,
index 7199b9b6e890d8b4e21a38b50a9a177c0da3946b..ec5eba4af447450830f46bedb132ccf8f331848d 100644 (file)
@@ -1154,7 +1154,7 @@ public:
   void operator()(std::string s) const {
     f->dump_string(name, s);
   }
-  void operator()(int i) const {
+  void operator()(int64_t i) const {
     f->dump_int(name, i);
   }
   void operator()(double d) const {
@@ -1192,15 +1192,21 @@ void pool_opts_t::dump(Formatter* f) const
 
 class pool_opts_encoder_t : public boost::static_visitor<> {
 public:
-  explicit pool_opts_encoder_t(bufferlist& bl_, uint64_t features) : bl(bl_) {}
+  explicit pool_opts_encoder_t(bufferlist& bl_, uint64_t features)
+    : bl(bl_),
+      features(features) {}
 
   void operator()(const std::string &s) const {
     encode(static_cast<int32_t>(pool_opts_t::STR), bl);
     encode(s, bl);
   }
-  void operator()(int i) const {
+  void operator()(int64_t i) const {
     encode(static_cast<int32_t>(pool_opts_t::INT), bl);
-    encode(i, bl);
+    if (HAVE_FEATURE(features, SERVER_NAUTILUS)) {
+      encode(i, bl);
+    } else {
+      encode(static_cast<int32_t>(i), bl);
+    }
   }
   void operator()(double d) const {
     encode(static_cast<int32_t>(pool_opts_t::DOUBLE), bl);
@@ -1209,11 +1215,16 @@ public:
 
 private:
   bufferlist& bl;
+  uint64_t features;
 };
 
 void pool_opts_t::encode(bufferlist& bl, uint64_t features) const
 {
-  ENCODE_START(1, 1, bl);
+  unsigned v = 2;
+  if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
+    v = 1;
+  }
+  ENCODE_START(v, 1, bl);
   uint32_t n = static_cast<uint32_t>(opts.size());
   encode(n, bl);
   for (opts_t::const_iterator i = opts.begin(); i != opts.end(); ++i) {
@@ -1238,8 +1249,14 @@ void pool_opts_t::decode(bufferlist::const_iterator& bl)
       decode(s, bl);
       opts[static_cast<key_t>(k)] = s;
     } else if (t == INT) {
-      int i;
-      decode(i, bl);
+      int64_t i;
+      if (struct_v >= 2) {
+       decode(i, bl);
+      } else {
+       int ii;
+       decode(ii, bl);
+       i = ii;
+      }
       opts[static_cast<key_t>(k)] = i;
     } else if (t == DOUBLE) {
       double d;
index 6f34202d5053640ce8cf38b58f1aea86b9e46430..bf4b90d382a8552cba9d9f407bd6a3552495fdb5 100644 (file)
@@ -1029,7 +1029,7 @@ public:
     }
   };
 
-  typedef boost::variant<std::string,int,double> value_t;
+  typedef boost::variant<std::string,int64_t,double> value_t;
 
   static bool is_opt_name(const std::string& name);
   static opt_desc_t get_opt_desc(const std::string& name);