From: Samuel Just Date: Fri, 3 May 2019 20:44:27 +0000 (-0700) Subject: osd/: convert boost::optional users to std::optional X-Git-Tag: v15.1.0~2702^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=48ce9f457034920b223e55259fd20fa0556e5533;p=ceph.git osd/: convert boost::optional users to std::optional Signed-off-by: Samuel Just --- diff --git a/src/include/encoding.h b/src/include/encoding.h index 9963cf7a53382..42f4e69050468 100644 --- a/src/include/encoding.h +++ b/src/include/encoding.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -335,6 +336,10 @@ template inline void encode(const boost::optional &p, bufferlist &bl); template inline void decode(boost::optional &p, bufferlist::const_iterator &bp); +template +inline void encode(const std::optional &p, bufferlist &bl); +template +inline void decode(std::optional &p, bufferlist::const_iterator &bp); template inline void encode(const boost::tuple &t, bufferlist& bl); template @@ -569,6 +574,32 @@ inline void decode(boost::optional &p, bufferlist::const_iterator &bp) #pragma GCC diagnostic pop #pragma GCC diagnostic warning "-Wpragmas" +// std optional +template +inline void encode(const std::optional &p, bufferlist &bl) +{ + __u8 present = static_cast(p); + encode(present, bl); + if (p) + encode(*p, bl); +} + +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +template +inline void decode(std::optional &p, bufferlist::const_iterator &bp) +{ + __u8 present; + decode(present, bp); + if (present) { + p = T{}; + decode(*p, bp); + } else { + p = std::nullopt; + } +} + // std::tuple template inline void encode(const std::tuple &t, bufferlist& bl) diff --git a/src/include/types.h b/src/include/types.h index f58213895e319..44777d218c8a4 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -58,6 +58,7 @@ extern "C" { #include #include #include +#include #include #include @@ -106,6 +107,8 @@ template inline std::ostream& operator<<(std::ostream& out, const std::deque& v); template inline std::ostream& operator<<(std::ostream& out, const std::tuple &t); +template +inline std::ostream& operator<<(std::ostream& out, const std::optional &t); template inline std::ostream& operator<<(std::ostream& out, const std::list& ilist); template @@ -184,6 +187,16 @@ inline std::ostream& operator<<(std::ostream& out, const std::tuple &t) { return out; } +// Mimics boost::optional +template +inline std::ostream& operator<<(std::ostream& out, const std::optional &t) { + if (!t) + out << "--" ; + else + out << ' ' << *t ; + return out; +} + template inline std::ostream& operator<<(std::ostream& out, const std::list& ilist) { for (auto it = ilist.begin(); diff --git a/src/messages/MOSDRepOp.h b/src/messages/MOSDRepOp.h index bafee6faac09a..b998eedd2a63e 100644 --- a/src/messages/MOSDRepOp.h +++ b/src/messages/MOSDRepOp.h @@ -61,7 +61,7 @@ public: hobject_t discard_temp_oid; ///< previously used temp object that we can now stop tracking /// non-empty if this transaction involves a hit_set history update - boost::optional updated_hit_set_history; + std::optional updated_hit_set_history; epoch_t get_map_epoch() const override { return map_epoch; diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index f498f6c9b7186..a14de9558a5d2 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -98,7 +98,7 @@ ostream &operator<<(ostream &lhs, const ECBackend::read_result_t &rhs) lhs << "read_result_t(r=" << rhs.r << ", errors=" << rhs.errors; if (rhs.attrs) { - lhs << ", attrs=" << rhs.attrs.get(); + lhs << ", attrs=" << *(rhs.attrs); } else { lhs << ", noattrs"; } @@ -414,7 +414,7 @@ void ECBackend::handle_recovery_push_reply( void ECBackend::handle_recovery_read_complete( const hobject_t &hoid, boost::tuple > &to_read, - boost::optional > attrs, + std::optional > attrs, RecoveryMessages *m) { dout(10) << __func__ << ": returned " << hoid << " " @@ -1482,7 +1482,7 @@ void ECBackend::submit_transaction( const eversion_t &trim_to, const eversion_t &roll_forward_to, const vector &log_entries, - boost::optional &hset_history, + std::optional &hset_history, Context *on_all_commit, ceph_tid_t tid, osd_reqid_t reqid, diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index e003a08c73667..230542bc6de50 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -104,7 +104,7 @@ public: const eversion_t &trim_to, const eversion_t &roll_forward_to, const vector &log_entries, - boost::optional &hset_history, + std::optional &hset_history, Context *on_all_commit, ceph_tid_t tid, osd_reqid_t reqid, @@ -302,7 +302,7 @@ private: void handle_recovery_read_complete( const hobject_t &hoid, boost::tuple > &to_read, - boost::optional > attrs, + std::optional > attrs, RecoveryMessages *m); void handle_recovery_push( const PushOp &op, @@ -344,7 +344,7 @@ public: struct read_result_t { int r; map errors; - boost::optional > attrs; + std::optional > attrs; list< boost::tuple< uint64_t, uint64_t, map > > returned; @@ -456,7 +456,7 @@ public: object_stat_sum_t delta_stats; eversion_t version; eversion_t trim_to; - boost::optional updated_hit_set_history; + std::optional updated_hit_set_history; vector log_entries; ceph_tid_t tid; osd_reqid_t reqid; diff --git a/src/osd/ECMsgTypes.h b/src/osd/ECMsgTypes.h index 4d18dace1b813..3545edf58da76 100644 --- a/src/osd/ECMsgTypes.h +++ b/src/osd/ECMsgTypes.h @@ -33,7 +33,7 @@ struct ECSubWrite { vector log_entries; std::set temp_added; std::set temp_removed; - boost::optional updated_hit_set_history; + std::optional updated_hit_set_history; bool backfill_or_async_recovery = false; ECSubWrite() : tid(0) {} ECSubWrite( @@ -47,7 +47,7 @@ struct ECSubWrite { eversion_t trim_to, eversion_t roll_forward_to, vector log_entries, - boost::optional updated_hit_set_history, + std::optional updated_hit_set_history, const std::set &temp_added, const std::set &temp_removed, bool backfill_or_async_recovery) diff --git a/src/osd/ECTransaction.cc b/src/osd/ECTransaction.cc index ee791d633c6ea..38402004c5d91 100644 --- a/src/osd/ECTransaction.cc +++ b/src/osd/ECTransaction.cc @@ -184,7 +184,7 @@ void ECTransaction::generate_transactions( entry->mod_desc.update_snaps(op.updated_snaps->first); } - map > xattr_rollback; + map > xattr_rollback; ceph_assert(hinfo); bufferlist old_hinfo; encode(*hinfo, old_hinfo); @@ -200,7 +200,7 @@ void ECTransaction::generate_transactions( if (op.truncate->first != op.truncate->second) { op.truncate->first = op.truncate->second; } else { - op.truncate = boost::none; + op.truncate = std::nullopt; } op.delete_first = true; @@ -218,7 +218,7 @@ void ECTransaction::generate_transactions( } if (op.delete_first) { - /* We also want to remove the boost::none entries since + /* We also want to remove the std::nullopt entries since * the keys already won't exist */ for (auto j = op.attr_updates.begin(); j != op.attr_updates.end(); @@ -332,13 +332,13 @@ void ECTransaction::generate_transactions( xattr_rollback.insert( make_pair( j.first, - boost::optional(citer->second))); + std::optional(citer->second))); } else { // won't overwrite anything we put in earlier xattr_rollback.insert( make_pair( j.first, - boost::none)); + std::nullopt)); } } if (j.second) { diff --git a/src/osd/ExtentCache.h b/src/osd/ExtentCache.h index 7f6e3e2e51a63..bf5a60dc1b6f2 100644 --- a/src/osd/ExtentCache.h +++ b/src/osd/ExtentCache.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include #include "include/interval_set.h" @@ -131,14 +131,14 @@ private: uint64_t offset; uint64_t length; - boost::optional bl; + std::optional bl; uint64_t get_length() const { return length; } bool is_pending() const { - return bl == boost::none; + return bl == std::nullopt; } bool pinned_by_write() const { @@ -204,7 +204,7 @@ private: UPDATE_PIN }; type action = NONE; - boost::optional bl; + std::optional bl; }; template void traverse_update( diff --git a/src/osd/MissingLoc.h b/src/osd/MissingLoc.h index 19c8f872ea5d1..3b1ff161b21b9 100644 --- a/src/osd/MissingLoc.h +++ b/src/osd/MissingLoc.h @@ -290,7 +290,7 @@ class MissingLoc { const map &pmissing, const map &pinfo) { recovered(hoid); - boost::optional item; + std::optional item; auto miter = missing.get_items().find(hoid); if (miter != missing.get_items().end()) { item = miter->second; diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 3aca91296570b..e121ca2561cd6 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -10416,7 +10416,7 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) << " no pg, shouldn't exist e" << osdmap->get_epoch() << ", dropping " << qi << dendl; // share map with client? - if (boost::optional _op = qi.maybe_get_op()) { + if (std::optional _op = qi.maybe_get_op()) { osd->service.maybe_share_map((*_op)->get_req()->get_connection().get(), sdata->shard_osdmap, (*_op)->sent_epoch); @@ -10457,7 +10457,7 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) { #ifdef WITH_LTTNG osd_reqid_t reqid; - if (boost::optional _op = qi.maybe_get_op()) { + if (std::optional _op = qi.maybe_get_op()) { reqid = (*_op)->get_reqid(); } #endif @@ -10479,7 +10479,7 @@ void OSD::ShardedOpWQ::_process(uint32_t thread_index, heartbeat_handle_d *hb) { #ifdef WITH_LTTNG osd_reqid_t reqid; - if (boost::optional _op = qi.maybe_get_op()) { + if (std::optional _op = qi.maybe_get_op()) { reqid = (*_op)->get_reqid(); } #endif diff --git a/src/osd/OpQueueItem.h b/src/osd/OpQueueItem.h index 558c5c885c8b7..0680e0bd7e700 100644 --- a/src/osd/OpQueueItem.h +++ b/src/osd/OpQueueItem.h @@ -55,8 +55,8 @@ public: virtual const spg_t& get_ordering_token() const = 0; virtual OrderLocker::Ref get_order_locker(PGRef pg) = 0; virtual op_type_t get_op_type() const = 0; - virtual boost::optional maybe_get_op() const { - return boost::none; + virtual std::optional maybe_get_op() const { + return std::nullopt; } virtual uint64_t get_reserved_pushes() const { @@ -124,7 +124,7 @@ public: OpQueueable::op_type_t get_op_type() const { return qitem->get_op_type(); } - boost::optional maybe_get_op() const { + std::optional maybe_get_op() const { return qitem->maybe_get_op(); } uint64_t get_reserved_pushes() const { @@ -208,7 +208,7 @@ public: ostream &print(ostream &rhs) const override final { return rhs << "PGOpItem(op=" << *(op->get_req()) << ")"; } - boost::optional maybe_get_op() const override final { + std::optional maybe_get_op() const override final { return op; } void run(OSD *osd, OSDShard *sdata, PGRef& pg, ThreadPool::TPHandle &handle) override final; diff --git a/src/osd/PG.cc b/src/osd/PG.cc index d6565eb505720..d8b86cd581bef 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -3053,8 +3053,8 @@ void PG::scrub_compare_maps() // construct authoritative scrub map for type specific scrubbing scrubber.cleaned_meta_map.insert(scrubber.primary_scrubmap); map, - boost::optional>> missing_digest; + pair, + std::optional>> missing_digest; map maps; maps[pg_whoami] = &scrubber.primary_scrubmap; diff --git a/src/osd/PG.h b/src/osd/PG.h index d6119ca70f591..e712ae54b8b50 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -1327,8 +1327,8 @@ protected: virtual void scrub_snapshot_metadata( ScrubMap &map, const std::map, - boost::optional>> &missing_digest) { } + pair, + std::optional>> &missing_digest) { } virtual void _scrub_clear_state() { } virtual void _scrub_finish() { } void clear_scrub_reserved(); diff --git a/src/osd/PGBackend.cc b/src/osd/PGBackend.cc index 62cfed4ed5d21..fa802d3a7c1f6 100644 --- a/src/osd/PGBackend.cc +++ b/src/osd/PGBackend.cc @@ -197,7 +197,7 @@ void PGBackend::rollback( temp.append(t); temp.swap(t); } - void setattrs(map > &attrs) override { + void setattrs(map > &attrs) override { ObjectStore::Transaction temp; pg->rollback_setattrs(hoid, attrs, &temp); temp.append(t); @@ -438,15 +438,15 @@ int PGBackend::objects_get_attrs( void PGBackend::rollback_setattrs( const hobject_t &hoid, - map > &old_attrs, + map > &old_attrs, ObjectStore::Transaction *t) { map to_set; ceph_assert(!hoid.is_temp()); - for (map >::iterator i = old_attrs.begin(); + for (map >::iterator i = old_attrs.begin(); i != old_attrs.end(); ++i) { if (i->second) { - to_set[i->first] = i->second.get(); + to_set[i->first] = *(i->second); } else { t->rmattr( coll, @@ -1010,8 +1010,8 @@ void PGBackend::be_compare_scrubmaps( map> &missing, map> &inconsistent, map> &authoritative, - map, - boost::optional>> &missing_digest, + map, + std::optional>> &missing_digest, int &shallow_errors, int &deep_errors, Scrub::Store *store, const spg_t& pgid, @@ -1147,7 +1147,7 @@ void PGBackend::be_compare_scrubmaps( } if (fix_digest) { - boost::optional data_digest, omap_digest; + std::optional data_digest, omap_digest; ceph_assert(auth_object.digest_present); data_digest = auth_object.digest; if (auth_object.omap_digest_present) { @@ -1199,7 +1199,7 @@ void PGBackend::be_compare_scrubmaps( utime_t age = now - auth_oi.local_mtime; if (update == FORCE || age > cct->_conf->osd_deep_scrub_update_digest_min_age) { - boost::optional data_digest, omap_digest; + std::optional data_digest, omap_digest; if (auth_object.digest_present) { data_digest = auth_object.digest; dout(20) << __func__ << " will update data digest on " << *k << dendl; diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 70c01ac075893..cc08603edea7c 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -171,17 +171,17 @@ typedef std::shared_ptr OSDMapRef; virtual void add_local_next_event(const pg_log_entry_t& e) = 0; virtual const map &get_shard_missing() const = 0; - virtual boost::optional maybe_get_shard_missing( + virtual const pg_missing_const_i * maybe_get_shard_missing( pg_shard_t peer) const { if (peer == primary_shard()) { - return get_local_missing(); + return &get_local_missing(); } else { map::const_iterator i = get_shard_missing().find(peer); if (i == get_shard_missing().end()) { - return boost::optional(); + return nullptr; } else { - return i->second; + return &(i->second); } } } @@ -232,7 +232,7 @@ typedef std::shared_ptr OSDMapRef; virtual void log_operation( const vector &logv, - const boost::optional &hset_history, + const std::optional &hset_history, const eversion_t &trim_to, const eversion_t &roll_forward_to, bool transaction_applied, @@ -449,7 +449,7 @@ typedef std::shared_ptr OSDMapRef; const eversion_t &roll_forward_to, ///< [in] trim rollback info to here const vector &log_entries, ///< [in] log entries for t /// [in] hitset history (if updated with this transaction) - boost::optional &hset_history, + std::optional &hset_history, Context *on_all_commit, ///< [in] called when all commit ceph_tid_t tid, ///< [in] tid osd_reqid_t reqid, ///< [in] reqid @@ -489,7 +489,7 @@ typedef std::shared_ptr OSDMapRef; /// Reapply old attributes void rollback_setattrs( const hobject_t &hoid, - map > &old_attrs, + map > &old_attrs, ObjectStore::Transaction *t); /// Truncate object to rollback append @@ -595,8 +595,8 @@ typedef std::shared_ptr OSDMapRef; map> &missing, map> &inconsistent, map> &authoritative, - map, - boost::optional>> &missing_digest, + map, + std::optional>> &missing_digest, int &shallow_errors, int &deep_errors, Scrub::Store *store, const spg_t& pgid, diff --git a/src/osd/PGTransaction.h b/src/osd/PGTransaction.h index e3a7b8e1e8206..beb61449a39b6 100644 --- a/src/osd/PGTransaction.h +++ b/src/osd/PGTransaction.h @@ -16,7 +16,7 @@ #include #include -#include +#include #include "common/hobject.h" #include "osd/osd_types.h" @@ -127,24 +127,24 @@ public: * remember the lowest truncate and the final object size * (the last truncate). We also adjust the buffers map * to account for truncates overriding previous writes */ - boost::optional > truncate = boost::none; + std::optional > truncate = std::nullopt; - std::map > attr_updates; + std::map > attr_updates; enum class OmapUpdateType {Remove, Insert}; std::vector > omap_updates; - boost::optional omap_header; + std::optional omap_header; /// (old, new) -- only valid with no truncate or buffer updates - boost::optional, set > > updated_snaps; + std::optional, set > > updated_snaps; struct alloc_hint_t { uint64_t expected_object_size; uint64_t expected_write_size; uint32_t flags; }; - boost::optional alloc_hint; + std::optional alloc_hint; struct BufferUpdate { struct Write { @@ -338,7 +338,7 @@ public: auto &op = get_object_op_for_modify(hoid); op.clear_omap = true; op.omap_updates.clear(); - op.omap_header = boost::none; + op.omap_header = std::nullopt; } void truncate( const hobject_t &hoid, ///< [in] object @@ -383,7 +383,7 @@ public: const string &attrname ///< [in] attr to remove ) { auto &op = get_object_op_for_modify(hoid); - op.attr_updates[attrname] = boost::none; + op.attr_updates[attrname] = std::nullopt; } /// set alloc hint diff --git a/src/osd/PrimaryLogPG.cc b/src/osd/PrimaryLogPG.cc index a95b5a4610a99..dbe8a7daa4e12 100644 --- a/src/osd/PrimaryLogPG.cc +++ b/src/osd/PrimaryLogPG.cc @@ -2343,7 +2343,7 @@ PrimaryLogPG::cache_result_t PrimaryLogPG::maybe_handle_manifest_detail( } } if (all_dirty) { - start_flush(OpRequestRef(), obc, true, NULL, boost::none); + start_flush(OpRequestRef(), obc, true, NULL, std::nullopt); } return cache_result_t::NOOP; } @@ -2405,7 +2405,7 @@ void PrimaryLogPG::handle_manifest_flush(hobject_t oid, ceph_tid_t tid, int r, } int PrimaryLogPG::start_manifest_flush(OpRequestRef op, ObjectContextRef obc, bool blocking, - boost::optional> &&on_flush) + std::optional> &&on_flush) { auto p = obc->obs.oi.manifest.chunk_map.begin(); FlushOpRef manifest_fop(std::make_shared()); @@ -2599,7 +2599,7 @@ void PrimaryLogPG::record_write_error(OpRequestRef op, const hobject_t &soid, submit_log_entries( entries, std::move(lock_manager), - boost::optional >( + std::optional >( OnComplete(this, op, orig_reply, r)), op, r); @@ -4893,13 +4893,13 @@ struct FillInVerifyExtent : public Context { ceph_le64 *r; int32_t *rval; bufferlist *outdatap; - boost::optional maybe_crc; + std::optional maybe_crc; uint64_t size; OSDService *osd; hobject_t soid; __le32 flags; FillInVerifyExtent(ceph_le64 *r, int32_t *rv, bufferlist *blp, - boost::optional mc, uint64_t size, + std::optional mc, uint64_t size, OSDService *osd, hobject_t soid, __le32 flags) : r(r), rval(rv), outdatap(blp), maybe_crc(mc), size(size), osd(osd), soid(soid), flags(flags) {} @@ -5015,7 +5015,7 @@ struct C_ChecksumRead : public Context { C_ChecksumRead(PrimaryLogPG *primary_log_pg, OSDOp &osd_op, Checksummer::CSumType csum_type, bufferlist &&init_value_bl, - boost::optional maybe_crc, uint64_t size, + std::optional maybe_crc, uint64_t size, OSDService *osd, hobject_t soid, __le32 flags) : primary_log_pg(primary_log_pg), osd_op(osd_op), csum_type(csum_type), init_value_bl(std::move(init_value_bl)), @@ -5109,7 +5109,7 @@ int PrimaryLogPG::do_checksum(OpContext *ctx, OSDOp& osd_op, if (pool.info.is_erasure() && op.checksum.length > 0) { // If there is a data digest and it is possible we are reading // entire object, pass the digest. - boost::optional maybe_crc; + std::optional maybe_crc; if (oi.is_data_digest() && op.checksum.offset == 0 && op.checksum.length >= oi.size) { maybe_crc = oi.data_digest; @@ -5227,7 +5227,7 @@ struct C_ExtentCmpRead : public Context { Context *fill_extent_ctx; C_ExtentCmpRead(PrimaryLogPG *primary_log_pg, OSDOp &osd_op, - boost::optional maybe_crc, uint64_t size, + std::optional maybe_crc, uint64_t size, OSDService *osd, hobject_t soid, __le32 flags) : primary_log_pg(primary_log_pg), osd_op(osd_op), fill_extent_ctx(new FillInVerifyExtent(&read_length, &osd_op.rval, @@ -5281,7 +5281,7 @@ int PrimaryLogPG::do_extent_cmp(OpContext *ctx, OSDOp& osd_op) } else if (pool.info.is_erasure()) { // If there is a data digest and it is possible we are reading // entire object, pass the digest. - boost::optional maybe_crc; + std::optional maybe_crc; if (oi.is_data_digest() && op.checksum.offset == 0 && op.checksum.length >= oi.size) { maybe_crc = oi.data_digest; @@ -5374,7 +5374,7 @@ int PrimaryLogPG::do_read(OpContext *ctx, OSDOp& osd_op) { } else if (pool.info.is_erasure()) { // The initialisation below is required to silence a false positive // -Wmaybe-uninitialized warning - boost::optional maybe_crc = boost::make_optional(false, uint32_t()); + std::optional maybe_crc; // If there is a data digest and it is possible we are reading // entire object, pass the digest. FillInVerifyExtent will // will check the oi.size again. @@ -5869,7 +5869,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) break; } if (oi.is_dirty()) { - result = start_flush(ctx->op, ctx->obc, false, NULL, boost::none); + result = start_flush(ctx->op, ctx->obc, false, NULL, std::nullopt); if (result == -EINPROGRESS) result = -EAGAIN; } else { @@ -5902,7 +5902,7 @@ int PrimaryLogPG::do_osd_ops(OpContext *ctx, vector& ops) } hobject_t missing; if (oi.is_dirty()) { - result = start_flush(ctx->op, ctx->obc, true, &missing, boost::none); + result = start_flush(ctx->op, ctx->obc, true, &missing, std::nullopt); if (result == -EINPROGRESS) result = -EAGAIN; } else { @@ -8208,7 +8208,7 @@ void PrimaryLogPG::do_osd_op_effects(OpContext *ctx, const ConnectionRef& conn) p != ctx->notify_acks.end(); ++p) { if (p->watch_cookie) - dout(10) << "notify_ack " << make_pair(p->watch_cookie.get(), p->notify_id) << dendl; + dout(10) << "notify_ack " << make_pair(*(p->watch_cookie), p->notify_id) << dendl; else dout(10) << "notify_ack " << make_pair("NULL", p->notify_id) << dendl; for (map, WatchRef>::iterator i = @@ -8217,7 +8217,7 @@ void PrimaryLogPG::do_osd_op_effects(OpContext *ctx, const ConnectionRef& conn) ++i) { if (i->first.second != entity) continue; if (p->watch_cookie && - p->watch_cookie.get() != i->first.first) continue; + *(p->watch_cookie) != i->first.first) continue; dout(10) << "acking notify on watch " << i->first << dendl; i->second->notify_ack(p->notify_id, p->reply_bl); } @@ -9748,7 +9748,7 @@ struct C_Flush : public Context { int PrimaryLogPG::start_flush( OpRequestRef op, ObjectContextRef obc, bool blocking, hobject_t *pmissing, - boost::optional> &&on_flush) + std::optional> &&on_flush) { const object_info_t& oi = obc->obs.oi; const hobject_t& soid = oi.soid; @@ -9982,7 +9982,7 @@ void PrimaryLogPG::finish_flush(hobject_t oid, ceph_tid_t tid, int r) } if (fop->on_flush) { (*(fop->on_flush))(); - fop->on_flush = boost::none; + fop->on_flush = std::nullopt; } flush_ops.erase(oid); return; @@ -10019,7 +10019,7 @@ int PrimaryLogPG::try_flush_mark_clean(FlushOpRef fop) } if (fop->on_flush) { (*(fop->on_flush))(); - fop->on_flush = boost::none; + fop->on_flush = std::nullopt; } flush_ops.erase(oid); if (fop->blocking) @@ -10052,7 +10052,7 @@ int PrimaryLogPG::try_flush_mark_clean(FlushOpRef fop) osd->logger->inc(l_osd_tier_clean); if (fop->on_flush) { (*(fop->on_flush))(); - fop->on_flush = boost::none; + fop->on_flush = std::nullopt; } flush_ops.erase(oid); return 0; @@ -10096,7 +10096,7 @@ int PrimaryLogPG::try_flush_mark_clean(FlushOpRef fop) if (fop->on_flush) { ctx->register_on_finish(*(fop->on_flush)); - fop->on_flush = boost::none; + fop->on_flush = std::nullopt; } ctx->at_version = get_next_version(); @@ -10192,7 +10192,7 @@ void PrimaryLogPG::cancel_flush(FlushOpRef fop, bool requeue, } if (fop->on_flush) { (*(fop->on_flush))(); - fop->on_flush = boost::none; + fop->on_flush = std::nullopt; } flush_ops.erase(fop->obc->obs.oi.soid); } @@ -10390,7 +10390,7 @@ boost::intrusive_ptr PrimaryLogPG::new_repop( int r, ObcLockManager &&manager, OpRequestRef &&op, - boost::optional > &&on_complete) + std::optional > &&on_complete) { RepGather *repop = new RepGather( std::move(manager), @@ -10453,7 +10453,7 @@ void PrimaryLogPG::simple_opc_submit(OpContextUPtr ctx) void PrimaryLogPG::submit_log_entries( const mempool::osd_pglog::list &entries, ObcLockManager &&manager, - boost::optional > &&_on_complete, + std::optional > &&_on_complete, OpRequestRef op, int r) { @@ -10467,7 +10467,7 @@ void PrimaryLogPG::submit_log_entries( } boost::intrusive_ptr repop; - boost::optional > on_complete; + std::optional > on_complete; if (get_osdmap()->require_osd_release >= ceph_release_t::jewel) { repop = new_repop( version, @@ -11486,13 +11486,14 @@ void PrimaryLogPG::do_update_log_missing(OpRequestRef &op) op->get_req()); ceph_assert(m->get_type() == MSG_OSD_PG_UPDATE_LOG_MISSING); ObjectStore::Transaction t; - boost::optional op_trim_to, op_roll_forward_to; + std::optional op_trim_to, op_roll_forward_to; if (m->pg_trim_to != eversion_t()) op_trim_to = m->pg_trim_to; if (m->pg_roll_forward_to != eversion_t()) op_roll_forward_to = m->pg_roll_forward_to; - dout(20) << __func__ << " op_trim_to = " << op_trim_to << " op_roll_forward_to = " << op_roll_forward_to << dendl; + dout(20) << __func__ + << " op_trim_to = " << op_trim_to << " op_roll_forward_to = " << op_roll_forward_to << dendl; recovery_state.append_log_entries_update_missing( m->entries, t, op_trim_to, op_roll_forward_to); @@ -11675,7 +11676,7 @@ void PrimaryLogPG::mark_all_unfound_lost( submit_log_entries( log_entries, std::move(manager), - boost::optional >( + std::optional >( [this, oids, con, num_unfound, tid]() { if (recovery_state.perform_deletes_during_peering()) { for (auto oid : oids) { @@ -14403,13 +14404,13 @@ bool PrimaryLogPG::_range_available_for_scrub( return true; } -static bool doing_clones(const boost::optional &snapset, +static bool doing_clones(const std::optional &snapset, const vector::reverse_iterator &curclone) { - return snapset && curclone != snapset.get().clones.rend(); + return snapset && curclone != snapset->clones.rend(); } void PrimaryLogPG::log_missing(unsigned missing, - const boost::optional &head, + const std::optional &head, LogChannelRef clog, const spg_t &pgid, const char *func, @@ -14418,21 +14419,21 @@ void PrimaryLogPG::log_missing(unsigned missing, { ceph_assert(head); if (allow_incomplete_clones) { - dout(20) << func << " " << mode << " " << pgid << " " << head.get() - << " skipped " << missing << " clone(s) in cache tier" << dendl; + dout(20) << func << " " << mode << " " << pgid << " " << *head + << " skipped " << missing << " clone(s) in cache tier" << dendl; } else { - clog->info() << mode << " " << pgid << " " << head.get() - << " : " << missing << " missing clone(s)"; + clog->info() << mode << " " << pgid << " " << *head + << " : " << missing << " missing clone(s)"; } } -unsigned PrimaryLogPG::process_clones_to(const boost::optional &head, - const boost::optional &snapset, +unsigned PrimaryLogPG::process_clones_to(const std::optional &head, + const std::optional &snapset, LogChannelRef clog, const spg_t &pgid, const char *mode, bool allow_incomplete_clones, - boost::optional target, + std::optional target, vector::reverse_iterator *curclone, inconsistent_snapset_wrapper &e) { @@ -14441,14 +14442,14 @@ unsigned PrimaryLogPG::process_clones_to(const boost::optional &head, unsigned missing = 0; // NOTE: clones are in descending order, thus **curclone > target test here - hobject_t next_clone(head.get()); + hobject_t next_clone(*head); while(doing_clones(snapset, *curclone) && (!target || **curclone > *target)) { ++missing; // it is okay to be missing one or more clones in a cache tier. // skip higher-numbered clones in the list. if (!allow_incomplete_clones) { next_clone.snap = **curclone; - clog->error() << mode << " " << pgid << " " << head.get() + clog->error() << mode << " " << pgid << " " << *head << " : expected clone " << next_clone << " " << missing << " missing"; ++scrubber.shallow_errors; @@ -14488,19 +14489,19 @@ unsigned PrimaryLogPG::process_clones_to(const boost::optional &head, void PrimaryLogPG::scrub_snapshot_metadata( ScrubMap &scrubmap, const map, - boost::optional>> &missing_digest) + pair, + std::optional>> &missing_digest) { dout(10) << __func__ << dendl; bool repair = state_test(PG_STATE_REPAIR); bool deep_scrub = state_test(PG_STATE_DEEP_SCRUB); const char *mode = (repair ? "repair": (deep_scrub ? "deep-scrub" : "scrub")); - boost::optional all_clones; // Unspecified snapid_t or boost::none + std::optional all_clones; // Unspecified snapid_t or std::nullopt // traverse in reverse order. - boost::optional head; - boost::optional snapset; // If initialized so will head (above) + std::optional head; + std::optional snapset; // If initialized so will head (above) vector::reverse_iterator curclone; // Defined only if snapset initialized unsigned missing = 0; inconsistent_snapset_wrapper soid_error, head_error; @@ -14512,7 +14513,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( ceph_assert(!soid.is_snapdir()); soid_error = inconsistent_snapset_wrapper{soid}; object_stat_sum_t stat; - boost::optional oi; + std::optional oi; stat.num_objects++; @@ -14526,7 +14527,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( // basic checks. if (p->second.attrs.count(OI_ATTR) == 0) { - oi = boost::none; + oi = std::nullopt; osd->clog->error() << mode << " " << info.pgid << " " << soid << " : no '" << OI_ATTR << "' attr"; ++scrubber.shallow_errors; @@ -14536,9 +14537,9 @@ void PrimaryLogPG::scrub_snapshot_metadata( bv.push_back(p->second.attrs[OI_ATTR]); try { oi = object_info_t(); // Initialize optional<> before decode into it - oi.get().decode(bv); + oi->decode(bv); } catch (buffer::error& e) { - oi = boost::none; + oi = std::nullopt; osd->clog->error() << mode << " " << info.pgid << " " << soid << " : can't decode '" << OI_ATTR << "' attr " << e.what(); ++scrubber.shallow_errors; @@ -14559,7 +14560,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( ++scrubber.shallow_errors; } - dout(20) << mode << " " << soid << " " << oi.get() << dendl; + dout(20) << mode << " " << soid << " " << *oi << dendl; // A clone num_bytes will be added later when we have snapset if (!soid.is_snap()) { @@ -14582,12 +14583,12 @@ void PrimaryLogPG::scrub_snapshot_metadata( // Check for any problems while processing clones if (doing_clones(snapset, curclone)) { - boost::optional target; + std::optional target; // Expecting an object with snap for current head if (soid.has_snapset() || soid.get_head() != head->get_head()) { dout(10) << __func__ << " " << mode << " " << info.pgid << " new object " - << soid << " while processing " << head.get() << dendl; + << soid << " while processing " << *head << dendl; target = all_clones; } else { @@ -14655,7 +14656,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( osd->clog->error() << mode << " " << info.pgid << " " << soid << " : no '" << SS_ATTR << "' attr"; ++scrubber.shallow_errors; - snapset = boost::none; + snapset = std::nullopt; head_error.set_snapset_missing(); } else { bufferlist bl; @@ -14663,10 +14664,10 @@ void PrimaryLogPG::scrub_snapshot_metadata( auto blp = bl.cbegin(); try { snapset = SnapSet(); // Initialize optional<> before decoding into it - decode(snapset.get(), blp); + decode(*snapset, blp); head_error.ss_bl.push_back(p->second.attrs[SS_ATTR]); } catch (buffer::error& e) { - snapset = boost::none; + snapset = std::nullopt; osd->clog->error() << mode << " " << info.pgid << " " << soid << " : can't decode '" << SS_ATTR << "' attr " << e.what(); ++scrubber.shallow_errors; @@ -14679,7 +14680,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( curclone = snapset->clones.rbegin(); if (!snapset->clones.empty()) { - dout(20) << " snapset " << snapset.get() << dendl; + dout(20) << " snapset " << *snapset << dendl; if (snapset->seq == 0) { osd->clog->error() << mode << " " << info.pgid << " " << soid << " : snaps.seq not set"; @@ -14757,7 +14758,7 @@ void PrimaryLogPG::scrub_snapshot_metadata( if (doing_clones(snapset, curclone)) { dout(10) << __func__ << " " << mode << " " << info.pgid - << " No more objects while processing " << head.get() << dendl; + << " No more objects while processing " << *head << dendl; missing += process_clones_to(head, snapset, osd->clog, info.pgid, mode, pool.info.allow_incomplete_clones(), all_clones, &curclone, diff --git a/src/osd/PrimaryLogPG.h b/src/osd/PrimaryLogPG.h index 88fc59ec5d808..c8145cc577d5b 100644 --- a/src/osd/PrimaryLogPG.h +++ b/src/osd/PrimaryLogPG.h @@ -244,7 +244,7 @@ public: int rval; ///< copy-from result bool blocking; ///< whether we are blocking updates bool removal; ///< we are removing the backend object - boost::optional> on_flush; ///< callback, may be null + std::optional> on_flush; ///< callback, may be null // for chunked object map io_results; map io_tids; @@ -444,7 +444,7 @@ public: void log_operation( const vector &logv, - const boost::optional &hset_history, + const std::optional &hset_history, const eversion_t &trim_to, const eversion_t &roll_forward_to, bool transaction_applied, @@ -577,7 +577,7 @@ public: list watch_disconnects; ///< old watch + send_discon list notifies; struct NotifyAck { - boost::optional watch_cookie; + std::optional watch_cookie; uint64_t notify_id; bufferlist reply_bl; explicit NotifyAck(uint64_t notify_id) : notify_id(notify_id) {} @@ -602,7 +602,7 @@ public: PGTransactionUPtr op_t; vector log; - boost::optional updated_hset_history; + std::optional updated_hset_history; interval_set modified_ranges; ObjectContextRef obc; @@ -610,7 +610,7 @@ public: ObjectContextRef head_obc; // if we also update snapset (see trim_object) // FIXME: we may want to kill this msgr hint off at some point! - boost::optional data_off = boost::none; + std::optional data_off = std::nullopt; MOSDOpReply *reply; @@ -777,7 +777,7 @@ public: RepGather( ObcLockManager &&manager, OpRequestRef &&o, - boost::optional > &&on_complete, + std::optional > &&on_complete, ceph_tid_t rt, eversion_t lc, int r) : @@ -919,7 +919,7 @@ protected: int r, ObcLockManager &&manager, OpRequestRef &&op, - boost::optional > &&on_complete); + std::optional > &&on_complete); void remove_repop(RepGather *repop); OpContextUPtr simple_opc_create(ObjectContextRef obc); @@ -934,7 +934,7 @@ protected: void submit_log_entries( const mempool::osd_pglog::list &entries, ObcLockManager &&manager, - boost::optional > &&on_complete, + std::optional > &&on_complete, OpRequestRef op = OpRequestRef(), int r = 0); struct LogUpdateCtx { @@ -1359,7 +1359,7 @@ protected: int start_flush( OpRequestRef op, ObjectContextRef obc, bool blocking, hobject_t *pmissing, - boost::optional> &&on_flush); + std::optional> &&on_flush); void finish_flush(hobject_t oid, ceph_tid_t tid, int r); int try_flush_mark_clean(FlushOpRef fop); void cancel_flush(FlushOpRef fop, bool requeue, vector *tids); @@ -1376,8 +1376,8 @@ protected: void scrub_snapshot_metadata( ScrubMap &map, const std::map, - boost::optional>> &missing_digest) override; + pair, + std::optional>> &missing_digest) override; void _scrub_clear_state() override; void _scrub_finish() override; object_stat_collection_t scrub_cstat; @@ -1445,7 +1445,7 @@ protected: int do_manifest_flush(OpRequestRef op, ObjectContextRef obc, FlushOpRef manifest_fop, uint64_t start_offset, bool block); int start_manifest_flush(OpRequestRef op, ObjectContextRef obc, bool blocking, - boost::optional> &&on_flush); + std::optional> &&on_flush); void finish_manifest_flush(hobject_t oid, ceph_tid_t tid, int r, ObjectContextRef obc, uint64_t last_offset); void handle_manifest_flush(hobject_t oid, ceph_tid_t tid, int r, @@ -1522,19 +1522,19 @@ private: return pri > 0 ? pri : cct->_conf->osd_recovery_op_priority; } void log_missing(unsigned missing, - const boost::optional &head, + const std::optional &head, LogChannelRef clog, const spg_t &pgid, const char *func, const char *mode, bool allow_incomplete_clones); - unsigned process_clones_to(const boost::optional &head, - const boost::optional &snapset, + unsigned process_clones_to(const std::optional &head, + const std::optional &snapset, LogChannelRef clog, const spg_t &pgid, const char *mode, bool allow_incomplete_clones, - boost::optional target, + std::optional target, vector::reverse_iterator *curclone, inconsistent_snapset_wrapper &snap_error); diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 8063e0a9e132a..57db2c3848025 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -428,7 +428,7 @@ void ReplicatedBackend::submit_transaction( const eversion_t &trim_to, const eversion_t &roll_forward_to, const vector &_log_entries, - boost::optional &hset_history, + std::optional &hset_history, Context *on_all_commit, ceph_tid_t tid, osd_reqid_t reqid, @@ -900,7 +900,7 @@ Message * ReplicatedBackend::generate_subop( hobject_t new_temp_oid, hobject_t discard_temp_oid, const bufferlist &log_entries, - boost::optional &hset_hist, + std::optional &hset_hist, ObjectStore::Transaction &op_t, pg_shard_t peer, const pg_info_t &pinfo) @@ -950,7 +950,7 @@ void ReplicatedBackend::issue_op( hobject_t new_temp_oid, hobject_t discard_temp_oid, const vector &log_entries, - boost::optional &hset_hist, + std::optional &hset_hist, InProgressOp *op, ObjectStore::Transaction &op_t) { diff --git a/src/osd/ReplicatedBackend.h b/src/osd/ReplicatedBackend.h index 8f447495a4ed1..ec536450987b6 100644 --- a/src/osd/ReplicatedBackend.h +++ b/src/osd/ReplicatedBackend.h @@ -360,7 +360,7 @@ public: const eversion_t &trim_to, const eversion_t &roll_forward_to, const vector &log_entries, - boost::optional &hset_history, + std::optional &hset_history, Context *on_all_commit, ceph_tid_t tid, osd_reqid_t reqid, @@ -378,7 +378,7 @@ private: hobject_t new_temp_oid, hobject_t discard_temp_oid, const bufferlist &log_entries, - boost::optional &hset_history, + std::optional &hset_history, ObjectStore::Transaction &op_t, pg_shard_t peer, const pg_info_t &pinfo); @@ -392,7 +392,7 @@ private: hobject_t new_temp_oid, hobject_t discard_temp_oid, const vector &log_entries, - boost::optional &hset_history, + std::optional &hset_history, InProgressOp *op, ObjectStore::Transaction &op_t); void op_commit(InProgressOpRef& op); diff --git a/src/osd/mClockOpClassSupport.cc b/src/osd/mClockOpClassSupport.cc index d35c2cbe8d5c4..22416e064f46c 100644 --- a/src/osd/mClockOpClassSupport.cc +++ b/src/osd/mClockOpClassSupport.cc @@ -88,7 +88,7 @@ namespace ceph { // get_header returns ceph_msg_header type, ceph_msg_header // stores type as unsigned little endian, so be sure to // convert to CPU byte ordering - boost::optional op_ref_maybe = op.maybe_get_op(); + std::optional op_ref_maybe = op.maybe_get_op(); ceph_assert(op_ref_maybe); __le16 mtype_le = (*op_ref_maybe)->get_req()->get_header().type; __u16 mtype = le16_to_cpu(mtype_le); diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 5d329b3a40cdd..897a9034b815e 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -1028,9 +1028,9 @@ std::string pg_state_string(uint64_t state) return ret; } -boost::optional pg_string_state(const std::string& state) +std::optional pg_string_state(const std::string& state) { - boost::optional type; + std::optional type; if (state == "active") type = PG_STATE_ACTIVE; else if (state == "clean") @@ -1096,7 +1096,7 @@ boost::optional pg_string_state(const std::string& state) else if (state == "unknown") type = 0; else - type = boost::none; + type = std::nullopt; return type; } @@ -4121,7 +4121,7 @@ void ObjectModDesc::visit(Visitor *visitor) const break; } case SETATTRS: { - map > attrs; + map > attrs; decode(attrs, bp); visitor->setattrs(attrs); break; @@ -4175,7 +4175,7 @@ struct DumpVisitor : public ObjectModDesc::Visitor { f->dump_unsigned("old_size", old_size); f->close_section(); } - void setattrs(map > &attrs) override { + void setattrs(map > &attrs) override { f->open_object_section("op"); f->dump_string("code", "SETATTRS"); f->open_array_section("attrs"); @@ -4235,7 +4235,7 @@ void ObjectModDesc::dump(Formatter *f) const void ObjectModDesc::generate_test_instances(list& o) { - map > attrs; + map > attrs; attrs[OI_ATTR]; attrs[SS_ATTR]; attrs["asdf"]; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index f856e63101ed0..5aeb0443d2791 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -979,7 +979,7 @@ WRITE_CLASS_ENCODER_FEATURES(objectstore_perf_stat_t) std::string pg_state_string(uint64_t state); std::string pg_vector_string(const std::vector &a); -boost::optional pg_string_state(const std::string& state); +std::optional pg_string_state(const std::string& state); /* @@ -3586,7 +3586,7 @@ public: class Visitor { public: virtual void append(uint64_t old_offset) {} - virtual void setattrs(std::map> &attrs) {} + virtual void setattrs(std::map> &attrs) {} virtual void rmobject(version_t old_version) {} /** * Used to support the unfound_lost_delete log event: if the stashed @@ -3655,7 +3655,7 @@ public: encode(old_size, bl); ENCODE_FINISH(bl); } - void setattrs(std::map> &old_attrs) { + void setattrs(std::map> &old_attrs) { if (!can_local_rollback || rollback_info_completed) return; ENCODE_START(1, 1, bl);