]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: build without "using namespace std"
authorKefu Chai <kchai@redhat.com>
Wed, 11 Aug 2021 03:53:25 +0000 (11:53 +0800)
committerKefu Chai <kchai@redhat.com>
Fri, 13 Aug 2021 04:23:36 +0000 (12:23 +0800)
* add "std::" prefix in headers
* add "using" declarations in .cc files.

so we don't rely on "using namespace std" in one or more included
headers.

Signed-off-by: Kefu Chai <kchai@redhat.com>
19 files changed:
src/osd/ECBackend.cc
src/osd/ECTransaction.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h
src/osd/PGBackend.cc
src/osd/PeeringState.cc
src/osd/PeeringState.h
src/osd/PrimaryLogPG.cc
src/osd/PrimaryLogPG.h
src/osd/PrimaryLogScrub.cc
src/osd/ReplicatedBackend.cc
src/osd/Watch.cc
src/osd/osd_types.cc
src/osd/osd_types.h
src/osd/pg_scrubber.cc
src/osd/pg_scrubber.h
src/osd/recovery_types.cc
src/osd/scrubber_common.h

index f9398c1722047ba50eccd23b4c53160166dbaa2b..5388391c4f0d3310aa57bb28073923e055a5d841 100644 (file)
@@ -34,6 +34,7 @@
 
 using std::dec;
 using std::hex;
+using std::less;
 using std::list;
 using std::make_pair;
 using std::map;
index 2a6c67d13eb93a8bba1d9fcd8e5068eb255097a7..d48b20d73f8369d79691bbc38d14b2e597468212 100644 (file)
@@ -21,6 +21,7 @@
 #include "os/ObjectStore.h"
 #include "common/inline_variant.h"
 
+using std::less;
 using std::make_pair;
 using std::map;
 using std::pair;
index 57964679afd505d81fbac4bd5c3d3615608de1b7..2a30d7afadb0df53fae5e9baf621de1aa6d0cdde 100644 (file)
@@ -1178,12 +1178,13 @@ protected:
   friend class OSDSocketHook;
   class OSDSocketHook *asok_hook;
   using PGRefOrError = std::tuple<std::optional<PGRef>, int>;
-  PGRefOrError locate_asok_target(const cmdmap_t& cmdmap, stringstream& ss, bool only_primary);
+    PGRefOrError locate_asok_target(const cmdmap_t& cmdmap,
+                                   std::stringstream& ss, bool only_primary);
   int asok_route_to_pg(bool only_primary,
     std::string_view prefix,
     cmdmap_t cmdmap,
     Formatter *f,
-    stringstream& ss,
+    std::stringstream& ss,
     const bufferlist& inbl,
     bufferlist& outbl,
     std::function<void(int, const std::string&, bufferlist&)> on_finish);
index 10829def63909444ed56cc51b9bef4fdda12d759..7991b3d92947687211eaa5026b7e83138226953e 100644 (file)
@@ -2092,7 +2092,7 @@ void PG::replica_scrub(epoch_t epoch_queued,
   dout(10) << __func__ << " queued at: " << epoch_queued
           << (is_primary() ? " (primary)" : " (replica)") << dendl;
   scrub_queued = false;
-  forward_scrub_event(&ScrubPgIF::send_start_replica, epoch_queued, "StartReplica/nw"sv);
+  forward_scrub_event(&ScrubPgIF::send_start_replica, epoch_queued, "StartReplica/nw");
 }
 
 bool PG::ops_blocked_by_scrub() const
index e46a63c395ca1c7c23fa66e2ab7c31c7f7c3f23d..c288ff265e76e09ce9cc2e9812d9262aa540d476 100644 (file)
@@ -378,7 +378,7 @@ public:
   {
     // a new scrub
     scrub_queued = false;
-    forward_scrub_event(&ScrubPgIF::initiate_regular_scrub, queued, "StartScrub"sv);
+    forward_scrub_event(&ScrubPgIF::initiate_regular_scrub, queued, "StartScrub");
   }
 
   /**
@@ -391,7 +391,7 @@ public:
     // a new scrub
     scrub_queued = false;
     forward_scrub_event(&ScrubPgIF::initiate_scrub_after_repair, queued,
-                       "AfterRepairScrub"sv);
+                       "AfterRepairScrub");
   }
 
   void replica_scrub(epoch_t queued, ThreadPool::TPHandle &handle);
@@ -399,87 +399,87 @@ public:
   void replica_scrub_resched(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     scrub_queued = false;
-    forward_scrub_event(&ScrubPgIF::send_sched_replica, queued, "SchedReplica"sv);
+    forward_scrub_event(&ScrubPgIF::send_sched_replica, queued, "SchedReplica");
   }
 
   void scrub_send_resources_granted(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_remotes_reserved, queued, "RemotesReserved"sv);
+    forward_scrub_event(&ScrubPgIF::send_remotes_reserved, queued, "RemotesReserved");
   }
 
   void scrub_send_resources_denied(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     forward_scrub_event(&ScrubPgIF::send_reservation_failure, queued,
-                       "ReservationFailure"sv);
+                       "ReservationFailure");
   }
 
   void scrub_send_scrub_resched(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     scrub_queued = false;
-    forward_scrub_event(&ScrubPgIF::send_scrub_resched, queued, "InternalSchedScrub"sv);
+    forward_scrub_event(&ScrubPgIF::send_scrub_resched, queued, "InternalSchedScrub");
   }
 
   void scrub_send_pushes_update(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     forward_scrub_event(&ScrubPgIF::active_pushes_notification, queued,
-                       "ActivePushesUpd"sv);
+                       "ActivePushesUpd");
   }
 
   void scrub_send_applied_update(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     forward_scrub_event(&ScrubPgIF::update_applied_notification, queued,
-                       "UpdatesApplied"sv);
+                       "UpdatesApplied");
   }
 
   void scrub_send_unblocking(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_scrub_unblock, queued, "Unblocked"sv);
+    forward_scrub_event(&ScrubPgIF::send_scrub_unblock, queued, "Unblocked");
   }
 
   void scrub_send_digest_update(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::digest_update_notification, queued, "DigestUpdate"sv);
+    forward_scrub_event(&ScrubPgIF::digest_update_notification, queued, "DigestUpdate");
   }
 
   void scrub_send_local_map_ready(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_local_map_done, queued, "IntLocalMapDone"sv);
+    forward_scrub_event(&ScrubPgIF::send_local_map_done, queued, "IntLocalMapDone");
   }
 
   void scrub_send_replmaps_ready(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_replica_maps_ready, queued, "GotReplicas"sv);
+    forward_scrub_event(&ScrubPgIF::send_replica_maps_ready, queued, "GotReplicas");
   }
 
   void scrub_send_replica_pushes(epoch_t queued, ThreadPool::TPHandle& handle)
   {
     forward_scrub_event(&ScrubPgIF::send_replica_pushes_upd, queued,
-                       "ReplicaPushesUpd"sv);
+                       "ReplicaPushesUpd");
   }
 
   void scrub_send_maps_compared(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_maps_compared, queued, "MapsCompared"sv);
+    forward_scrub_event(&ScrubPgIF::send_maps_compared, queued, "MapsCompared");
   }
 
   void scrub_send_get_next_chunk(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_get_next_chunk, queued, "NextChunk"sv);
+    forward_scrub_event(&ScrubPgIF::send_get_next_chunk, queued, "NextChunk");
   }
 
   void scrub_send_scrub_is_finished(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_scrub_is_finished, queued, "ScrubFinished"sv);
+    forward_scrub_event(&ScrubPgIF::send_scrub_is_finished, queued, "ScrubFinished");
   }
 
   void scrub_send_chunk_free(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_chunk_free, queued, "SelectedChunkFree"sv);
+    forward_scrub_event(&ScrubPgIF::send_chunk_free, queued, "SelectedChunkFree");
   }
 
   void scrub_send_chunk_busy(epoch_t queued, ThreadPool::TPHandle& handle)
   {
-    forward_scrub_event(&ScrubPgIF::send_chunk_busy, queued, "ChunkIsBusy"sv);
+    forward_scrub_event(&ScrubPgIF::send_chunk_busy, queued, "ChunkIsBusy");
   }
 
   void reg_next_scrub();
index 3b1525bd2713563ac3766bbe499b4c875c8f39d4..4e8c74c487ee087004ecdcf60eea48f6424a6a5f 100644 (file)
@@ -30,6 +30,7 @@
 #include "messages/MOSDPGRecoveryDelete.h"
 #include "messages/MOSDPGRecoveryDeleteReply.h"
 
+using std::less;
 using std::list;
 using std::make_pair;
 using std::map;
index 78de95278097b43aa80b208cc7d5db66b862f6d3..698b767de8240add286c3d7f0b0d957dda4a512c 100644 (file)
@@ -28,6 +28,7 @@ using std::map;
 using std::ostream;
 using std::pair;
 using std::set;
+using std::string;
 using std::stringstream;
 using std::vector;
 
index c49a46697d07fa05ebbd27901007a157a2679687..992af4c576804a52a2c64d9552d15cb436d89305 100644 (file)
@@ -1518,7 +1518,7 @@ public:
   }
 
   void update_heartbeat_peers();
-  void query_unfound(Formatter *f, string state);
+  void query_unfound(Formatter *f, std::string state);
   bool proc_replica_info(
     pg_shard_t from, const pg_info_t &oinfo, epoch_t send_epoch);
   void remove_down_peer_info(const OSDMapRef &osdmap);
@@ -1578,18 +1578,18 @@ public:
     std::set<pg_shard_t> *acting_backfill,
     std::ostream &ss);
 
-  static std::pair<map<pg_shard_t, pg_info_t>::const_iterator, eversion_t>
+  static std::pair<std::map<pg_shard_t, pg_info_t>::const_iterator, eversion_t>
   select_replicated_primary(
-    map<pg_shard_t, pg_info_t>::const_iterator auth_log_shard,
+    std::map<pg_shard_t, pg_info_t>::const_iterator auth_log_shard,
     uint64_t force_auth_primary_missing_objects,
     const std::vector<int> &up,
     pg_shard_t up_primary,
-    const map<pg_shard_t, pg_info_t> &all_info,
+    const std::map<pg_shard_t, pg_info_t> &all_info,
     const OSDMapRef osdmap,
-    ostream &ss);
+    std::ostream &ss);
 
   static void calc_replicated_acting(
-    map<pg_shard_t, pg_info_t>::const_iterator primary_shard,
+    std::map<pg_shard_t, pg_info_t>::const_iterator primary_shard,
     eversion_t oldest_auth_log_entry,
     unsigned size,
     const std::vector<int> &acting,
@@ -1604,7 +1604,7 @@ public:
     const PGPool& pool,
     std::ostream &ss);
   static void calc_replicated_acting_stretch(
-    map<pg_shard_t, pg_info_t>::const_iterator primary_shard,
+    std::map<pg_shard_t, pg_info_t>::const_iterator primary_shard,
     eversion_t oldest_auth_log_entry,
     unsigned size,
     const std::vector<int> &acting,
index 64e596b107acb47870bac029a4c439c4cfc17059..2dd1e4acae91830fda4df4a8cc692a6c64f6bc0c 100644 (file)
 
 MEMPOOL_DEFINE_OBJECT_FACTORY(PrimaryLogPG, replicatedpg, osd);
 
+using std::less;
 using std::list;
 using std::ostream;
 using std::pair;
 using std::make_pair;
+using std::make_unique;
 using std::map;
 using std::ostringstream;
 using std::set;
@@ -3726,7 +3728,7 @@ ceph_tid_t PrimaryLogPG::refcount_manifest(hobject_t src_soid, hobject_t tgt_soi
     cls_cas_chunk_create_or_get_ref_op get_call;
     get_call.source = src_soid.get_head();
     ceph_assert(chunk);
-    get_call.data = move(*chunk);
+    get_call.data = std::move(*chunk);
     ::encode(get_call, in);
     obj_op.call("cas", "chunk_create_or_get_ref", in);
   } else {
@@ -10493,7 +10495,7 @@ int PrimaryLogPG::start_dedup(OpRequestRef op, ObjectContextRef obc)
     }
     C_SetDedupChunks *fin = new C_SetDedupChunks(this, soid, get_last_peering_reset(), p.first);
     ceph_tid_t tid = refcount_manifest(soid, target, refcount_t::CREATE_OR_GET_REF, 
-                           fin, move(chunks[p.first]));
+                           fin, std::move(chunks[p.first]));
     mop->chunks[target] = make_pair(p.first, p.second.length());
     mop->num_chunks++;
     mop->tids[p.first] = tid;
@@ -10560,7 +10562,7 @@ int PrimaryLogPG::do_cdc(const object_info_t& oi,
     bufferlist chunk;
     chunk.substr_of(bl, p.first, p.second);
     hobject_t target = get_fpoid_from_chunk(oi.soid, chunk);
-    chunks[p.first] = move(chunk);
+    chunks[p.first] = std::move(chunk);
     chunk_map[p.first] = chunk_info_t(0, p.second, target);
     total_length += p.second;
   }
index ea69db4f0bd5078b5e11386a76a66336de78f528..d7d075c77af0778e50b7129ba44e5f600e800ec0 100644 (file)
@@ -278,7 +278,7 @@ public:
     OpRequestRef op;
     std::map<uint64_t, int> results;
     std::map<uint64_t, ceph_tid_t> tids; 
-    std::map<hobject_t, pair<uint64_t, uint64_t>> chunks;
+    std::map<hobject_t, std::pair<uint64_t, uint64_t>> chunks;
     uint64_t num_chunks = 0;
     object_manifest_t new_manifest;
     
@@ -1368,7 +1368,7 @@ protected:
 
   // -- cls_gather --
   std::map<hobject_t, CLSGatherOp> cls_gather_ops;
-  void cancel_cls_gather(map<hobject_t,CLSGatherOp>::iterator iter, bool requeue, std::vector<ceph_tid_t> *tids);
+  void cancel_cls_gather(std::map<hobject_t,CLSGatherOp>::iterator iter, bool requeue, std::vector<ceph_tid_t> *tids);
   void cancel_cls_gather_ops(bool requeue, std::vector<ceph_tid_t> *tids);
 
   // -- scrub --
@@ -1442,7 +1442,7 @@ protected:
   void process_copy_chunk_manifest(hobject_t oid, ceph_tid_t tid, int r, uint64_t offset);
   void finish_promote_manifest(int r, CopyResults *results, ObjectContextRef obc);
   void cancel_and_requeue_proxy_ops(hobject_t oid);
-  void cancel_manifest_ops(bool requeue, vector<ceph_tid_t> *tids);
+  void cancel_manifest_ops(bool requeue, std::vector<ceph_tid_t> *tids);
   ceph_tid_t refcount_manifest(hobject_t src_soid, hobject_t tgt_soid, refcount_t type,
                              Context *cb, std::optional<bufferlist> chunk);
   void dec_all_refcount_manifest(const object_info_t& oi, OpContext* ctx);
index 3747cd698419999770e90b2ed8a59085bd39479a..2bdcbf36c7cfb0e72653522993d9601dedb949e7 100644 (file)
@@ -14,6 +14,8 @@
 #undef dout_prefix
 #define dout_prefix _prefix(_dout, this->m_pg)
 
+using std::vector;
+
 template <class T> static ostream& _prefix(std::ostream* _dout, T* t)
 {
   return t->gen_prefix(*_dout) << " PrimaryLog scrubber pg(" << t->pg_id << ") ";
index f26650bb86d732c7d6ee21c453e41377414e048c..b0715e2decb446dd0d085d0034db15f2ff6db6a4 100644 (file)
@@ -33,6 +33,7 @@ static ostream& _prefix(std::ostream *_dout, ReplicatedBackend *pgb) {
   return pgb->get_parent()->gen_dbg_prefix(*_dout);
 }
 
+using std::less;
 using std::list;
 using std::make_pair;
 using std::map;
index ca71620d0df366ed4ac85d450c183dc6064e3b2d..c36ecdc541322767bae1cec59a70ff3f4d1fd3f6 100644 (file)
@@ -23,6 +23,7 @@ using std::make_pair;
 using std::pair;
 using std::ostream;
 using std::set;
+using std::vector;
 
 using ceph::bufferlist;
 using ceph::decode;
index 2c5da52158fd80b71b4b2148290e9ca130d63e42..bdcd47b6263940df27da0cf7d4a057ecfa848289 100644 (file)
@@ -46,6 +46,7 @@ using std::map;
 using std::ostream;
 using std::pair;
 using std::set;
+using std::shared_ptr;
 using std::string;
 using std::unique_ptr;
 using std::vector;
index 94693bdfc0faed1531b312e6a6aa0fd6711aad7e..43b969c9e3428fd33090a31bd322eab541b75adb 100644 (file)
@@ -1517,12 +1517,12 @@ public:
     return peering_crush_bucket_count != 0;
   }
 
-  bool stretch_set_can_peer(const set<int>& want, const OSDMap& osdmap,
+  bool stretch_set_can_peer(const std::set<int>& want, const OSDMap& osdmap,
                            std::ostream *out) const;
-  bool stretch_set_can_peer(const vector<int>& want, const OSDMap& osdmap,
+  bool stretch_set_can_peer(const std::vector<int>& want, const OSDMap& osdmap,
                            std::ostream *out) const {
     if (!is_stretch_pool()) return true;
-    set<int> swant;
+    std::set<int> swant;
     for (auto i : want) swant.insert(i);
     return stretch_set_can_peer(swant, osdmap, out);
   }
index 0a98f5addc0edb8d4b8cbd5f7a7972613921bb46..41128b2f1b5f743af7795513078075a6075b3640 100644 (file)
 #include "ScrubStore.h"
 #include "scrub_machine.h"
 
+using std::list;
+using std::map;
+using std::pair;
+using std::set;
+using std::stringstream;
+using std::vector;
 using namespace Scrub;
 using namespace std::chrono;
 using namespace std::chrono_literals;
-
+using namespace std::literals;
 
 #define dout_context (m_pg->cct)
 #define dout_subsys ceph_subsys_osd
@@ -838,7 +844,7 @@ std::string PgScrubber::dump_awaited_maps() const
 void PgScrubber::update_op_mode_text()
 {
   auto visible_repair = state_test(PG_STATE_REPAIR);
-  m_mode_desc = (visible_repair ? "repair"sv : (m_is_deep ? "deep-scrub"sv : "scrub"sv));
+  m_mode_desc = (visible_repair ? "repair" : (m_is_deep ? "deep-scrub" : "scrub"));
 
   dout(10) << __func__ << ": repair: visible: " << (visible_repair ? "true" : "false")
           << ", internal: " << (m_is_repair ? "true" : "false")
index 0145ae6515f285f7d98fe438af2d94f1e535b218..cc1f5d8171104883578ca80eab47987931717f84 100644 (file)
@@ -339,7 +339,7 @@ class PgScrubber : public ScrubPgIF, public ScrubMachineListener {
   int asok_debug(std::string_view cmd,
                 std::string param,
                 Formatter* f,
-                stringstream& ss) override;
+                std::stringstream& ss) override;
   int m_debug_blockrange{0};
 
   // -------------------------------------------------------------------------------------------
index 3dd49a82d06a872dd9693ff96e79c8fdbeb36ee1..70ba1fd797edee7d0972f891b866e2e735b8057b 100644 (file)
@@ -3,7 +3,7 @@
 
 #include "recovery_types.h"
 
-ostream& operator<<(ostream& out, const BackfillInterval& bi)
+std::ostream& operator<<(std::ostream& out, const BackfillInterval& bi)
 {
   out << "BackfillInfo(" << bi.begin << "-" << bi.end
       << " " << bi.objects.size() << " objects";
index 30883bf8bf38530f7b73a8aea2f6badd2cec9880..b733464baf606ce6703a848d6d74393814511f8d 100644 (file)
@@ -101,7 +101,7 @@ struct requested_scrub_t {
   bool check_repair{false};
 };
 
-ostream& operator<<(ostream& out, const requested_scrub_t& sf);
+std::ostream& operator<<(std::ostream& out, const requested_scrub_t& sf);
 
 /**
  *  The interface used by the PG when requesting scrub-related info or services
@@ -110,9 +110,9 @@ struct ScrubPgIF {
 
   virtual ~ScrubPgIF() = default;
 
-  friend ostream& operator<<(ostream& out, const ScrubPgIF& s) { return s.show(out); }
+  friend std::ostream& operator<<(std::ostream& out, const ScrubPgIF& s) { return s.show(out); }
 
-  virtual ostream& show(ostream& out) const = 0;
+  virtual std::ostream& show(std::ostream& out) const = 0;
 
   // --------------- triggering state-machine events:
 
@@ -283,5 +283,5 @@ struct ScrubPgIF {
   virtual int asok_debug(std::string_view cmd,
                         std::string param,
                         Formatter* f,
-                        stringstream& ss) = 0;
+                        std::stringstream& ss) = 0;
 };