From: Yehuda Sadeh Date: Thu, 17 Jul 2014 22:48:26 +0000 (-0700) Subject: rgw: list extra objects to set truncation flag correctly X-Git-Tag: v0.84~74^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dc417e477d4ad262885c6b5f5987cf06d63b159d;p=ceph.git rgw: list extra objects to set truncation flag correctly Otherwise we end up returning wrong truncated value, and no data on the next iteration. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 383976557f6e..4981db5fc5b7 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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 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;