From: Kefu Chai Date: Wed, 11 Aug 2021 03:48:00 +0000 (+0800) Subject: librbd: build without "using namespace std" X-Git-Tag: v17.1.0~1121^2~35 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6eb14774fec0fce1145a440570bfd76234675b42;p=ceph.git librbd: build without "using namespace std" * 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 --- diff --git a/src/common/options/rbd.yaml.in b/src/common/options/rbd.yaml.in index e8f5d0d2555a..e7b2f2e6048d 100644 --- a/src/common/options/rbd.yaml.in +++ b/src/common/options/rbd.yaml.in @@ -57,7 +57,7 @@ options: - runtime validator: | [](std::string *value, std::string *error_message) { - stringstream ss; + std::stringstream ss; uint64_t features = librbd::rbd_features_from_string(*value, &ss); // Leave this in integer form to avoid breaking Cinder. Someday // we would like to present this in string form instead... @@ -748,7 +748,7 @@ options: - runtime validator: | [](std::string *value, std::string *error_message) { - ostringstream ss; + std::ostringstream ss; uint64_t exclude_ops = librbd::io::rbd_io_operations_from_string(*value, &ss); // Leave this in integer form to avoid breaking Cinder. Someday // we would like to present this in string form instead... diff --git a/src/librbd/BlockGuard.h b/src/librbd/BlockGuard.h index 2474e3c022ab..1fbbc05c8e9a 100644 --- a/src/librbd/BlockGuard.h +++ b/src/librbd/BlockGuard.h @@ -31,7 +31,7 @@ struct BlockExtent { : block_start(block_start), block_end(block_end) { } - friend ostream& operator<< (ostream& os, const BlockExtent& block_extent) { + friend std::ostream& operator<< (std::ostream& os, const BlockExtent& block_extent) { os << "[block_start = " << block_extent.block_start << ", " << "block_end = " << block_extent.block_end << ")"; return os; diff --git a/src/librbd/ImageCtx.h b/src/librbd/ImageCtx.h index ba44d314c86c..2fe67c408ede 100644 --- a/src/librbd/ImageCtx.h +++ b/src/librbd/ImageCtx.h @@ -83,7 +83,7 @@ namespace librbd { } }; - static const string METADATA_CONF_PREFIX; + static const std::string METADATA_CONF_PREFIX; CephContext *cct; ConfigProxy config; @@ -281,7 +281,7 @@ namespace librbd { uint64_t get_current_size() const; uint64_t get_object_size() const; - string get_object_name(uint64_t num) const; + std::string get_object_name(uint64_t num) const; uint64_t get_stripe_unit() const; uint64_t get_stripe_count() const; uint64_t get_stripe_period() const; @@ -324,7 +324,7 @@ namespace librbd { int get_parent_overlap(librados::snap_t in_snap_id, uint64_t *overlap) const; void register_watch(Context *on_finish); - uint64_t prune_parent_extents(vector >& objectx, + uint64_t prune_parent_extents(std::vector >& objectx, uint64_t overlap); void cancel_async_requests(); diff --git a/src/librbd/Utils.cc b/src/librbd/Utils.cc index dadf6ab8126a..112f342bd026 100644 --- a/src/librbd/Utils.cc +++ b/src/librbd/Utils.cc @@ -67,7 +67,7 @@ std::string generate_image_id(librados::IoCtx &ioctx) { std::uniform_int_distribution distribution{0, 0xFFFFFFFF}; uint32_t extra = distribution(generator); - ostringstream bid_ss; + std::ostringstream bid_ss; bid_ss << std::hex << bid << std::hex << extra; std::string id = bid_ss.str(); diff --git a/src/librbd/Watcher.h b/src/librbd/Watcher.h index 96ecda7d0e7b..e029430c5b7d 100644 --- a/src/librbd/Watcher.h +++ b/src/librbd/Watcher.h @@ -44,7 +44,7 @@ public: void unblock_notifies(); std::string get_oid() const; - void set_oid(const string& oid); + void set_oid(const std::string& oid); uint64_t get_watch_handle() const { std::shared_lock watch_locker{m_watch_lock}; diff --git a/src/librbd/api/DiffIterate.cc b/src/librbd/api/DiffIterate.cc index dcd07ea56a3d..c73610df3096 100644 --- a/src/librbd/api/DiffIterate.cc +++ b/src/librbd/api/DiffIterate.cc @@ -263,11 +263,11 @@ int DiffIterate::execute() { while (left > 0) { uint64_t period_off = off - (off % period); - uint64_t read_len = min(period_off + period - off, left); + uint64_t read_len = std::min(period_off + period - off, left); if (fast_diff_enabled) { // map to extents - map > object_extents; + std::map > object_extents; Striper::file_to_extents(cct, m_image_ctx.format_string, &m_image_ctx.layout, off, read_len, 0, object_extents, 0); diff --git a/src/librbd/api/Group.cc b/src/librbd/api/Group.cc index 512df799791f..cb6b44e8d5a0 100644 --- a/src/librbd/api/Group.cc +++ b/src/librbd/api/Group.cc @@ -59,7 +59,7 @@ string generate_uuid(librados::IoCtx& io_ctx) uint64_t bid = rados.get_instance_id(); uint32_t extra = rand() % 0xFFFFFFFF; - ostringstream bid_ss; + std::ostringstream bid_ss; bid_ss << std::hex << bid << std::hex << extra; return bid_ss.str(); } diff --git a/src/librbd/api/Image.cc b/src/librbd/api/Image.cc index 7df0f4fc69e2..eab7efdb2647 100644 --- a/src/librbd/api/Image.cc +++ b/src/librbd/api/Image.cc @@ -32,6 +32,8 @@ #undef dout_prefix #define dout_prefix *_dout << "librbd::api::Image: " << __func__ << ": " +using std::map; +using std::string; using librados::snap_t; namespace librbd { diff --git a/src/librbd/api/Mirror.cc b/src/librbd/api/Mirror.cc index 825d430bc05b..51716ff36987 100644 --- a/src/librbd/api/Mirror.cc +++ b/src/librbd/api/Mirror.cc @@ -538,7 +538,7 @@ int Mirror::image_disable(I *ictx, bool force) { }; std::unique_lock image_locker{ictx->image_lock}; - map snap_info = ictx->snap_info; + std::map snap_info = ictx->snap_info; for (auto &info : snap_info) { cls::rbd::ParentImageSpec parent_spec{ictx->md_ctx.get_id(), ictx->md_ctx.get_namespace(), @@ -1115,7 +1115,7 @@ int Mirror::mode_set(librados::IoCtx& io_ctx, } if (next_mirror_mode == cls::rbd::MIRROR_MODE_POOL) { - map images; + std::map images; r = Image::list_images_v2(io_ctx, &images); if (r < 0) { lderr(cct) << "failed listing images: " << cpp_strerror(r) << dendl; @@ -1552,7 +1552,7 @@ int Mirror::peer_site_remove(librados::IoCtx& io_ctx, return r; } - vector names; + std::vector names; r = Namespace::list(io_ctx, &names); if (r < 0) { return r; @@ -1829,9 +1829,9 @@ int Mirror::image_global_status_list( CephContext *cct = reinterpret_cast(io_ctx.cct()); int r; - map id_to_name; + std::map id_to_name; { - map name_to_id; + std::map name_to_id; r = Image::list_images_v2(io_ctx, &name_to_id); if (r < 0) { return r; @@ -1841,8 +1841,8 @@ int Mirror::image_global_status_list( } } - map images_; - map statuses_; + std::map images_; + std::map statuses_; r = librbd::cls_client::mirror_image_status_list(&io_ctx, start_id, max, &images_, &statuses_); @@ -1969,8 +1969,8 @@ int Mirror::image_info_list( entries->clear(); while (entries->size() < max) { - map images; - map statuses; + std::map images; + std::map statuses; int r = librbd::cls_client::mirror_image_status_list(&io_ctx, last_read, max, &images, diff --git a/src/librbd/api/Namespace.cc b/src/librbd/api/Namespace.cc index 6c5ac7fda314..86ed70c06ace 100644 --- a/src/librbd/api/Namespace.cc +++ b/src/librbd/api/Namespace.cc @@ -169,7 +169,7 @@ rollback: } template -int Namespace::list(IoCtx& io_ctx, vector *names) +int Namespace::list(IoCtx& io_ctx, std::vector *names) { CephContext *cct = (CephContext *)io_ctx.cct(); ldout(cct, 5) << dendl; diff --git a/src/librbd/api/Snapshot.cc b/src/librbd/api/Snapshot.cc index 88f22694cf28..c175808bdc24 100644 --- a/src/librbd/api/Snapshot.cc +++ b/src/librbd/api/Snapshot.cc @@ -62,7 +62,7 @@ public: return r; } - string group_header_oid = util::group_header_name(snap_namespace.group_id); + std::string group_header_oid = util::group_header_name(snap_namespace.group_id); r = cls_client::group_snap_get_by_id(&group_ioctx, group_header_oid, snap_namespace.group_snapshot_id, @@ -277,7 +277,7 @@ int Snapshot::get_id(I *ictx, const std::string& snap_name, uint64_t *snap_id } template -int Snapshot::list(I *ictx, vector& snaps) { +int Snapshot::list(I *ictx, std::vector& snaps) { ldout(ictx->cct, 20) << "snap_list " << ictx << dendl; int r = ictx->state->refresh_if_required(); diff --git a/src/librbd/api/Trash.cc b/src/librbd/api/Trash.cc index 7285e9e990c1..d8189e8a73d2 100644 --- a/src/librbd/api/Trash.cc +++ b/src/librbd/api/Trash.cc @@ -119,7 +119,7 @@ int list_trash_image_specs( uint32_t max_read = 1024; std::string last_read; do { - std::map trash_entries; + std::map trash_entries; int r = cls_client::trash_list(&io_ctx, last_read, max_read, &trash_entries); if (r < 0 && r != -ENOENT) { @@ -347,7 +347,7 @@ int Trash::get(IoCtx &io_ctx, const std::string &id, } template -int Trash::list(IoCtx &io_ctx, vector &entries, +int Trash::list(IoCtx &io_ctx, std::vector &entries, bool exclude_user_remove_source) { CephContext *cct((CephContext *)io_ctx.cct()); ldout(cct, 20) << __func__ << " " << &io_ctx << dendl; diff --git a/src/librbd/cache/ObjectCacherWriteback.cc b/src/librbd/cache/ObjectCacherWriteback.cc index 9f3d5c8953e2..8c0aaa7bcda5 100644 --- a/src/librbd/cache/ObjectCacherWriteback.cc +++ b/src/librbd/cache/ObjectCacherWriteback.cc @@ -32,6 +32,8 @@ #undef dout_prefix #define dout_prefix *_dout << "librbd::cache::ObjectCacherWriteback: " +using namespace std; + namespace librbd { namespace cache { diff --git a/src/librbd/cache/ParentCacheObjectDispatch.cc b/src/librbd/cache/ParentCacheObjectDispatch.cc index 5953dceca018..d42a3b88bff6 100644 --- a/src/librbd/cache/ParentCacheObjectDispatch.cc +++ b/src/librbd/cache/ParentCacheObjectDispatch.cc @@ -20,6 +20,7 @@ #define dout_prefix *_dout << "librbd::cache::ParentCacheObjectDispatch: " \ << this << " " << __func__ << ": " +using namespace std; using namespace ceph::immutable_obj_cache; using librbd::util::data_object_name; diff --git a/src/librbd/cache/pwl/AbstractWriteLog.cc b/src/librbd/cache/pwl/AbstractWriteLog.cc index ab69c0732389..8ad905ad2f7b 100644 --- a/src/librbd/cache/pwl/AbstractWriteLog.cc +++ b/src/librbd/cache/pwl/AbstractWriteLog.cc @@ -31,6 +31,7 @@ namespace librbd { namespace cache { namespace pwl { +using namespace std; using namespace librbd::cache::pwl; typedef AbstractWriteLog::Extent Extent; diff --git a/src/librbd/cache/pwl/ImageCacheState.cc b/src/librbd/cache/pwl/ImageCacheState.cc index 11074befb57d..65de7b70f4e0 100644 --- a/src/librbd/cache/pwl/ImageCacheState.cc +++ b/src/librbd/cache/pwl/ImageCacheState.cc @@ -22,6 +22,8 @@ namespace librbd { namespace cache { namespace pwl { +using namespace std; + namespace { bool get_json_format(const std::string& s, JSONFormattable *f) { JSONParser p; diff --git a/src/librbd/cache/pwl/LogOperation.cc b/src/librbd/cache/pwl/LogOperation.cc index 54da5a2e002d..ee90df41baae 100644 --- a/src/librbd/cache/pwl/LogOperation.cc +++ b/src/librbd/cache/pwl/LogOperation.cc @@ -205,7 +205,7 @@ void WriteLogOperation::init(bool has_data, std::vector:: } std::ostream &WriteLogOperation::format(std::ostream &os) const { - string op_name = is_writesame ? "(Write Same) " : "(Write) "; + std::string op_name = is_writesame ? "(Write Same) " : "(Write) "; os << op_name; GenericWriteLogOperation::format(os); os << ", "; diff --git a/src/librbd/cache/pwl/Request.cc b/src/librbd/cache/pwl/Request.cc index 5288af9d01ae..4770e498fba5 100644 --- a/src/librbd/cache/pwl/Request.cc +++ b/src/librbd/cache/pwl/Request.cc @@ -11,6 +11,8 @@ #define dout_prefix *_dout << "librbd::cache::pwl::Request: " << this << " " \ << __func__ << ": " +using namespace std; + namespace librbd { namespace cache { namespace pwl { diff --git a/src/librbd/cache/pwl/Request.h b/src/librbd/cache/pwl/Request.h index 8d5a0b4742a7..86dd0f880ad1 100644 --- a/src/librbd/cache/pwl/Request.h +++ b/src/librbd/cache/pwl/Request.h @@ -136,7 +136,7 @@ public: bufferlist cmp_bl; bufferlist read_bl; bool is_comp_and_write = false; - unique_ptr op_set = nullptr; + std::unique_ptr op_set = nullptr; C_WriteRequest(T &pwl, const utime_t arrived, io::Extents &&image_extents, bufferlist&& bl, const int fadvise_flags, ceph::mutex &lock, diff --git a/src/librbd/cache/pwl/Types.cc b/src/librbd/cache/pwl/Types.cc index 827125c31f8f..c218c5773ea7 100644 --- a/src/librbd/cache/pwl/Types.cc +++ b/src/librbd/cache/pwl/Types.cc @@ -70,7 +70,7 @@ void WriteLogCacheEntry::dump(Formatter *f) const { f->dump_unsigned("entry_index", entry_index); } -void WriteLogCacheEntry::generate_test_instances(list& ls) { +void WriteLogCacheEntry::generate_test_instances(std::list& ls) { ls.push_back(new WriteLogCacheEntry); ls.push_back(new WriteLogCacheEntry); ls.back()->sync_gen_number = 1; @@ -98,7 +98,7 @@ void WriteLogPoolRoot::dump(Formatter *f) const { f->dump_unsigned("first_free_entry", first_free_entry); f->dump_unsigned("first_valid_entry", first_valid_entry); } -void WriteLogPoolRoot::generate_test_instances(list& ls) { +void WriteLogPoolRoot::generate_test_instances(std::list& ls) { ls.push_back(new WriteLogPoolRoot); ls.push_back(new WriteLogPoolRoot); ls.back()->layout_version = 2; diff --git a/src/librbd/cache/pwl/Types.h b/src/librbd/cache/pwl/Types.h index 530c6df9ef75..c62096a84576 100644 --- a/src/librbd/cache/pwl/Types.h +++ b/src/librbd/cache/pwl/Types.h @@ -274,7 +274,7 @@ struct WriteLogCacheEntry { } #endif void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; struct WriteLogPoolRoot { @@ -315,7 +315,7 @@ struct WriteLogPoolRoot { #endif void dump(ceph::Formatter *f) const; - static void generate_test_instances(list& ls); + static void generate_test_instances(std::list& ls); }; struct WriteBufferAllocation { diff --git a/src/librbd/cache/pwl/rwl/WriteLog.cc b/src/librbd/cache/pwl/rwl/WriteLog.cc index a725d05f092a..dcb036693e5e 100644 --- a/src/librbd/cache/pwl/rwl/WriteLog.cc +++ b/src/librbd/cache/pwl/rwl/WriteLog.cc @@ -29,6 +29,7 @@ namespace librbd { namespace cache { namespace pwl { +using namespace std; using namespace librbd::cache::pwl; namespace rwl { diff --git a/src/librbd/cache/pwl/ssd/Types.h b/src/librbd/cache/pwl/ssd/Types.h index e34b7516684c..fe82dee9edf7 100644 --- a/src/librbd/cache/pwl/ssd/Types.h +++ b/src/librbd/cache/pwl/ssd/Types.h @@ -27,7 +27,7 @@ struct SuperBlock{ f->dump_object("super", root); } - static void generate_test_instances(list& ls) { + static void generate_test_instances(std::list& ls) { ls.push_back(new SuperBlock); ls.push_back(new SuperBlock); ls.back()->root.first_valid_entry = 2; diff --git a/src/librbd/cache/pwl/ssd/WriteLog.cc b/src/librbd/cache/pwl/ssd/WriteLog.cc index efe482287fa0..8258a3de8ef6 100644 --- a/src/librbd/cache/pwl/ssd/WriteLog.cc +++ b/src/librbd/cache/pwl/ssd/WriteLog.cc @@ -30,6 +30,7 @@ namespace cache { namespace pwl { namespace ssd { +using namespace std; using namespace librbd::cache::pwl; // SSD: this number can be updated later @@ -76,7 +77,7 @@ void WriteLog::collect_read_extents( // Make a bl for this hit extent. This will add references to the // write_entry->cache_bl */ ldout(m_image_ctx.cct, 5) << dendl; - auto write_entry = static_pointer_cast(map_entry.log_entry); + auto write_entry = std::static_pointer_cast(map_entry.log_entry); buffer::list hit_bl; hit_bl = write_entry->get_cache_bl(); bool writesame = write_entry->is_writesame_entry(); diff --git a/src/librbd/image/CreateRequest.cc b/src/librbd/image/CreateRequest.cc index 3d7c905a2c02..dd0ab2fff8f0 100644 --- a/src/librbd/image/CreateRequest.cc +++ b/src/librbd/image/CreateRequest.cc @@ -432,7 +432,7 @@ void CreateRequest::create_image() { ldout(m_cct, 15) << dendl; ceph_assert(m_data_pool.empty() || m_data_pool_id != -1); - ostringstream oss; + std::ostringstream oss; oss << RBD_DATA_PREFIX; if (m_data_pool_id != -1) { oss << stringify(m_io_ctx.get_id()) << "."; diff --git a/src/librbd/internal.cc b/src/librbd/internal.cc index db780956b561..dba15bdf23a1 100644 --- a/src/librbd/internal.cc +++ b/src/librbd/internal.cc @@ -68,6 +68,7 @@ #define rbd_howmany(x, y) (((x) + (y) - 1) / (y)) +using std::istringstream; using std::map; using std::pair; using std::set; @@ -1325,7 +1326,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { } } - uint64_t len = min(period, src_size - offset); + uint64_t len = std::min(period, src_size - offset); bufferlist *bl = new bufferlist(); auto ctx = new C_CopyRead(&throttle, dest, offset, bl, sparse_size); auto comp = io::AioCompletion::create_and_start( @@ -1536,7 +1537,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) { start_time = coarse_mono_clock::now(); while (left > 0) { uint64_t period_off = off - (off % period); - uint64_t read_len = min(period_off + period - off, left); + uint64_t read_len = std::min(period_off + period - off, left); bufferlist bl; diff --git a/src/librbd/internal.h b/src/librbd/internal.h index 9bd03228a54e..2b2400b8c8cf 100644 --- a/src/librbd/internal.h +++ b/src/librbd/internal.h @@ -132,7 +132,8 @@ namespace librbd { int invalidate_cache(ImageCtx *ictx); int poll_io_events(ImageCtx *ictx, io::AioCompletion **comps, int numcomp); - int metadata_list(ImageCtx *ictx, const string &last, uint64_t max, map *pairs); + int metadata_list(ImageCtx *ictx, const std::string &last, uint64_t max, + std::map *pairs); int metadata_get(ImageCtx *ictx, const std::string &key, std::string *value); int list_watchers(ImageCtx *ictx, std::list &watchers); diff --git a/src/librbd/io/QosImageDispatch.cc b/src/librbd/io/QosImageDispatch.cc index 324c670fe1fb..ba7b37049851 100644 --- a/src/librbd/io/QosImageDispatch.cc +++ b/src/librbd/io/QosImageDispatch.cc @@ -56,10 +56,10 @@ QosImageDispatch::QosImageDispatch(I* image_ctx) SafeTimer *timer; ceph::mutex *timer_lock; ImageCtx::get_timer_instance(cct, &timer, &timer_lock); - for (auto flag : throttle_flags) { - m_throttles.push_back(make_pair( - flag.first, - new TokenBucketThrottle(cct, flag.second, 0, 0, timer, timer_lock))); + for (auto [flag, name] : throttle_flags) { + m_throttles.emplace_back( + flag, + new TokenBucketThrottle(cct, name, 0, 0, timer, timer_lock)); } } diff --git a/src/librbd/journal/Types.h b/src/librbd/journal/Types.h index ae5681ade067..d57858a15900 100644 --- a/src/librbd/journal/Types.h +++ b/src/librbd/journal/Types.h @@ -372,12 +372,12 @@ struct UpdateFeaturesEvent : public OpEventBase { struct MetadataSetEvent : public OpEventBase { static const EventType TYPE = EVENT_TYPE_METADATA_SET; - string key; - string value; + std::string key; + std::string value; MetadataSetEvent() { } - MetadataSetEvent(uint64_t op_tid, const string &_key, const string &_value) + MetadataSetEvent(uint64_t op_tid, const std::string &_key, const std::string &_value) : OpEventBase(op_tid), key(_key), value(_value) { } @@ -389,11 +389,11 @@ struct MetadataSetEvent : public OpEventBase { struct MetadataRemoveEvent : public OpEventBase { static const EventType TYPE = EVENT_TYPE_METADATA_REMOVE; - string key; + std::string key; MetadataRemoveEvent() { } - MetadataRemoveEvent(uint64_t op_tid, const string &_key) + MetadataRemoveEvent(uint64_t op_tid, const std::string &_key) : OpEventBase(op_tid), key(_key) { } diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index a803b7db7f25..4557b2c7558e 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -61,6 +61,10 @@ #undef dout_prefix #define dout_prefix *_dout << "librbd: " +using std::list; +using std::map; +using std::pair; +using std::set; using std::string; using std::vector; diff --git a/src/librbd/managed_lock/ReleaseRequest.cc b/src/librbd/managed_lock/ReleaseRequest.cc index 598ececab051..6707a149f4fc 100644 --- a/src/librbd/managed_lock/ReleaseRequest.cc +++ b/src/librbd/managed_lock/ReleaseRequest.cc @@ -16,6 +16,8 @@ #define dout_prefix *_dout << "librbd::managed_lock::ReleaseRequest: " \ << this << " " << __func__ << ": " +using std::string; + namespace librbd { namespace managed_lock { diff --git a/src/librbd/operation/SnapshotRemoveRequest.cc b/src/librbd/operation/SnapshotRemoveRequest.cc index b78be8a0af6b..cc975d176350 100644 --- a/src/librbd/operation/SnapshotRemoveRequest.cc +++ b/src/librbd/operation/SnapshotRemoveRequest.cc @@ -481,7 +481,7 @@ int SnapshotRemoveRequest::scan_for_parents( ceph_assert(ceph_mutex_is_locked(image_ctx.image_lock)); if (pspec.pool_id != -1) { - map::iterator it; + std::map::iterator it; for (it = image_ctx.snap_info.begin(); it != image_ctx.snap_info.end(); ++it) { // skip our snap id (if checking base image, CEPH_NOSNAP won't match) diff --git a/src/librbd/operation/TrimRequest.cc b/src/librbd/operation/TrimRequest.cc index b8ecf10acf1c..6fda48aa769f 100644 --- a/src/librbd/operation/TrimRequest.cc +++ b/src/librbd/operation/TrimRequest.cc @@ -42,7 +42,7 @@ public: ceph_assert(image_ctx.exclusive_lock == nullptr || image_ctx.exclusive_lock->is_lock_owner()); - string oid = image_ctx.get_object_name(m_object_no); + std::string oid = image_ctx.get_object_name(m_object_no); ldout(image_ctx.cct, 10) << "removing (with copyup) " << oid << dendl; auto object_dispatch_spec = io::ObjectDispatchSpec::create_discard( @@ -80,7 +80,7 @@ public: } } - string oid = image_ctx.get_object_name(m_object_no); + std::string oid = image_ctx.get_object_name(m_object_no); ldout(image_ctx.cct, 10) << "removing " << oid << dendl; librados::AioCompletion *rados_completion = @@ -343,19 +343,18 @@ void TrimRequest::send_clean_boundary() { ContextCompletion *completion = new ContextCompletion(this->create_async_callback_context(), true); - for (vector::iterator p = extents.begin(); - p != extents.end(); ++p) { - ldout(cct, 20) << " ex " << *p << dendl; + for (auto& extent : extents) { + ldout(cct, 20) << " ex " << extent << dendl; Context *req_comp = new C_ContextCompletion(*completion); - if (p->offset == 0) { + if (extent.offset == 0) { // treat as a full object delete on the boundary - p->length = image_ctx.layout.object_size; + extent.length = image_ctx.layout.object_size; } auto object_dispatch_spec = io::ObjectDispatchSpec::create_discard( - &image_ctx, io::OBJECT_DISPATCH_LAYER_NONE, p->objectno, p->offset, - p->length, io_context, 0, 0, {}, req_comp); + &image_ctx, io::OBJECT_DISPATCH_LAYER_NONE, extent.objectno, extent.offset, + extent.length, io_context, 0, 0, {}, req_comp); object_dispatch_spec->send(); } completion->finish_adding_requests();