diff --git a/src/cls/user/cls_user_types.h b/src/cls/user/cls_user_types.h index 8595f25fd1c..3d0d344324b 100644 --- a/src/cls/user/cls_user_types.h +++ b/src/cls/user/cls_user_types.h @@ -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; diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index ae6ce016360..23981b44025 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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 entries; bool truncated = false; string m = marker; @@ -121,15 +120,18 @@ int rgw_read_user_buckets(RGWRados * store, } do { + std::list 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++; } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c19b07ebfb3..f1d9dfe4c36 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -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;