From 871e1f51afe9d6c8b88debc07460b4316121f999 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 1 Feb 2017 19:05:50 +0100 Subject: [PATCH] rgw: be aware abount tenants on cls_user_bucket -> rgw_bucket conversion. Fixes: http://tracker.ceph.com/issues/18364 Fixes: http://tracker.ceph.com/issues/16355 Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_bucket.cc | 5 ++--- src/rgw/rgw_bucket.h | 2 +- src/rgw/rgw_common.h | 25 ++++++++++++++++--------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 63a0e45881a7..a1ec0f0a0b09 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -133,9 +133,8 @@ int rgw_read_user_buckets(RGWRados * store, if (ret < 0) return ret; - for (list::iterator q = entries.begin(); q != entries.end(); ++q) { - RGWBucketEnt e(*q); - buckets.add(e); + for (const auto& entry : entries) { + buckets.add(RGWBucketEnt(user_id, entry)); total++; } diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index ff6c8c61e6d5..93b781f00eec 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -126,7 +126,7 @@ public: /** * Add a (created) bucket to the user's bucket list. */ - void add(RGWBucketEnt& bucket) { + void add(const RGWBucketEnt& bucket) { buckets[bucket.bucket.name] = bucket; } diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index c5aa61daf789..14f7e24618bf 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -737,10 +737,15 @@ struct rgw_bucket { rgw_bucket() { } // cppcheck-suppress noExplicitConstructor - rgw_bucket(const cls_user_bucket& b) : name(b.name), data_pool(b.data_pool), - data_extra_pool(b.data_extra_pool), - index_pool(b.index_pool), marker(b.marker), - bucket_id(b.bucket_id) {} + explicit rgw_bucket(const rgw_user& u, const cls_user_bucket& b) + : tenant(u.tenant), + name(b.name), + data_pool(b.data_pool), + data_extra_pool(b.data_extra_pool), + index_pool(b.index_pool), + marker(b.marker), + bucket_id(b.bucket_id) { + } rgw_bucket(const string& s) : name(s) { data_pool = index_pool = s; marker = ""; @@ -1414,11 +1419,13 @@ struct RGWBucketEnt { RGWBucketEnt() : size(0), size_rounded(0), count(0) {} - explicit RGWBucketEnt(const cls_user_bucket_entry& e) : bucket(e.bucket), - size(e.size), - size_rounded(e.size_rounded), - creation_time(e.creation_time), - count(e.count) {} + explicit RGWBucketEnt(const rgw_user& u, const cls_user_bucket_entry& e) + : bucket(u, e.bucket), + size(e.size), + size_rounded(e.size_rounded), + creation_time(e.creation_time), + count(e.count) { + } void convert(cls_user_bucket_entry *b) { bucket.convert(&b->bucket); -- 2.47.3