Skip to content

Commit 23609f6

Browse files
authored
Merge pull request ceph#62235 from cbodley/wip-70399
cls/rgw: non-versioned listings skip past version suffix Reviewed-by: J. Eric Ivancich <[email protected]>
2 parents 5402b3a + 90902ce commit 23609f6

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/cls/rgw/cls_rgw.cc

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,14 @@ static void get_list_index_key(rgw_bucket_dir_entry& entry, string *index_key)
364364
index_key->append(entry.key.instance);
365365
}
366366

367+
// Format an omap key for an object name that sorts after all versioned keys
368+
// generated by get_list_index_key().
369+
static std::string cls_rgw_after_versions(const std::string& key)
370+
{
371+
// assert: ! key.empty()
372+
return key + '\1'; // suffix "\1" sorts after suffixes like "\0v123\0iabc"
373+
}
374+
367375
static void encode_obj_versioned_data_key(const cls_rgw_obj_key& key, string *index_key, bool append_delete_marker_suffix = false)
368376
{
369377
*index_key = BI_PREFIX_CHAR;
@@ -528,8 +536,6 @@ static int read_bucket_header(cls_method_context_t hctx,
528536

529537
int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
530538
{
531-
CLS_LOG(10, "entered %s", __func__);
532-
533539
// maximum number of calls to get_obj_vals we'll try; compromise
534540
// between wanting to return the requested # of entries, but not
535541
// wanting to slow down this op with too many omap reads
@@ -545,6 +551,10 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
545551
return -EINVAL;
546552
}
547553

554+
CLS_LOG(10, "entered %s start=%s count=%u prefix=%s delim=%s versioned=%d",
555+
__func__, op.start_obj.to_string().c_str(), op.num_entries,
556+
op.filter_prefix.c_str(), op.delimiter.c_str(), (int)op.list_versions);
557+
548558
rgw_cls_list_ret ret;
549559
rgw_bucket_dir& new_dir = ret.dir;
550560
auto& name_entry_map = new_dir.m; // map of keys to entries
@@ -652,6 +662,13 @@ int rgw_bucket_list(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
652662
(!entry.is_visible() || op.start_obj.name == key.name)) {
653663
CLS_LOG(20, "%s: entry %s[%s] is not visible",
654664
__func__, key.name.c_str(), key.instance.c_str());
665+
666+
// advance past any versioned entries for this name
667+
start_after_omap_key = cls_rgw_after_versions(key.name);
668+
start_after_entry_key.set(start_after_omap_key);
669+
670+
kiter = keys.lower_bound(start_after_omap_key);
671+
--kiter;
655672
continue;
656673
}
657674

src/rgw/driver/rados/rgw_rados.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1862,7 +1862,7 @@ int RGWRados::Bucket::List::list_objects_ordered(
18621862
ldpp_dout(dpp, 20) << __func__ <<
18631863
": starting attempt " << attempt << dendl;
18641864

1865-
if (attempt > 1 && !(prev_marker < cur_marker)) {
1865+
if (attempt > 1 && prev_marker == cur_marker) {
18661866
// we've failed to make forward progress
18671867
ldpp_dout(dpp, 0) << "ERROR: " << __func__ <<
18681868
" marker failed to make forward progress; attempt=" << attempt <<

0 commit comments

Comments
 (0)