From: Mykola Golub Date: Thu, 22 Apr 2021 06:14:25 +0000 (+0100) Subject: cls/rgw: look for plane entries in non-ascii plain namespace too X-Git-Tag: v15.2.14~38^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6c2749ccc0ce461614fa79d9c6561622053e57b4;p=ceph.git cls/rgw: look for plane entries in non-ascii plain namespace too Fixes: https://tracker.ceph.com/issues/50415 Signed-off-by: Mykola Golub (cherry picked from commit 7cf30e943276ff66f0eff9f0c088c597b1f9e066) Conflicts: src/cls/rgw/cls_rgw.cc (trivial) --- diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 84e536af0a0..30262f427c9 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -42,6 +42,9 @@ static std::string bucket_index_prefixes[] = { "", /* special handling for the o /* this must be the last index */ "9999_",}; +static const std::string BI_PREFIX_END = string(1, BI_PREFIX_CHAR) + + bucket_index_prefixes[BI_BUCKET_LAST_INDEX]; + static bool bi_is_objs_index(const string& s) { return ((unsigned char)s[0] != BI_PREFIX_CHAR); } @@ -2424,18 +2427,14 @@ static int rgw_bi_put_op(cls_method_context_t hctx, bufferlist *in, bufferlist * } static int list_plain_entries(cls_method_context_t hctx, - const string& name, - const string& marker, - uint32_t max, + const string& filter, + const string& start_after_key, + const string& end_key, + uint32_t max, list *entries, - bool *pmore) + bool *end_key_reached, + bool *pmore) { - string filter = name; - string start_after_key = marker; - - string end_key; // stop listing at bi_log_prefix - bi_log_prefix(end_key); - int count = 0; map keys; int ret = cls_cxx_map_get_vals(hctx, start_after_key, filter, max, @@ -2444,13 +2443,12 @@ static int list_plain_entries(cls_method_context_t hctx, return ret; } - map::iterator iter; - for (iter = keys.begin(); iter != keys.end(); ++iter) { - if (iter->first >= end_key) { - /* past the end of plain namespace */ - if (pmore) { - *pmore = false; - } + *end_key_reached = false; + + for (auto iter = keys.begin(); iter != keys.end(); ++iter) { + if (!end_key.empty() && iter->first >= end_key) { + *end_key_reached = true; + *pmore = true; return count; } @@ -2469,13 +2467,12 @@ static int list_plain_entries(cls_method_context_t hctx, return -EIO; } - CLS_LOG(20, "%s(): entry.idx=%s e.key.name=%s", __func__, escape_str(entry.idx).c_str(), escape_str(e.key.name).c_str()); + CLS_LOG(20, "%s(): entry.idx=%s e.key.name=%s", __func__, + escape_str(entry.idx).c_str(), escape_str(e.key.name).c_str()); - if (!name.empty() && e.key.name != name) { + if (!filter.empty() && e.key.name != filter) { /* we are skipping the rest of the entries */ - if (pmore) { - *pmore = false; - } + *pmore = false; return count; } @@ -2484,12 +2481,54 @@ static int list_plain_entries(cls_method_context_t hctx, if (count >= (int)max) { return count; } - start_after_key = entry.idx; } return count; } +static int list_plain_entries(cls_method_context_t hctx, + const string& name, + const string& marker, + uint32_t max, + list *entries, + bool *pmore) { + string start_after_key = marker; + string end_key; + bi_log_prefix(end_key); + int r; + bool end_key_reached; + bool more; + + if (start_after_key < end_key) { + // listing ascii plain namespace + int r = list_plain_entries(hctx, name, start_after_key, end_key, max, + entries, &end_key_reached, &more); + if (r < 0) { + return r; + } + if (r >= (int)max || !end_key_reached || !more) { + if (pmore) { + *pmore = more; + } + return r; + } + start_after_key = BI_PREFIX_END; + max = max - r; + } + + // listing non-ascii plain namespace + r = list_plain_entries(hctx, name, start_after_key, {}, max, entries, + &end_key_reached, &more); + if (r < 0) { + return r; + } + if (pmore) { + *pmore = more; + } + + return r; +} + static int list_instance_entries(cls_method_context_t hctx, const string& name, const string& marker,