From: Tianshan Qu Date: Tue, 23 Jul 2019 13:50:15 +0000 (+0800) Subject: rgw: fix list bucket with delimiter wrongly skip some special keys X-Git-Tag: v15.1.0~1860^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc82637f54ab466c7dcd9d452da40ab17f206d4e;p=ceph-ci.git rgw: fix list bucket with delimiter wrongly skip some special keys list with delimiter will skip subfile with directory + after_delim_s, but the code wrongly add after_delim_s to next marker regardless it have directory Fixes: http://tracker.ceph.com/issues/40905 Signed-off-by: Tianshan Qu --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index e0d064045e5..b1436e03bc8 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -2446,15 +2446,6 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p, string skip_after_delim; while (truncated && count <= max) { - if (skip_after_delim > cur_marker.name) { - cur_marker = skip_after_delim; - - ldout(cct, 20) << "setting cur_marker=" - << cur_marker.name - << "[" << cur_marker.instance << "]" - << dendl; - } - ent_map_t ent_map; ent_map.reserve(read_ahead); int r = store->cls_bucket_list_ordered(target->get_bucket_info(), @@ -2538,14 +2529,6 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p, next_marker = prefix_key; (*common_prefixes)[prefix_key] = true; - int marker_delim_pos = cur_marker.name.find( - params.delim, cur_prefix.size()); - - skip_after_delim = cur_marker.name.substr(0, marker_delim_pos); - skip_after_delim.append(after_delim_s); - - ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl; - count++; } @@ -2561,6 +2544,24 @@ int RGWRados::Bucket::List::list_objects_ordered(int64_t max_p, result->emplace_back(std::move(entry)); count++; } + + if (!params.delim.empty()) { + int marker_delim_pos = cur_marker.name.find(params.delim, cur_prefix.size()); + if (marker_delim_pos >= 0) { + skip_after_delim = cur_marker.name.substr(0, marker_delim_pos); + skip_after_delim.append(after_delim_s); + + ldout(cct, 20) << "skip_after_delim=" << skip_after_delim << dendl; + + if (skip_after_delim > cur_marker.name) { + cur_marker = skip_after_delim; + ldout(cct, 20) << "setting cur_marker=" + << cur_marker.name + << "[" << cur_marker.instance << "]" + << dendl; + } + } + } } done: