From: Sage Weil Date: Wed, 28 Nov 2018 22:27:14 +0000 (-0600) Subject: osd/osd_types: pool_opts_t: int -> int64_t X-Git-Tag: v14.1.0~582^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0846da1a9cfd1ae7436f744dc19e84cc7545ed89;p=ceph.git osd/osd_types: pool_opts_t: int -> int64_t Encode int32_t for pre-nautilus maps. Fix up accessors. Signed-off-by: Sage Weil --- diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 9b90f19d316b..f73c48599d39 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -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(pg_num_min)); + pi->opts.set(pool_opts_t::PG_NUM_MIN, static_cast(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(n)); + p.opts.set(desc.key, static_cast(n)); } break; case pool_opts_t::DOUBLE: diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 08c6f57907a6..3e27fd692104 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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(val); + return boost::optional(val); } - return boost::optional(); + return boost::optional(); } ); @@ -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)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)val); } diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 49345cc2a61c..6ac9b4b9849f 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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); diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index bffb2ee98ae3..81574aad341f 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -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 &head, diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 7199b9b6e890..ec5eba4af447 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -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(pool_opts_t::STR), bl); encode(s, bl); } - void operator()(int i) const { + void operator()(int64_t i) const { encode(static_cast(pool_opts_t::INT), bl); - encode(i, bl); + if (HAVE_FEATURE(features, SERVER_NAUTILUS)) { + encode(i, bl); + } else { + encode(static_cast(i), bl); + } } void operator()(double d) const { encode(static_cast(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(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(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(k)] = i; } else if (t == DOUBLE) { double d; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 6f34202d5053..bf4b90d382a8 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -1029,7 +1029,7 @@ public: } }; - typedef boost::variant value_t; + typedef boost::variant value_t; static bool is_opt_name(const std::string& name); static opt_desc_t get_opt_desc(const std::string& name);