From: Adam C. Emerson Date: Sat, 7 Mar 2020 09:28:53 +0000 (-0500) Subject: osd: Build target 'common' without using namespace in headers X-Git-Tag: v16.0.0~18^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3499daa1ce1afaf32873c28f137e0d2052be046d;p=ceph.git osd: Build target 'common' without using namespace in headers Part of a changeset to allow building all of 'common' without relying on 'using namespace std' or 'using namespace ceph' at toplevel in headers. Signed-off-by: Adam C. Emerson --- diff --git a/src/osd/ClassHandler.cc b/src/osd/ClassHandler.cc index 0f9f5111c8b..2bf6a69ad10 100644 --- a/src/osd/ClassHandler.cc +++ b/src/osd/ClassHandler.cc @@ -25,6 +25,12 @@ #define CLS_PREFIX "libcls_" #define CLS_SUFFIX ".so" +using std::map; +using std::set; +using std::string; + +using ceph::bufferlist; + int ClassHandler::open_class(const string& cname, ClassData **pcls) { @@ -319,7 +325,7 @@ int ClassHandler::ClassMethod::exec(cls_method_context_t ctx, bufferlist& indata ret = method(ctx, indata.c_str(), indata.length(), &out, &olen); if (out) { // assume *out was allocated via cls_alloc (which calls malloc!) - buffer::ptr bp = buffer::claim_malloc(olen, out); + ceph::buffer::ptr bp = ceph::buffer::claim_malloc(olen, out); outdata.push_back(bp); } } else { diff --git a/src/osd/OSDMap.h b/src/osd/OSDMap.h index cdbacbb1e63..634e385c41b 100644 --- a/src/osd/OSDMap.h +++ b/src/osd/OSDMap.h @@ -1054,17 +1054,17 @@ public: */ uint64_t get_up_osd_features() const; - void get_upmap_pgs(vector *upmap_pgs) const; + void get_upmap_pgs(std::vector *upmap_pgs) const; bool check_pg_upmaps( CephContext *cct, - const vector& to_check, - vector *to_cancel, - map>> *to_remap) const; + const std::vector& to_check, + std::vector *to_cancel, + std::map>> *to_remap) const; void clean_pg_upmaps( CephContext *cct, Incremental *pending_inc, - const vector& to_cancel, - const map>>& to_remap) const; + const std::vector& to_cancel, + const std::map>>& to_remap) const; bool clean_pg_upmaps(CephContext *cct, Incremental *pending_inc) const; int apply_incremental(const Incremental &inc); @@ -1427,7 +1427,7 @@ public: pg_upmap_items.count(pg); } - bool check_full(const set &missing_on) const { + bool check_full(const std::set &missing_on) const { for (auto shard : missing_on) { if (get_state(shard.osd) & CEPH_OSD_FULL) return true; diff --git a/src/osd/OSDMapMapping.cc b/src/osd/OSDMapMapping.cc index ba59c21dfbe..9cd1fbf5823 100644 --- a/src/osd/OSDMapMapping.cc +++ b/src/osd/OSDMapMapping.cc @@ -8,6 +8,8 @@ #include "common/debug.h" +using std::vector; + MEMPOOL_DEFINE_OBJECT_FACTORY(OSDMapMapping, osdmapmapping, osdmap_mapping); diff --git a/src/osd/OSDMapMapping.h b/src/osd/OSDMapMapping.h index 37ec74f6f50..4096c389de4 100644 --- a/src/osd/OSDMapMapping.h +++ b/src/osd/OSDMapMapping.h @@ -33,7 +33,7 @@ public: } // child must implement either form of process - virtual void process(const vector& pgs) = 0; + virtual void process(const std::vector& pgs) = 0; virtual void process(int64_t poolid, unsigned ps_begin, unsigned ps_end) = 0; virtual void complete() = 0; @@ -100,9 +100,9 @@ protected: Job *job; int64_t pool; unsigned begin, end; - vector pgs; + std::vector pgs; - Item(Job *j, vector pgs) : job(j), pgs(pgs) {} + Item(Job *j, std::vector pgs) : job(j), pgs(pgs) {} Item(Job *j, int64_t p, unsigned b, unsigned e) : job(j), pool(p), @@ -158,7 +158,7 @@ public: void queue( Job *job, unsigned pgs_per_item, - const vector& input_pgs); + const std::vector& input_pgs); void drain() { wq.drain(); @@ -275,7 +275,7 @@ private: : Job(osdmap), mapping(m) { mapping->_start(*osdmap); } - void process(const vector& pgs) override {} + void process(const std::vector& pgs) override {} void process(int64_t pool, unsigned ps_begin, unsigned ps_end) override { mapping->_update_range(*osdmap, pool, ps_begin, ps_end); } diff --git a/src/osd/osd_op_util.cc b/src/osd/osd_op_util.cc index 626779843c7..48e3cb4b46a 100644 --- a/src/osd/osd_op_util.cc +++ b/src/osd/osd_op_util.cc @@ -6,6 +6,12 @@ #include "osd/ClassHandler.h" #include "messages/MOSDOp.h" +using std::ostream; +using std::string; +using std::vector; + +using ceph::bufferlist; + bool OpInfo::check_rmw(int flag) const { ceph_assert(rmw_flags != 0); return rmw_flags & flag; diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index cc5d91d528f..416f5cafd76 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -51,11 +51,14 @@ using std::stringstream; using std::unique_ptr; using std::vector; +using ceph::bufferlist; using ceph::decode; using ceph::decode_nohead; using ceph::encode; using ceph::encode_nohead; using ceph::Formatter; +using ceph::make_timespan; +using ceph::JSONFormatter; using namespace std::literals; @@ -3715,7 +3718,7 @@ public: pair get_bounds() const override { return make_pair(first, last + 1); } - void adjust_start_backwards(epoch_t last_epoch_clean) { + void adjust_start_backwards(epoch_t last_epoch_clean) override { first = last_epoch_clean; } @@ -6961,7 +6964,7 @@ int PGLSPlainFilter::init(ceph::bufferlist::const_iterator ¶ms) try { decode(xattr, params); decode(val, params); - } catch (buffer::error &e) { + } catch (ceph::buffer::error &e) { return -EINVAL; } return 0; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index eec67724f24..5c0f0a9ad6f 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -12,7 +12,7 @@ * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software * Foundation. See file COPYING. - * + * */ #ifndef CEPH_OSD_TYPES_H @@ -2372,7 +2372,7 @@ struct osd_stat_t { uint32_t front_max[3]; uint32_t front_last; }; - map hb_pingtime; ///< map of osd id to Interfaces + std::map hb_pingtime; ///< map of osd id to Interfaces osd_stat_t() : snap_trim_queue_len(0), num_snap_trimming(0), num_shards_repaired(0) {} @@ -3686,7 +3686,7 @@ struct pg_lease_t { void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list& o); - friend ostream& operator<<(ostream& out, const pg_lease_t& l) { + friend std::ostream& operator<<(std::ostream& out, const pg_lease_t& l) { return out << "pg_lease(ru " << l.readable_until << " ub " << l.readable_until_ub << " int " << l.interval << ")"; @@ -3713,7 +3713,7 @@ struct pg_lease_ack_t { void dump(ceph::Formatter *f) const; static void generate_test_instances(std::list& o); - friend ostream& operator<<(ostream& out, const pg_lease_ack_t& l) { + friend std::ostream& operator<<(std::ostream& out, const pg_lease_ack_t& l) { return out << "pg_lease_ack(ruub " << l.readable_until_ub << ")"; } }; @@ -3905,7 +3905,7 @@ private: * finally, clean_offsets becomes {[5~10], [30~10]} */ void trim(); - friend ostream& operator<<(ostream& out, const ObjectCleanRegions& ocr); + friend std::ostream& operator<<(std::ostream& out, const ObjectCleanRegions& ocr); public: ObjectCleanRegions() : new_object(false), clean_omap(true) { clean_offsets.insert(0, (uint64_t)-1); @@ -3927,13 +3927,13 @@ public: bool omap_is_dirty() const; bool object_is_exist() const; - void encode(bufferlist &bl) const; - void decode(bufferlist::const_iterator &bl); - void dump(Formatter *f) const; - static void generate_test_instances(list& o); + void encode(ceph::buffer::list &bl) const; + void decode(ceph::buffer::list::const_iterator &bl); + void dump(ceph::Formatter *f) const; + static void generate_test_instances(std::list& o); }; WRITE_CLASS_ENCODER(ObjectCleanRegions) -ostream& operator<<(ostream& out, const ObjectCleanRegions& ocr); +std::ostream& operator<<(std::ostream& out, const ObjectCleanRegions& ocr); struct OSDOp { @@ -4001,18 +4001,18 @@ std::ostream& operator<<(std::ostream& out, const OSDOp& op); struct pg_log_op_return_item_t { int32_t rval; - bufferlist bl; - void encode(bufferlist& p) const { + ceph::buffer::list bl; + void encode(ceph::buffer::list& p) const { using ceph::encode; encode(rval, p); encode(bl, p); } - void decode(bufferlist::const_iterator& p) { + void decode(ceph::buffer::list::const_iterator& p) { using ceph::decode; decode(rval, p); decode(bl, p); } - void dump(Formatter *f) const { + void dump(ceph::Formatter *f) const { f->dump_int("rval", rval); f->dump_unsigned("bl_length", bl.length()); } @@ -4025,7 +4025,7 @@ struct pg_log_op_return_item_t { const pg_log_op_return_item_t& rhs) { return !(lhs == rhs); } - friend ostream& operator<<(ostream& out, const pg_log_op_return_item_t& i) { + friend std::ostream& operator<<(std::ostream& out, const pg_log_op_return_item_t& i) { return out << "r=" << i.rval << "+" << i.bl.length() << "b"; } }; @@ -4091,7 +4091,7 @@ struct pg_log_entry_t { utime_t mtime; // this is the _user_ mtime, mind you int32_t return_code; // only stored for ERRORs for dup detection - vector op_returns; + std::vector op_returns; __s32 op; bool invalid_hash; // only when decoding sobject_t based entries @@ -4185,7 +4185,7 @@ struct pg_log_dup_t { version_t user_version; // the user version for this entry int32_t return_code; // only stored for ERRORs for dup detection - vector op_returns; + std::vector op_returns; pg_log_dup_t() : user_version(0), return_code(0) @@ -6220,11 +6220,11 @@ WRITE_CLASS_ENCODER(pool_pg_num_history_t) // prefix pgmeta_oid keys with _ so that PGLog::read_log_and_missing() can // easily skip them -static const string_view infover_key = "_infover"sv; -static const string_view info_key = "_info"sv; -static const string_view biginfo_key = "_biginfo"sv; -static const string_view epoch_key = "_epoch"sv; -static const string_view fastinfo_key = "_fastinfo"sv; +static const std::string_view infover_key = "_infover"; +static const std::string_view info_key = "_info"; +static const std::string_view biginfo_key = "_biginfo"; +static const std::string_view epoch_key = "_epoch"; +static const std::string_view fastinfo_key = "_fastinfo"; static const __u8 pg_latest_struct_v = 10; // v10 is the new past_intervals encoding @@ -6236,8 +6236,8 @@ static const __u8 pg_compat_struct_v = 10; int prepare_info_keymap( CephContext* cct, - map *km, - string *key_to_remove, + std::map *km, + std::string *key_to_remove, epoch_t epoch, pg_info_t &info, pg_info_t &last_written_info, @@ -6299,10 +6299,10 @@ public: class PGLSPlainFilter : public PGLSFilter { std::string val; public: - int init(ceph::bufferlist::const_iterator ¶ms) override; + int init(ceph::buffer::list::const_iterator ¶ms) override; ~PGLSPlainFilter() override {} bool filter(const hobject_t& obj, - const ceph::bufferlist& xattr_data) const override; + const ceph::buffer::list& xattr_data) const override; };