]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: build without "using namespace std" 42715/head
authorKefu Chai <kchai@redhat.com>
Mon, 9 Aug 2021 11:12:05 +0000 (19:12 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 9 Aug 2021 12:18:10 +0000 (20:18 +0800)
* add "std::" prefix in headers
* add "using" declarations in .cc files.

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

Signed-off-by: Kefu Chai <kchai@redhat.com>
34 files changed:
src/crimson/admin/admin_socket.cc
src/crimson/admin/osd_admin.cc
src/crimson/mon/MonClient.cc
src/crimson/mon/MonClient.h
src/crimson/net/Connection.h
src/crimson/net/Interceptor.h
src/crimson/net/Messenger.h
src/crimson/net/SocketConnection.cc
src/crimson/net/SocketConnection.h
src/crimson/net/SocketMessenger.h
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/cyanstore/cyan_collection.cc
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h
src/crimson/os/seastore/cache.cc
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h
src/crimson/osd/heartbeat.cc
src/crimson/osd/main.cc
src/crimson/osd/objclass.cc
src/crimson/osd/osd.cc
src/crimson/osd/osd_meta.cc
src/crimson/osd/osdmap_gate.cc
src/crimson/osd/pg.cc
src/crimson/osd/pg.h
src/crimson/osd/pg_backend.cc
src/crimson/osd/pg_map.cc
src/crimson/osd/pg_meta.cc
src/crimson/osd/pg_recovery.cc
src/crimson/osd/pg_recovery.h
src/crimson/osd/replicated_recovery_backend.cc
src/crimson/osd/replicated_recovery_backend.h
src/crimson/osd/shard_services.cc
src/crimson/osd/shard_services.h

index 58710e3beef4030e0fb62768fec666b163d9d97a..1593123eb00796c50bf5a64eee6c8b0ea031ecd3 100644 (file)
@@ -29,6 +29,11 @@ seastar::logger& logger()
 }
 }  // namespace
 
+using std::string;
+using std::string_view;
+using std::stringstream;
+using std::unique_ptr;
+
 namespace crimson::admin {
 
 tell_result_t::tell_result_t(int ret, std::string&& err)
index 5c4ffdd2a7e3c03d0fa0a05ae64e1c17503dcb53..e8320458834773f0eb04333a8903bb6632522cfb 100644 (file)
@@ -17,9 +17,6 @@
 #include "crimson/osd/exceptions.h"
 #include "crimson/osd/osd.h"
 
-using crimson::osd::OSD;
-using namespace crimson::common;
-
 namespace {
 seastar::logger& logger()
 {
@@ -27,9 +24,13 @@ seastar::logger& logger()
 }
 }  // namespace
 
-namespace crimson::admin {
-
+using std::string_view;
+using std::unique_ptr;
+using crimson::osd::OSD;
 using crimson::common::local_conf;
+using namespace crimson::common;
+
+namespace crimson::admin {
 
 template <class Hook, class... Args>
 std::unique_ptr<AdminSocketHook> make_asok_hook(Args&&... args)
index 8ad6e74b01afb7f687c61f15889dfc8042694515..0e8e73a05810259b64e9838446180c32ac5eaf9d 100644 (file)
 #include "messages/MMonSubscribe.h"
 #include "messages/MMonSubscribeAck.h"
 
+using std::string;
+using std::tuple;
+using std::vector;
+
 namespace {
   seastar::logger& logger()
   {
index 4648c7310c575b61782aeec1e3d6713722abdd5f..7ad14696c9085acbfe454f248053c92942a672b8 100644 (file)
@@ -70,7 +70,7 @@ class Client : public crimson::net::Dispatcher,
 
   ceph_tid_t last_mon_command_id = 0;
   using command_result_t =
-    seastar::future<std::tuple<std::int32_t, string, ceph::bufferlist>>;
+    seastar::future<std::tuple<std::int32_t, std::string, ceph::bufferlist>>;
   struct mon_command_t {
     ceph::ref_t<MMonCommand> req;
     typename command_result_t::promise_type result;
index a494a6baacbc0f146033bc71b1bdd2ebee077443..e715d059a5eee76230d2b03fcd73e552bef6d7ef 100644 (file)
@@ -136,7 +136,7 @@ class Connection : public seastar::enable_shared_from_this<Connection> {
   // without dispatching any reset event
   virtual void mark_down() = 0;
 
-  virtual void print(ostream& out) const = 0;
+  virtual void print(std::ostream& out) const = 0;
 
   void set_last_keepalive(clock_t::time_point when) {
     last_keepalive = when;
@@ -151,12 +151,12 @@ class Connection : public seastar::enable_shared_from_this<Connection> {
     virtual ~user_private_t() = default;
   };
 private:
-  unique_ptr<user_private_t> user_private;
+  std::unique_ptr<user_private_t> user_private;
 public:
   bool has_user_private() const {
     return user_private != nullptr;
   }
-  void set_user_private(unique_ptr<user_private_t> new_user_private) {
+  void set_user_private(std::unique_ptr<user_private_t> new_user_private) {
     user_private = std::move(new_user_private);
   }
   user_private_t &get_user_private() {
@@ -165,7 +165,7 @@ public:
   }
 };
 
-inline ostream& operator<<(ostream& out, const Connection& conn) {
+inline std::ostream& operator<<(std::ostream& out, const Connection& conn) {
   out << "[";
   conn.print(out);
   out << "]";
index dfa2183ec03a88570d70294c99c392e18031b615..8f34dc3b7c8292a5d5fa79d5098718451a8a0305 100644 (file)
@@ -62,7 +62,8 @@ class socket_blocker {
       return seastar::make_ready_future<>();
     } else {
       p_blocked = seastar::abort_source();
-      return seastar::sleep_abortable(10s, *p_blocked).then([] {
+      return seastar::sleep_abortable(std::chrono::seconds(10),
+                                     *p_blocked).then([] {
         throw std::runtime_error(
             "Timeout (10s) in socket_blocker::wait_blocked()");
       }).handle_exception_type([] (const seastar::sleep_aborted& e) {
@@ -78,7 +79,8 @@ class socket_blocker {
     }
     ceph_assert(!p_unblocked);
     p_unblocked = seastar::abort_source();
-    return seastar::sleep_abortable(10s, *p_unblocked).then([] {
+    return seastar::sleep_abortable(std::chrono::seconds(10),
+                                   *p_unblocked).then([] {
       ceph_abort("Timeout (10s) in socket_blocker::block()");
     }).handle_exception_type([] (const seastar::sleep_aborted& e) {
       // wait done!
index 2b39fbf63a668527e1250e5eb798654f151869df..179a752b746e140cf315e4d8128fa4a839ad3748 100644 (file)
@@ -118,7 +118,7 @@ public:
     auth_server = as;
   }
 
-  virtual void print(ostream& out) const = 0;
+  virtual void print(std::ostream& out) const = 0;
 
   virtual SocketPolicy get_policy(entity_type_t peer_type) const = 0;
 
@@ -144,7 +144,7 @@ public:
          const uint64_t nonce);
 };
 
-inline ostream& operator<<(ostream& out, const Messenger& msgr) {
+inline std::ostream& operator<<(std::ostream& out, const Messenger& msgr) {
   out << "[";
   msgr.print(out);
   out << "]";
index a119b9a96c673e12b3c1daccc46eb13961de3965..99abf890454d0e2a41eb5ba2d74adeb9ffe0622f 100644 (file)
@@ -21,6 +21,7 @@
 #include "Interceptor.h"
 #endif
 
+using std::ostream;
 using namespace crimson::net;
 using crimson::common::local_conf;
 
index e2bdc24853d4895ec625c425710bc5d10552be6b..4513e338f369a9500eec695d9fecbc39b6b95b28 100644 (file)
@@ -75,7 +75,7 @@ class SocketConnection : public Connection {
 
   void mark_down() override;
 
-  void print(ostream& out) const override;
+  void print(std::ostream& out) const override;
 
   /// start a handshake from the client's perspective,
   /// only call when SocketConnection first construct
index 9bd3cfc4f7840e876caea9992e8d319e8a8dbb0d..0e1a2e98fa6fb63c58dd797ea1ad091717cbd8bc 100644 (file)
@@ -85,7 +85,7 @@ class SocketMessenger final : public Messenger {
 
   seastar::future<> shutdown() override;
 
-  void print(ostream& out) const override {
+  void print(std::ostream& out) const override {
     out << get_myname()
         << "(" << logic_name
         << ") " << get_myaddr();
index d05c69ac096448056e2cf8d484421b39d3434e19..dc343b3401002c2588bc1199e31433ac98628857 100644 (file)
 #include "crimson/common/log.h"
 #include "crimson/os/futurized_store.h"
 
+using std::map;
+using std::set;
+using std::string;
+
 namespace {
 
 seastar::logger& logger()
index f44234e845a0023dfdf856f67ea78f4181b6cf47..9a814f978d57267f4addf251d5b4f1ae02215eee 100644 (file)
@@ -2,6 +2,8 @@
 
 #include "cyan_object.h"
 
+using std::make_pair;
+
 namespace crimson::os
 {
 
index 330baab9db4c65b984e9d02569ad41ce3534bdee..964025234c107af94bb0188dec3c274bca52fd76 100644 (file)
@@ -21,6 +21,7 @@ namespace {
   }
 }
 
+using std::string;
 using crimson::common::local_conf;
 
 namespace crimson::os {
index 85349b28714927c936e6edba93224d5006c0b4db..38f8f6d5ec92d1a540078218d511bfe8b75a0b48 100644 (file)
@@ -174,7 +174,7 @@ private:
   int _setattrs(const coll_t& cid, const ghobject_t& oid,
                 std::map<std::string,bufferlist>& aset);
   int _rm_attr(const coll_t& cid, const ghobject_t& oid,
-              string_view name);
+               std::string_view name);
   int _create_collection(const coll_t& cid, int bits);
   boost::intrusive_ptr<Collection> _get_collection(const coll_t& cid);
 };
index b494d142a76501a8416dfad03da52a6b12213ca2..502a35f3ee7b5bff1135d6b413d6bcf2e90d15a2 100644 (file)
@@ -16,6 +16,8 @@
 #include "crimson/os/seastore/onode_manager/staged-fltree/node_extent_manager/seastore.h"
 #include "test/crimson/seastore/test_block.h"
 
+using std::string_view;
+
 namespace crimson::os::seastore {
 
 Cache::Cache(SegmentManager &segment_manager) :
index fb474f483d5dc8b3ada7491bcb2bc00c91891594..ad0df8d0e53b6d7d5a38a37db6c333f9522ada51 100644 (file)
@@ -27,6 +27,7 @@
 #include "crimson/os/seastore/onode_manager.h"
 #include "crimson/os/seastore/object_data_handler.h"
 
+using std::string;
 using crimson::common::local_conf;
 
 namespace crimson::os::seastore {
index d38d49d3a6d54a6af004e25fdcc0643e33fdc8c2..27768fe6ae74ccc4d030128044cd737ea41a3531 100644 (file)
@@ -266,7 +266,7 @@ private:
   omap_get_values_ret_t omap_list(
     CollectionRef ch,
     const ghobject_t &oid,
-    const std::optional<string> &_start,
+    const std::optional<std::string> &_start,
     OMapManager::omap_list_config_t config);
 
   SegmentManagerRef segment_manager;
index 53723f0a7444d2a2b04e1bc69e6bb4febe153c70..2ddeaa9cf1204643f845b28f7c3fed3ce4473457 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "osd/OSDMap.h"
 
+using std::set;
+using std::string;
 using crimson::common::local_conf;
 
 namespace {
@@ -637,7 +639,7 @@ bool Heartbeat::FailingPeers::add_pending(
   if (failure_pending.count(peer)) {
     return false;
   }
-  auto failed_for = chrono::duration_cast<chrono::seconds>(
+  auto failed_for = std::chrono::duration_cast<std::chrono::seconds>(
       now - failed_since).count();
   auto osdmap = heartbeat.service.get_osdmap_service().get_map();
   auto failure_report =
index 3b714ead8619a6b09b899019978e55026d55d1d0..169c2f4540b096a06d149e23f1df6a621a202820 100644 (file)
@@ -30,6 +30,7 @@
 
 namespace bpo = boost::program_options;
 using config_t = crimson::common::ConfigProxy;
+using std::string;
 
 seastar::logger& logger() {
   return crimson::get_logger(ceph_subsys_osd);
index eb1d66ec53dccbd683230355c8bf93271219279a..3ed9697173607a9b78a4f8f3ed5865fc2700778d 100644 (file)
@@ -18,6 +18,9 @@
 #include "auth/Crypto.h"
 #include "common/armor.h"
 
+using std::map;
+using std::string;
+
 static inline int execute_osd_op(cls_method_context_t hctx, OSDOp& op)
 {
   // we can expect the memory under `ret` will be still fine after
index fce209201598c4d4ac6c6ef23408621cc1269e7b..a7e0cbd14993458579edc9e384247a01af8b2bc4 100644 (file)
@@ -64,6 +64,13 @@ namespace {
   static constexpr int TICK_INTERVAL = 1;
 }
 
+using std::make_unique;
+using std::map;
+using std::pair;
+using std::string;
+using std::unique_ptr;
+using std::vector;
+
 using crimson::common::local_conf;
 using crimson::os::FuturizedStore;
 
index 02a7675b433b0a34f30af5d8e79bd148ca8e73f8..eeea9b57280eb4ddb18070c1987bba9bee393164 100644 (file)
@@ -10,6 +10,7 @@
 #include "crimson/os/futurized_store.h"
 #include "os/Transaction.h"
 
+using std::string;
 using read_errorator = crimson::os::FuturizedStore::read_errorator;
 
 void OSDMeta::create(ceph::os::Transaction& t)
index 90afc32b4e4044cdd110b0e97dcca4ab63181018..4add9388d81ac621c30fece71c1fd3554c0cf72f 100644 (file)
@@ -32,7 +32,7 @@ blocking_future<epoch_t> OSDMapGate::wait_for_map(epoch_t epoch)
   } else {
     logger().info("evt epoch is {}, i have {}, will wait", epoch, current);
     auto &blocker = waiting_peering.emplace(
-      epoch, make_pair(blocker_type, epoch)).first->second;
+      epoch, std::make_pair(blocker_type, epoch)).first->second;
     auto fut = blocker.promise.get_shared_future();
     if (shard_services) {
       return blocker.make_blocking_future(
index a5e3251a3d5adc83eea865e98b6ce07e361565f3..fbebbc4b8158b531e4b05b2f6bb269499698d86d 100644 (file)
 #include "crimson/osd/pg_recovery.h"
 #include "crimson/osd/replicated_recovery_backend.h"
 
+using std::ostream;
+using std::set;
+using std::string;
+using std::vector;
+
 namespace {
   seastar::logger& logger() {
     return crimson::get_logger(ceph_subsys_osd);
index b659352af4586eae7f60517811ebfc1b6ae85bf7..39f645fc918780d531b4cfcedff6edb99b992330 100644 (file)
@@ -265,10 +265,10 @@ public:
        }));
   }
 
-  void update_heartbeat_peers(set<int> peers) final {
+  void update_heartbeat_peers(std::set<int> peers) final {
     // Not needed yet
   }
-  void set_probe_targets(const set<pg_shard_t> &probe_set) final {
+  void set_probe_targets(const std::set<pg_shard_t> &probe_set) final {
     // Not needed yet
   }
   void clear_probe_targets() final {
@@ -655,7 +655,7 @@ public:
   epoch_t get_last_peering_reset() const final {
     return peering_state.get_last_peering_reset();
   }
-  const set<pg_shard_t> &get_acting_recovery_backfill() const {
+  const std::set<pg_shard_t> &get_acting_recovery_backfill() const {
     return peering_state.get_acting_recovery_backfill();
   }
   bool is_backfill_target(pg_shard_t osd) const {
@@ -667,11 +667,11 @@ public:
   uint64_t min_peer_features() const {
     return peering_state.get_min_peer_features();
   }
-  const map<hobject_t, set<pg_shard_t>>&
+  const std::map<hobject_t, std::set<pg_shard_t>>&
   get_missing_loc_shards() const {
     return peering_state.get_missing_loc().get_missing_locs();
   }
-  const map<pg_shard_t, pg_missing_t> &get_shard_missing() const {
+  const std::map<pg_shard_t, pg_missing_t> &get_shard_missing() const {
     return peering_state.get_peer_missing();
   }
   epoch_t get_interval_start_epoch() const {
@@ -751,7 +751,7 @@ private:
        oid, get_actingset(), v);
   }
   bool is_degraded_or_backfilling_object(const hobject_t& soid) const;
-  const set<pg_shard_t> &get_actingset() const {
+  const std::set<pg_shard_t> &get_actingset() const {
     return peering_state.get_actingset();
   }
 
index 62f7341c73633aee3b558679801022ee2dad4ca2..5f2ddfcef6a13df2e958c7041cbd31ca311220ce 100644 (file)
@@ -32,6 +32,9 @@ namespace {
   }
 }
 
+using std::runtime_error;
+using std::string;
+using std::string_view;
 using crimson::common::local_conf;
 
 std::unique_ptr<PGBackend>
index 08071f2604fecc37176997e42ab59e8a050e0c8d..6a542aeba1dd94e943930f72e2fe6534efce7f5e 100644 (file)
@@ -12,6 +12,8 @@ namespace {
   }
 }
 
+using std::make_pair;
+
 namespace crimson::osd {
 
 PGMap::PGCreationState::PGCreationState(spg_t pgid) : pgid(pgid) {}
index 6ab4c58fd5b29cec926515bad2b0ba1d9ac604e2..a0b9b37d6035d2fe1f7ed852aca85e6cdae80e43 100644 (file)
@@ -8,6 +8,8 @@
 #include "crimson/os/futurized_collection.h"
 #include "crimson/os/futurized_store.h"
 
+using std::string;
+using std::string_view;
 // prefix pgmeta_oid keys with _ so that PGLog::read_log_and_missing() can
 // easily skip them
 using crimson::os::FuturizedStore;
index e879cb9ec14c207343b50196e5500dd10dd914cc..e076b1c817fd8d0e9e38c55a9ef732f0ecf530a8 100644 (file)
@@ -27,6 +27,9 @@ namespace {
   }
 }
 
+using std::map;
+using std::set;
+
 void PGRecovery::start_pglogbased_recovery()
 {
   using PglogBasedRecovery = crimson::osd::PglogBasedRecovery;
index 7120342dd583700f100e83c4199b57ba0e701913..cdb07cc5c3945035f239c0858980a533fecdc149 100644 (file)
@@ -66,7 +66,7 @@ private:
     const object_stat_sum_t& stat_diff,
     bool is_delete);
   void on_failed_recover(
-    const set<pg_shard_t>& from,
+    const std::set<pg_shard_t>& from,
     const hobject_t& soid,
     const eversion_t& v);
   void on_peer_recover(
index 927551d07681907d9b8b43f6ab339e2378a79454..6eccf8d1a11f08a81ac83001eb56855c8d861506 100644 (file)
@@ -18,6 +18,10 @@ namespace {
   }
 }
 
+using std::less;
+using std::map;
+using std::string;
+
 RecoveryBackend::interruptible_future<>
 ReplicatedRecoveryBackend::recover_object(
   const hobject_t& soid,
index 1d9b6042b9b18e23d1d509715159fecb309a12db..f35011a9d4550fccacbe7eacaa0d0823ff8f80a1 100644 (file)
@@ -83,7 +83,7 @@ protected:
     ceph::bufferlist&& data_included,
     ceph::bufferlist&& omap_header,
     const std::map<std::string, bufferlist, std::less<>> &attrs,
-    std::map<string, bufferlist>&& omap_entries,
+    std::map<std::string, bufferlist>&& omap_entries,
     ceph::os::Transaction *t);
   void submit_push_complete(
     const ObjectRecoveryInfo &recovery_info,
index 41ea91bcebfc4e1ea8fd0725724e6c442a017f1f..1723f775ef9d0e7e3de05adbcba848b0850e7ff3 100644 (file)
@@ -23,6 +23,8 @@ namespace {
   }
 }
 
+using std::vector;
+
 namespace crimson::osd {
 
 ShardServices::ShardServices(
index b6b48a254b1b73d082fed311b45a214450805bce..faacc196f374d6c898f7f910fb429377bb5ab3eb 100644 (file)
@@ -147,11 +147,11 @@ private:
     std::vector<int> acting;
     bool forced = false;
   };
-  map<pg_t, pg_temp_t> pg_temp_wanted;
-  map<pg_t, pg_temp_t> pg_temp_pending;
+  std::map<pg_t, pg_temp_t> pg_temp_wanted;
+  std::map<pg_t, pg_temp_t> pg_temp_pending;
   friend std::ostream& operator<<(std::ostream&, const pg_temp_t&);
 public:
-  void queue_want_pg_temp(pg_t pgid, const vector<int>& want,
+  void queue_want_pg_temp(pg_t pgid, const std::vector<int>& want,
                          bool forced = false);
   void remove_want_pg_temp(pg_t pgid);
   void requeue_pg_temp();
@@ -166,7 +166,7 @@ public:
 
   // PG Created State
 private:
-  set<pg_t> pg_created;
+  std::set<pg_t> pg_created;
 public:
   seastar::future<> send_pg_created(pg_t pgid);
   seastar::future<> send_pg_created();