]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix rgw_read_user_buckets() use of max param 1183/head
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 4 Feb 2014 18:34:02 +0000 (10:34 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 4 Feb 2014 18:37:11 +0000 (10:37 -0800)
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 <yehuda@inktank.com>
src/rgw/rgw_bucket.cc

index 81554085766e92abf79154e081fb3db5195797bd..6394e5f0ce995fca6d0188357d4c055b2870de87 100644 (file)
@@ -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<cls_user_bucket_entry>::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<string, RGWBucketEnt>& m = buckets.get_buckets();