From 04b1ae466e280568656f8effb031b01505077c6b Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 4 Feb 2014 10:34:02 -0800 Subject: [PATCH] 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 --- src/rgw/rgw_bucket.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 81554085766..6394e5f0ce9 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(); -- 2.47.3