From 7dd54fa3621c04c8ea5723fb1bc06b91d81a0c6c Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 31 Mar 2015 12:41:11 +0200 Subject: [PATCH] rgw: make rgw_read_user_buckets() backward compatible. Fixes: #10683 Backport: hammer Signed-off-by: Radoslaw Zarzynski --- src/rgw/rgw_bucket.cc | 13 +++++++++++-- src/rgw/rgw_bucket.h | 9 +++++++-- src/rgw/rgw_op.cc | 2 +- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 5d2af38ea6fb1..c3aab8e86aedd 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -42,8 +42,13 @@ void rgw_get_buckets_obj(const string& user_id, string& buckets_obj_id) * Get all the buckets owned by a user and fill up an RGWUserBuckets with them. * Returns: 0 on success, -ERR# on failure. */ -int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& buckets, - const string& marker, uint64_t max, bool need_stats) +int rgw_read_user_buckets(RGWRados * store, + string user_id, + RGWUserBuckets& buckets, + const string& marker, + uint64_t max, + bool need_stats, + uint64_t default_amount) { int ret; buckets.clear(); @@ -59,6 +64,10 @@ int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& bucke uint64_t total = 0; + if (!max) { + max = default_amount; + } + do { ret = store->cls_user_list_buckets(obj, m, max - total, entries, &m, &truncated); if (ret == -ENOENT) diff --git a/src/rgw/rgw_bucket.h b/src/rgw/rgw_bucket.h index 830e096c98777..222e152b10ffb 100644 --- a/src/rgw/rgw_bucket.h +++ b/src/rgw/rgw_bucket.h @@ -104,8 +104,13 @@ extern void rgw_bucket_init(RGWMetadataManager *mm); * Get all the buckets owned by a user and fill up an RGWUserBuckets with them. * Returns: 0 on success, -ERR# on failure. */ -extern int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& buckets, - const string& marker, uint64_t max, bool need_stats); +extern int rgw_read_user_buckets(RGWRados *store, + string user_id, + RGWUserBuckets& buckets, + const string& marker, + uint64_t max, + bool need_stats, + uint64_t default_amount = 1000); extern int rgw_link_bucket(RGWRados *store, string user_id, rgw_bucket& bucket, time_t creation_time, bool update_entrypoint = true); extern int rgw_unlink_bucket(RGWRados *store, string user_id, const string& bucket_name, bool update_entrypoint = true); diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 34335b4dd8f12..d4cc7f00823cf 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1002,7 +1002,7 @@ void RGWListBuckets::execute() read_count = min(limit - total_count, (uint64_t)max_buckets); ret = rgw_read_user_buckets(store, s->user.user_id, buckets, - marker, read_count, should_get_stats()); + marker, read_count, should_get_stats(), 0); if (!started) { send_response_begin(buckets.count() > 0); -- 2.47.3