rgw: clean-up around and implement the move semantics in RGWBucketEnt.

Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
This commit is contained in:
Radoslaw Zarzynski 2016-12-28 15:54:42 +01:00 committed by Radoslaw Zarzynski
parent f59dc0acfc
commit 545dabe31a
3 changed files with 19 additions and 13 deletions

View File

@ -101,7 +101,7 @@ struct cls_user_bucket_entry {
cls_user_bucket bucket;
size_t size;
size_t size_rounded;
real_time creation_time;
ceph::real_time creation_time;
uint64_t count;
bool user_stats_sync;

View File

@ -106,10 +106,9 @@ int rgw_read_user_buckets(RGWRados * store,
{
int ret;
buckets.clear();
string buckets_obj_id;
std::string buckets_obj_id;
rgw_get_buckets_obj(user_id, buckets_obj_id);
rgw_raw_obj obj(store->get_zone_params().user_uid_pool, buckets_obj_id);
list<cls_user_bucket_entry> entries;
bool truncated = false;
string m = marker;
@ -121,15 +120,18 @@ int rgw_read_user_buckets(RGWRados * store,
}
do {
std::list<cls_user_bucket_entry> entries;
ret = store->cls_user_list_buckets(obj, m, end_marker, max - total, entries, &m, &truncated);
if (ret == -ENOENT)
if (ret == -ENOENT) {
ret = 0;
}
if (ret < 0)
if (ret < 0) {
return ret;
}
for (const auto& entry : entries) {
buckets.add(RGWBucketEnt(user_id, entry));
for (auto& entry : entries) {
buckets.add(RGWBucketEnt(user_id, std::move(entry)));
total++;
}

View File

@ -1884,9 +1884,14 @@ struct RGWBucketEnt {
rgw_bucket bucket;
size_t size;
size_t size_rounded;
real_time creation_time;
ceph::real_time creation_time;
uint64_t count;
/* The placement_rule is necessary to calculate per-storage-policy statics
* of the Swift API. Although the info available in RGWBucketInfo, we need
* to duplicate it here to not affect the performance of buckets listing. */
std::string placement_rule;
RGWBucketEnt()
: size(0),
size_rounded(0),
@ -1894,17 +1899,16 @@ struct RGWBucketEnt {
}
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),
explicit RGWBucketEnt(const rgw_user& u, cls_user_bucket_entry&& e)
: bucket(u, std::move(e.bucket)),
size(e.size),
size_rounded(e.size_rounded),
creation_time(e.creation_time),
count(e.count) {
}
RGWBucketEnt& operator=(const RGWBucketEnt&) = default;
void convert(cls_user_bucket_entry *b) const {
bucket.convert(&b->bucket);
b->size = size;