]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: list extra objects to set truncation flag correctly
authorYehuda Sadeh <yehuda@inktank.com>
Thu, 17 Jul 2014 22:48:26 +0000 (15:48 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Tue, 29 Jul 2014 17:41:36 +0000 (10:41 -0700)
Otherwise we end up returning wrong truncated value, and no data on the
next iteration.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
(cherry picked from commit dc417e477d4ad262885c6b5f5987cf06d63b159d)

src/rgw/rgw_rados.cc

index 3c0fef32021d0c40f12f33ade6005e880310ca39..3948be8707f723663a17ade5eb16d1d6216dc068 100644 (file)
@@ -1762,13 +1762,13 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
     }
   }
 
-  while (truncated && count < max) {
+  while (truncated && count <= max) {
     if (skip_after_delim > cur_marker) {
       cur_marker = skip_after_delim;
       ldout(cct, 20) << "setting cur_marker=" << cur_marker << dendl;
     }
     std::map<string, RGWObjEnt> ent_map;
-    int r = cls_bucket_list(bucket, cur_marker, cur_prefix, max - count, ent_map,
+    int r = cls_bucket_list(bucket, cur_marker, cur_prefix, max + 1 - count, ent_map,
                             &truncated, &cur_marker);
     if (r < 0)
       return r;
@@ -1791,7 +1791,7 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
         continue;
       }
 
-      if (next_marker) {
+      if (next_marker && count < max) {
         *next_marker = obj;
       }
 
@@ -1808,6 +1808,10 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
           string prefix_key = obj.substr(0, delim_pos + 1);
 
           if (common_prefixes.find(prefix_key) == common_prefixes.end()) {
+            if (count >= max) {
+              truncated = true;
+              goto done;
+            }
             if (next_marker) {
               *next_marker = prefix_key;
             }
@@ -1825,6 +1829,11 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
         }
       }
 
+      if (count >= max) {
+        truncated = true;
+        goto done;
+      }
+
       RGWObjEnt ent = eiter->second;
       ent.name = obj;
       ent.ns = ns;