From: Kefu Chai Date: Sun, 27 Jun 2021 04:01:17 +0000 (+0800) Subject: mgr,mon: s/boost::optional/std::optional/ X-Git-Tag: v17.1.0~1533^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a41b62bd85688bec566a7760cea95341bcb7a953;p=ceph.git 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 --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 3533f3d6f4b75..03b3ab06383fc 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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(), &cond); + objecter->get_fs_stats(stats, std::optional(), &cond); } lock.unlock(); diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index 29f240440aeab..631067474054b 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -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 (), + objecter->get_fs_stats(stats, std::optional (), new C_SafeCond(mylock, cond, &done, &ret)); } { diff --git a/src/messages/MKVData.h b/src/messages/MKVData.h index f735f79d7eac8..d6182efd34e5b 100644 --- a/src/messages/MKVData.h +++ b/src/messages/MKVData.h @@ -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::less<>> data; + std::map,std::less<>> data; MKVData() : Message{MSG_KV_DATA, HEAD_VERSION, COMPAT_VERSION} { } diff --git a/src/messages/MStatfs.h b/src/messages/MStatfs.h index 41b236a9eeea6..46a9a3748dd55 100644 --- a/src/messages/MStatfs.h +++ b/src/messages/MStatfs.h @@ -16,6 +16,7 @@ #ifndef CEPH_MSTATFS_H #define CEPH_MSTATFS_H +#include #include /* or */ #include "messages/PaxosServiceMessage.h" @@ -26,10 +27,10 @@ private: public: uuid_d fsid; - boost::optional data_pool; + std::optional data_pool; MStatfs() : PaxosServiceMessage{CEPH_MSG_STATFS, 0, HEAD_VERSION, COMPAT_VERSION} {} - MStatfs(const uuid_d& f, ceph_tid_t t, boost::optional _data_pool, + MStatfs(const uuid_d& f, ceph_tid_t t, std::optional _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 (); + data_pool = std::optional (); } } private: diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index e78cc458fc724..58e51e30ad541 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -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& val) + const std::string &key, const std::optional& 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 ActivePyModules::set_config( const std::string &module_name, const std::string &key, - const boost::optional& val) + const std::optional& val) { return module_config.set_config(&monc, module_name, key, val); } @@ -730,7 +730,7 @@ std::map ActivePyModules::get_services() const void ActivePyModules::update_kv_data( const std::string prefix, bool incremental, - const map, std::less<>>& data) + const map, std::less<>>& data) { std::lock_guard l(lock); bool do_config = false; diff --git a/src/mgr/ActivePyModules.h b/src/mgr/ActivePyModules.h index d1e90f8bd3c0d..da21bb99fe343 100644 --- a/src/mgr/ActivePyModules.h +++ b/src/mgr/ActivePyModules.h @@ -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 &val); + const std::string &key, const std::optional &val); bool get_config(const std::string &module_name, const std::string &key, std::string *val) const; std::pair set_config(const std::string &module_name, - const std::string &key, const boost::optional &val); + const std::string &key, const std::optional &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::less<>>& data); + const map, std::less<>>& data); void _refresh_config_map(); // Public so that MonCommandCompletion can use it diff --git a/src/mgr/BaseMgrModule.cc b/src/mgr/BaseMgrModule.cc index 233951853971e..c1335bee1dd52 100644 --- a/src/mgr/BaseMgrModule.cc +++ b/src/mgr/BaseMgrModule.cc @@ -486,7 +486,7 @@ ceph_set_module_option(BaseMgrModule *self, PyObject *args) derr << "Invalid args!" << dendl; return nullptr; } - boost::optional val; + std::optional 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 val; + std::optional val; if (value) { val = value; } diff --git a/src/mgr/PyModule.cc b/src/mgr/PyModule.cc index c554ff1d00aa2..144f4354c2fab 100644 --- a/src/mgr/PyModule.cc +++ b/src/mgr/PyModule.cc @@ -185,7 +185,7 @@ PyModuleConfig::~PyModuleConfig() = default; std::pair PyModuleConfig::set_config( MonClient *monc, const std::string &module_name, - const std::string &key, const boost::optional& val) + const std::string &key, const std::optional& val) { const std::string global_key = "mgr/" + module_name + "/" + key; Command set_cmd; diff --git a/src/mgr/PyModule.h b/src/mgr/PyModule.h index 037a7a22b004c..fbb56080efa4a 100644 --- a/src/mgr/PyModule.h +++ b/src/mgr/PyModule.h @@ -181,6 +181,6 @@ public: std::pair set_config( MonClient *monc, const std::string &module_name, - const std::string &key, const boost::optional& val); + const std::string &key, const std::optional& val); }; diff --git a/src/mgr/PyModuleRegistry.h b/src/mgr/PyModuleRegistry.h index 27590107bb7ca..19360b3fa2ded 100644 --- a/src/mgr/PyModuleRegistry.h +++ b/src/mgr/PyModuleRegistry.h @@ -69,7 +69,7 @@ public: void update_kv_data( const std::string prefix, bool incremental, - const map, std::less<>>& data) { + const map, std::less<>>& data) { ceph_assert(active_modules); active_modules->update_kv_data(prefix, incremental, data); } diff --git a/src/mon/ConfigMap.h b/src/mon/ConfigMap.h index 2ecdcc0713365..a21e77265d659 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include @@ -146,7 +147,7 @@ struct ConfigChangeSet { std::string name; // key -> (old value, new value) - std::map,boost::optional>> diff; + std::map,std::optional>> diff; void dump(ceph::Formatter *f) const; void print(std::ostream& out) const; diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index d4dc0f3dfd8d2..39aa9f9b17737 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -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, §ion_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;; diff --git a/src/mon/ConfigMonitor.h b/src/mon/ConfigMonitor.h index e6c12a3d7f012..263bdb7a43079 100644 --- a/src/mon/ConfigMonitor.h +++ b/src/mon/ConfigMonitor.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include "ConfigMap.h" #include "mon/PaxosService.h" @@ -14,9 +14,9 @@ class ConfigMonitor : public PaxosService { version_t version = 0; ConfigMap config_map; - std::map> pending; + std::map> pending; std::string pending_description; - std::map> pending_cleanup; + std::map> pending_cleanup; std::map current; diff --git a/src/mon/KVMonitor.cc b/src/mon/KVMonitor.cc index bfe01bde92c3e..9092bd15d4d63 100644 --- a/src/mon/KVMonitor.cc +++ b/src/mon/KVMonitor.cc @@ -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> pending; + std::map> pending; auto p = bl.cbegin(); ceph::decode(pending, p); diff --git a/src/mon/KVMonitor.h b/src/mon/KVMonitor.h index c14c16380ee3f..3796e9b0b5a62 100644 --- a/src/mon/KVMonitor.h +++ b/src/mon/KVMonitor.h @@ -3,7 +3,7 @@ #pragma once -#include +#include #include "mon/PaxosService.h" @@ -14,7 +14,7 @@ extern const std::string KV_PREFIX; class KVMonitor : public PaxosService { version_t version = 0; - std::map> pending; + std::map> 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(); } }; diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 7c31f2c13f64f..aa0ae49ffd61d 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -84,7 +84,7 @@ public: } ceph_statfs get_statfs(OSDMap& osdmap, - boost::optional data_pool) const { + std::optional data_pool) const { return digest.get_statfs(osdmap, data_pool); } diff --git a/src/mon/PGMap.cc b/src/mon/PGMap.cc index c8ea4eabdcfc5..057c79dca36d4 100644 --- a/src/mon/PGMap.cc +++ b/src/mon/PGMap.cc @@ -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 data_pool) const + std::optional data_pool) const { ceph_statfs statfs; bool filter = false; diff --git a/src/mon/PGMap.h b/src/mon/PGMap.h index 6488cc895c76f..3bb0c3e09f52c 100644 --- a/src/mon/PGMap.h +++ b/src/mon/PGMap.h @@ -197,7 +197,7 @@ public: } ceph_statfs get_statfs(OSDMap &osdmap, - boost::optional data_pool) const; + std::optional data_pool) const; int64_t get_rule_avail(int ruleno) const { auto i = avail_space_by_rule.find(ruleno); diff --git a/src/neorados/RADOS.cc b/src/neorados/RADOS.cc index c3666820acb6c..944386ba5dcef 100644 --- a/src/neorados/RADOS.cc +++ b/src/neorados/RADOS.cc @@ -1077,7 +1077,7 @@ void RADOS::stat_pools(const std::vector& pools, void RADOS::stat_fs(std::optional _pool, std::unique_ptr c) { - boost::optional pool; + std::optional pool; if (_pool) pool = *pool; impl->objecter->get_fs_stats( diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index d935b73adb948..f66ba9fdcad21 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -4211,7 +4211,7 @@ void Objecter::_finish_pool_stat_op(PoolStatOp *op, int r) delete op; } -void Objecter::get_fs_stats(boost::optional poolid, +void Objecter::get_fs_stats(std::optional poolid, decltype(StatfsOp::onfinish)&& onfinish) { ldout(cct, 10) << "get_fs_stats" << dendl; diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 5af605913c06d..de1e7adf319bc 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -2164,7 +2164,7 @@ public: struct StatfsOp { ceph_tid_t tid; - boost::optional data_pool; + std::optional data_pool; using OpSig = void(boost::system::error_code, const struct ceph_statfs); using OpComp = ceph::async::Completion; @@ -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 poolid, + void get_fs_stats(std::optional poolid, decltype(StatfsOp::onfinish)&& onfinish); template - auto get_fs_stats(boost::optional poolid, + auto get_fs_stats(std::optional poolid, CompletionToken&& token) { boost::asio::async_completion 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 poolid, + void get_fs_stats(struct ceph_statfs& result, std::optional poolid, Context *onfinish) { get_fs_stats(poolid, OpContextVert(onfinish, result)); }