From: Radoslaw Zarzynski Date: Tue, 31 Mar 2015 10:41:11 +0000 (+0200) Subject: rgw: make rgw_read_user_buckets() backward compatible. X-Git-Tag: v9.0.1~106^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7dd54fa3621c04c8ea5723fb1bc06b91d81a0c6c;p=ceph.git rgw: make rgw_read_user_buckets() backward compatible. Fixes: #10683 Backport: hammer Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 5d2af38ea6fb..c3aab8e86aed 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 830e096c9877..222e152b10ff 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 34335b4dd8f1..d4cc7f00823c 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);