]> git.apps.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>
Fri, 18 Jul 2014 21:56:24 +0000 (14:56 -0700)
Otherwise we end up returning wrong truncated value, and no data on the
next iteration.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_rados.cc

index 383976557f6e3b5f1f3945face94c840d0f7ab2b..4981db5fc5b762e0318fa022f5d4b3ab526e6df7 100644 (file)
@@ -2299,13 +2299,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;
@@ -2328,7 +2328,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;
       }
 
@@ -2345,6 +2345,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;
             }
@@ -2362,6 +2366,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;