Encode int32_t for pre-nautilus maps.
Fix up accessors.
Signed-off-by: Sage Weil <sage@redhat.com>
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 {
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 {
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;
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:
}
// 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>();
}
);
"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);
}
"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);
}
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;
}
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;
}
// 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);
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,
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 {
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);
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) {
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;
}
};
- 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);