From 6df17a92283da9933bf5a3fca1278b728c79b8ee Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 17 Jul 2014 15:48:26 -0700 Subject: [PATCH] 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 (cherry picked from commit dc417e477d4ad262885c6b5f5987cf06d63b159d) --- src/rgw/rgw_rados.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 3c0fef32021d0..3948be8707f72 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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 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; -- 2.39.5