mgr,mon: s/boost::optional/std::optional/

since the encoding schemes of boost::optional and std::optional are
identical, they can be used interchangeably.

Signed-off-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2021-06-27 12:01:17 +08:00
parent 32e62f9a64
commit a41b62bd85
21 changed files with 44 additions and 42 deletions

View File

@ -10774,7 +10774,7 @@ int Client::statfs(const char *path, struct statvfs *stbuf,
if (data_pools.size() == 1) {
objecter->get_fs_stats(stats, data_pools[0], &cond);
} else {
objecter->get_fs_stats(stats, boost::optional<int64_t>(), &cond);
objecter->get_fs_stats(stats, std::optional<int64_t>(), &cond);
}
lock.unlock();

View File

@ -646,7 +646,7 @@ int librados::RadosClient::get_fs_stats(ceph_statfs& stats)
int ret = 0;
{
std::lock_guard l{mylock};
objecter->get_fs_stats(stats, boost::optional<int64_t> (),
objecter->get_fs_stats(stats, std::optional<int64_t> (),
new C_SafeCond(mylock, cond, &done, &ret));
}
{

View File

@ -15,7 +15,7 @@ public:
bool incremental = false;
// use transparent comparator so we can lookup in it by std::string_view keys
std::map<std::string,boost::optional<bufferlist>,std::less<>> data;
std::map<std::string,std::optional<bufferlist>,std::less<>> data;
MKVData() : Message{MSG_KV_DATA, HEAD_VERSION, COMPAT_VERSION} { }

View File

@ -16,6 +16,7 @@
#ifndef CEPH_MSTATFS_H
#define CEPH_MSTATFS_H
#include <optional>
#include <sys/statvfs.h> /* or <sys/statfs.h> */
#include "messages/PaxosServiceMessage.h"
@ -26,10 +27,10 @@ private:
public:
uuid_d fsid;
boost::optional<int64_t> data_pool;
std::optional<int64_t> data_pool;
MStatfs() : PaxosServiceMessage{CEPH_MSG_STATFS, 0, HEAD_VERSION, COMPAT_VERSION} {}
MStatfs(const uuid_d& f, ceph_tid_t t, boost::optional<int64_t> _data_pool,
MStatfs(const uuid_d& f, ceph_tid_t t, std::optional<int64_t> _data_pool,
version_t v)
: PaxosServiceMessage{CEPH_MSG_STATFS, v, HEAD_VERSION, COMPAT_VERSION},
fsid(f), data_pool(_data_pool) {
@ -60,7 +61,7 @@ public:
if (header.version >= 2) {
decode(data_pool, p);
} else {
data_pool = boost::optional<int64_t> ();
data_pool = std::optional<int64_t> ();
}
}
private:

View File

@ -661,7 +661,7 @@ PyObject *ActivePyModules::get_store_prefix(const std::string &module_name,
}
void ActivePyModules::set_store(const std::string &module_name,
const std::string &key, const boost::optional<std::string>& val)
const std::string &key, const std::optional<std::string>& val)
{
const std::string global_key = PyModule::mgr_store_prefix
+ module_name + "/" + key;
@ -708,7 +708,7 @@ void ActivePyModules::set_store(const std::string &module_name,
std::pair<int, std::string> ActivePyModules::set_config(
const std::string &module_name,
const std::string &key,
const boost::optional<std::string>& val)
const std::optional<std::string>& val)
{
return module_config.set_config(&monc, module_name, key, val);
}
@ -730,7 +730,7 @@ std::map<std::string, std::string> ActivePyModules::get_services() const
void ActivePyModules::update_kv_data(
const std::string prefix,
bool incremental,
const map<std::string, boost::optional<bufferlist>, std::less<>>& data)
const map<std::string, std::optional<bufferlist>, std::less<>>& data)
{
std::lock_guard l(lock);
bool do_config = false;

View File

@ -127,12 +127,12 @@ public:
PyObject *get_store_prefix(const std::string &module_name,
const std::string &prefix) const;
void set_store(const std::string &module_name,
const std::string &key, const boost::optional<std::string> &val);
const std::string &key, const std::optional<std::string> &val);
bool get_config(const std::string &module_name,
const std::string &key, std::string *val) const;
std::pair<int, std::string> set_config(const std::string &module_name,
const std::string &key, const boost::optional<std::string> &val);
const std::string &key, const std::optional<std::string> &val);
PyObject *get_typed_config(const std::string &module_name,
const std::string &key,
@ -174,7 +174,7 @@ public:
void update_kv_data(
const std::string prefix,
bool incremental,
const map<std::string, boost::optional<bufferlist>, std::less<>>& data);
const map<std::string, std::optional<bufferlist>, std::less<>>& data);
void _refresh_config_map();
// Public so that MonCommandCompletion can use it

View File

@ -486,7 +486,7 @@ ceph_set_module_option(BaseMgrModule *self, PyObject *args)
derr << "Invalid args!" << dendl;
return nullptr;
}
boost::optional<string> val;
std::optional<string> val;
if (value) {
val = value;
}
@ -529,7 +529,7 @@ ceph_store_set(BaseMgrModule *self, PyObject *args)
if (!PyArg_ParseTuple(args, "sz:ceph_store_set", &key, &value)) {
return nullptr;
}
boost::optional<string> val;
std::optional<string> val;
if (value) {
val = value;
}

View File

@ -185,7 +185,7 @@ PyModuleConfig::~PyModuleConfig() = default;
std::pair<int, std::string> PyModuleConfig::set_config(
MonClient *monc,
const std::string &module_name,
const std::string &key, const boost::optional<std::string>& val)
const std::string &key, const std::optional<std::string>& val)
{
const std::string global_key = "mgr/" + module_name + "/" + key;
Command set_cmd;

View File

@ -181,6 +181,6 @@ public:
std::pair<int, std::string> set_config(
MonClient *monc,
const std::string &module_name,
const std::string &key, const boost::optional<std::string>& val);
const std::string &key, const std::optional<std::string>& val);
};

View File

@ -69,7 +69,7 @@ public:
void update_kv_data(
const std::string prefix,
bool incremental,
const map<std::string, boost::optional<bufferlist>, std::less<>>& data) {
const map<std::string, std::optional<bufferlist>, std::less<>>& data) {
ceph_assert(active_modules);
active_modules->update_kv_data(prefix, incremental, data);
}

View File

@ -4,6 +4,7 @@
#pragma once
#include <map>
#include <optional>
#include <ostream>
#include <string>
@ -146,7 +147,7 @@ struct ConfigChangeSet {
std::string name;
// key -> (old value, new value)
std::map<std::string,std::pair<boost::optional<std::string>,boost::optional<std::string>>> diff;
std::map<std::string,std::pair<std::optional<std::string>,std::optional<std::string>>> diff;
void dump(ceph::Formatter *f) const;
void print(std::ostream& out) const;

View File

@ -587,7 +587,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op)
bl.append(value);
pending[key] = bl;
} else {
pending[key] = boost::none;
pending[key].reset();
}
goto update;
} else if (prefix == "config reset") {
@ -614,7 +614,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op)
bl.append(*i.second.first);
pending[i.first] = bl;
} else if (i.second.second) {
pending[i.first] = boost::none;
pending[i.first].reset();
}
}
}
@ -798,7 +798,7 @@ void ConfigMonitor::load_config()
if (p != renamed_pacific.end()) {
if (mon.monmap->min_mon_release >= ceph_release_t::pacific) {
// schedule a cleanup
pending_cleanup[key] = boost::none;
pending_cleanup[key].reset();
pending_cleanup[who + "/" + p->second] = it->value();
}
// continue loading under the new name
@ -831,18 +831,18 @@ void ConfigMonitor::load_config()
if (who.size() &&
!ConfigMap::parse_mask(who, &section_name, &mopt.mask)) {
derr << __func__ << " invalid mask for key " << key << dendl;
pending_cleanup[key] = boost::none;
pending_cleanup[key].reset();
} else if (opt->has_flag(Option::FLAG_NO_MON_UPDATE)) {
dout(10) << __func__ << " NO_MON_UPDATE option '"
<< name << "' = '" << value << "' for " << name
<< dendl;
pending_cleanup[key] = boost::none;
pending_cleanup[key].reset();
} else {
if (section_name.empty()) {
// we prefer global/$option instead of just $option
derr << __func__ << " adding global/ prefix to key '" << key << "'"
<< dendl;
pending_cleanup[key] = boost::none;
pending_cleanup[key].reset();
pending_cleanup["global/"s + key] = it->value();
}
Section *section = &config_map.global;;

View File

@ -3,7 +3,7 @@
#pragma once
#include <boost/optional.hpp>
#include <optional>
#include "ConfigMap.h"
#include "mon/PaxosService.h"
@ -14,9 +14,9 @@ class ConfigMonitor : public PaxosService
{
version_t version = 0;
ConfigMap config_map;
std::map<std::string,boost::optional<ceph::buffer::list>> pending;
std::map<std::string,std::optional<ceph::buffer::list>> pending;
std::string pending_description;
std::map<std::string,boost::optional<ceph::buffer::list>> pending_cleanup;
std::map<std::string,std::optional<ceph::buffer::list>> pending_cleanup;
std::map<std::string,ceph::buffer::list> current;

View File

@ -298,7 +298,7 @@ bool KVMonitor::prepare_command(MonOpRequestRef op)
else if (prefix == "config-key del" ||
prefix == "config-key rm") {
ss << "key deleted";
pending[key] = boost::none;
pending[key].reset();
goto update;
}
else {
@ -375,7 +375,7 @@ void KVMonitor::do_osd_destroy(int32_t id, uuid_d& uuid)
if (iter->key().find(prefix) != 0) {
break;
}
pending[iter->key()] = boost::none;
pending[iter->key()].reset();
}
propose_pending();
@ -491,7 +491,7 @@ bool KVMonitor::maybe_send_update(Subscription *sub)
int err = get_version(cur, bl);
ceph_assert(err == 0);
std::map<std::string,boost::optional<ceph::buffer::list>> pending;
std::map<std::string,std::optional<ceph::buffer::list>> pending;
auto p = bl.cbegin();
ceph::decode(pending, p);

View File

@ -3,7 +3,7 @@
#pragma once
#include <boost/optional.hpp>
#include <optional>
#include "mon/PaxosService.h"
@ -14,7 +14,7 @@ extern const std::string KV_PREFIX;
class KVMonitor : public PaxosService
{
version_t version = 0;
std::map<std::string,boost::optional<ceph::buffer::list>> pending;
std::map<std::string,std::optional<ceph::buffer::list>> pending;
bool _have_prefix(const string &prefix);
@ -64,6 +64,6 @@ public:
pending[key] = v;
}
void enqueue_rm(const std::string& key) {
pending[key] = boost::none;
pending[key].reset();
}
};

View File

@ -84,7 +84,7 @@ public:
}
ceph_statfs get_statfs(OSDMap& osdmap,
boost::optional<int64_t> data_pool) const {
std::optional<int64_t> data_pool) const {
return digest.get_statfs(osdmap, data_pool);
}

View File

@ -692,7 +692,7 @@ void PGMapDigest::pool_cache_io_rate_summary(ceph::Formatter *f, ostream *out,
}
ceph_statfs PGMapDigest::get_statfs(OSDMap &osdmap,
boost::optional<int64_t> data_pool) const
std::optional<int64_t> data_pool) const
{
ceph_statfs statfs;
bool filter = false;

View File

@ -197,7 +197,7 @@ public:
}
ceph_statfs get_statfs(OSDMap &osdmap,
boost::optional<int64_t> data_pool) const;
std::optional<int64_t> data_pool) const;
int64_t get_rule_avail(int ruleno) const {
auto i = avail_space_by_rule.find(ruleno);

View File

@ -1077,7 +1077,7 @@ void RADOS::stat_pools(const std::vector<std::string>& pools,
void RADOS::stat_fs(std::optional<std::int64_t> _pool,
std::unique_ptr<StatFSComp> c) {
boost::optional<int64_t> pool;
std::optional<int64_t> pool;
if (_pool)
pool = *pool;
impl->objecter->get_fs_stats(

View File

@ -4211,7 +4211,7 @@ void Objecter::_finish_pool_stat_op(PoolStatOp *op, int r)
delete op;
}
void Objecter::get_fs_stats(boost::optional<int64_t> poolid,
void Objecter::get_fs_stats(std::optional<int64_t> poolid,
decltype(StatfsOp::onfinish)&& onfinish)
{
ldout(cct, 10) << "get_fs_stats" << dendl;

View File

@ -2164,7 +2164,7 @@ public:
struct StatfsOp {
ceph_tid_t tid;
boost::optional<int64_t> data_pool;
std::optional<int64_t> data_pool;
using OpSig = void(boost::system::error_code,
const struct ceph_statfs);
using OpComp = ceph::async::Completion<OpSig>;
@ -3783,10 +3783,10 @@ private:
void _fs_stats_submit(StatfsOp *op);
public:
void handle_fs_stats_reply(MStatfsReply *m);
void get_fs_stats(boost::optional<int64_t> poolid,
void get_fs_stats(std::optional<int64_t> poolid,
decltype(StatfsOp::onfinish)&& onfinish);
template<typename CompletionToken>
auto get_fs_stats(boost::optional<int64_t> poolid,
auto get_fs_stats(std::optional<int64_t> poolid,
CompletionToken&& token) {
boost::asio::async_completion<CompletionToken, StatfsOp::OpSig> init(token);
get_fs_stats(poolid,
@ -3794,7 +3794,7 @@ public:
std::move(init.completion_handler)));
return init.result.get();
}
void get_fs_stats(struct ceph_statfs& result, boost::optional<int64_t> poolid,
void get_fs_stats(struct ceph_statfs& result, std::optional<int64_t> poolid,
Context *onfinish) {
get_fs_stats(poolid, OpContextVert(onfinish, result));
}