From: Yehuda Sadeh Date: Tue, 4 Feb 2014 18:34:02 +0000 (-0800) Subject: rgw: fix rgw_read_user_buckets() use of max param X-Git-Tag: v0.77~9^2~4^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=04b1ae466e280568656f8effb031b01505077c6b;p=ceph.git rgw: fix rgw_read_user_buckets() use of max param Fixes: #7336 The rgw_read_user_buckets() treated the max param as the max number of entries to request in a single op, but always fetched the entire list of buckets. This is wrong, as it should have treated it as the total number of entries requested. All the callers assume the latter. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 81554085766e..6394e5f0ce99 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -54,8 +54,10 @@ int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& bucke bool truncated; string m = marker; + uint64_t total = 0; + do { - ret = store->cls_user_list_buckets(obj, m, max, entries, &m, &truncated); + ret = store->cls_user_list_buckets(obj, m, max - total, entries, &m, &truncated); if (ret == -ENOENT) ret = 0; @@ -65,8 +67,10 @@ int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& bucke for (list::iterator q = entries.begin(); q != entries.end(); ++q) { RGWBucketEnt e(*q); buckets.add(e); + total++; } - } while (truncated); + + } while (truncated && total < max); if (need_stats) { map& m = buckets.get_buckets();