From bb92cc93ac32c1f98d7cfae778d684b94dd2de58 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 29 Aug 2017 19:16:20 +0200 Subject: [PATCH] rgw: enforce the std::move semantic across the path of RGWUserBuckets. Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 4a7a4344840c873189331f22c8143ba031622d20) --- src/rgw/rgw_bucket.h | 8 ++++++-- src/rgw/rgw_common.h | 39 ++++++++++++++++++++++++++++++++------- src/rgw/rgw_op.cc | 2 +- src/rgw/rgw_op.h | 2 +- src/rgw/rgw_rest_swift.cc | 2 +- src/rgw/rgw_rest_swift.h | 2 +- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 6cc20eb8f6149..69ff714184b5a 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -104,10 +104,14 @@ public: */ class RGWUserBuckets { - map buckets; + std::map buckets; public: - RGWUserBuckets() {} + RGWUserBuckets() = default; + RGWUserBuckets(RGWUserBuckets&&) = default; + + RGWUserBuckets& operator=(const RGWUserBuckets&) = default; + void encode(bufferlist& bl) const { ::encode(buckets, bl); } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 8d299cf39d475..b8080e9ab573b 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -774,11 +774,12 @@ struct RGWUserInfo WRITE_CLASS_ENCODER(RGWUserInfo) struct rgw_pool { - string name; - string ns; + std::string name; + std::string ns; - rgw_pool() {} + rgw_pool() = default; rgw_pool(const rgw_pool& _p) : name(_p.name), ns(_p.ns) {} + rgw_pool(rgw_pool&&) = default; rgw_pool(const string& _s) { from_str(_s); } @@ -834,6 +835,8 @@ struct rgw_pool { DECODE_FINISH(bl); } + rgw_pool& operator=(const rgw_pool&) = default; + bool operator==(const rgw_pool& p) const { return (compare(p) == 0); } @@ -855,10 +858,20 @@ struct rgw_data_placement_target { rgw_pool data_extra_pool; rgw_pool index_pool; - rgw_data_placement_target() {} + rgw_data_placement_target() = default; + rgw_data_placement_target(const rgw_data_placement_target&) = default; + rgw_data_placement_target(rgw_data_placement_target&&) = default; + + rgw_data_placement_target(const rgw_pool& data_pool, + const rgw_pool& data_extra_pool, + const rgw_pool& index_pool) + : data_pool(data_pool), + data_extra_pool(data_extra_pool), + index_pool(index_pool) { + } - rgw_data_placement_target(const rgw_pool& _data_pool, const rgw_pool& _data_extra_pool, const rgw_pool& _index_pool) - : data_pool(_data_pool), data_extra_pool(_data_extra_pool), index_pool(_index_pool) {} + rgw_data_placement_target& + operator=(const rgw_data_placement_target&) = default; const rgw_pool& get_data_extra_pool() const { if (data_extra_pool.empty()) { @@ -984,6 +997,8 @@ struct rgw_bucket { explicit_placement(b.explicit_placement.data_pool, b.explicit_placement.data_extra_pool, b.explicit_placement.index_pool) {} + rgw_bucket(const rgw_bucket&) = default; + rgw_bucket(rgw_bucket&&) = default; void convert(cls_user_bucket *b) const { b->name = name; @@ -1069,6 +1084,8 @@ struct rgw_bucket { void decode_json(JSONObj *obj); static void generate_test_instances(list& o); + rgw_bucket& operator=(const rgw_bucket&) = default; + bool operator<(const rgw_bucket& b) const { return name.compare(b.name) < 0; } @@ -1863,7 +1880,15 @@ struct RGWBucketEnt { real_time creation_time; uint64_t count; - RGWBucketEnt() : size(0), size_rounded(0), count(0) {} + RGWBucketEnt() + : size(0), + size_rounded(0), + count(0) { + } + RGWBucketEnt(const RGWBucketEnt&) = default; + RGWBucketEnt(RGWBucketEnt&&) = default; + + RGWBucketEnt& operator=(const RGWBucketEnt&) = default; explicit RGWBucketEnt(const rgw_user& u, const cls_user_bucket_entry& e) : bucket(u, e.bucket), diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 753a7389235a8..4e092eba42f0a 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1864,7 +1864,7 @@ void RGWListBuckets::execute() map::reverse_iterator riter = m.rbegin(); marker = riter->first; - handle_listing_chunk((buckets)); + handle_listing_chunk(std::move(buckets)); } } while (is_truncated && !done); diff --git a/src/rgw/rgw_op.h b/src/rgw/rgw_op.h index 7fe86fade054f..25af9fc3d4118 100644 --- a/src/rgw/rgw_op.h +++ b/src/rgw/rgw_op.h @@ -616,7 +616,7 @@ public: void execute() override; virtual int get_params() = 0; - virtual void handle_listing_chunk(RGWUserBuckets& buckets) { + virtual void handle_listing_chunk(RGWUserBuckets&& buckets) { /* The default implementation, used by e.g. S3, just generates a new * part of listing and sends it client immediately. Swift can behave * differently: when the reverse option is requested, all incoming diff --git a/src/rgw/rgw_rest_swift.cc b/src/rgw/rgw_rest_swift.cc index 9879e1a429b20..aa9ce48e2ec42 100644 --- a/src/rgw/rgw_rest_swift.cc +++ b/src/rgw/rgw_rest_swift.cc @@ -175,7 +175,7 @@ void RGWListBuckets_ObjStore_SWIFT::send_response_begin(bool has_buckets) } } -void RGWListBuckets_ObjStore_SWIFT::handle_listing_chunk(RGWUserBuckets& buckets) +void RGWListBuckets_ObjStore_SWIFT::handle_listing_chunk(RGWUserBuckets&& buckets) { if (wants_reversed) { /* Just store in the reversal buffer. Its content will be handled later, diff --git a/src/rgw/rgw_rest_swift.h b/src/rgw/rgw_rest_swift.h index 6cdaef487d991..c07356203476c 100644 --- a/src/rgw/rgw_rest_swift.h +++ b/src/rgw/rgw_rest_swift.h @@ -53,7 +53,7 @@ public: ~RGWListBuckets_ObjStore_SWIFT() override {} int get_params() override; - void handle_listing_chunk(RGWUserBuckets& buckets) override; + void handle_listing_chunk(RGWUserBuckets&& buckets) override; void send_response_begin(bool has_buckets) override; void send_response_data(RGWUserBuckets& buckets) override; void send_response_data_reversed(RGWUserBuckets& buckets); -- 2.39.5