]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: clean-up around and implement the move semantics in RGWBucketEnt.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Wed, 28 Dec 2016 14:54:42 +0000 (15:54 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 19 Sep 2017 11:51:07 +0000 (13:51 +0200)
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/cls/user/cls_user_types.h
src/rgw/rgw_bucket.cc
src/rgw/rgw_common.h

index 8595f25fd1cae35bc4a9e2821ce47679809b14da..3d0d344324bb28028c610566e64f9e9089d9ca43 100644 (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;
 
index ae6ce0163602ef1c310cd8abb37dcd04e855515e..23981b44025962e4954c42bb3b98784c54aa0fac 100644 (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++;
     }
 
index c19b07ebfb3e454759d04a5b0fdd0a4291028e3b..f1d9dfe4c365ba61bfc5a4a36f5412123a4801a1 100644 (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;