]> 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)
committerSage Weil <sage@redhat.com>
Sun, 20 Jul 2014 03:51:45 +0000 (20:51 -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 46ed1758eb747dac8bb440b7d2f48545369fa485..7ca4a9da56494acbaafbe87d42591564426c31c2 100644 (file)
@@ -2134,13 +2134,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;
@@ -2163,7 +2163,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;
       }
 
@@ -2180,6 +2180,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;
             }
@@ -2197,6 +2201,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;