From b429fa1807062716c9705ddcf316ed9b2741cc43 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Fri, 5 May 2017 14:56:40 -0400 Subject: [PATCH] cls/rgw: list_plain_entries() stops before bi_log entries list_plain_entries() was using encode_obj_versioned_data_key() to set its end_key, which gives a prefix of BI_BUCKET_OBJ_INSTANCE_INDEX[=2] that range between start_key and end_key would not only span the BI_BUCKET_OBJS_INDEX[=0] prefixes, but BI_BUCKET_LOG_INDEX[=1] prefixes as well. this can result in list_plain_entries() trying and failing to decode a rgw_bi_log_entry as a rgw_bucket_dir_entry Fixes: http://tracker.ceph.com/issues/19876 Signed-off-by: Casey Bodley (cherry picked from commit b29a1633a57abf443d5790c13d680d2917f86037) --- src/cls/rgw/cls_rgw.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index 58247b54ee3f0..86dcc66b58035 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -124,11 +124,15 @@ static void get_index_ver_key(cls_method_context_t hctx, uint64_t index_ver, str *key = buf; } -static void bi_log_index_key(cls_method_context_t hctx, string& key, string& id, uint64_t index_ver) +static void bi_log_prefix(string& key) { key = BI_PREFIX_CHAR; key.append(bucket_index_prefixes[BI_BUCKET_LOG_INDEX]); +} +static void bi_log_index_key(cls_method_context_t hctx, string& key, string& id, uint64_t index_ver) +{ + bi_log_prefix(key); get_index_ver_key(hctx, index_ver, &id); key.append(id); } @@ -2286,9 +2290,8 @@ static int list_plain_entries(cls_method_context_t hctx, const string& name, con string filter = name; string start_key = marker; - string first_instance_idx; - encode_obj_versioned_data_key(string(), &first_instance_idx); - string end_key = first_instance_idx; + string end_key; // stop listing at bi_log_prefix + bi_log_prefix(end_key); int count = 0; map keys; @@ -2536,7 +2539,7 @@ static int rgw_bi_list_op(cls_method_context_t hctx, bufferlist *in, bufferlist ret = list_olh_entries(hctx, op.name, op.marker, max - count, &op_ret.entries); if (ret < 0) { - CLS_LOG(0, "ERROR: %s(): list_instance_entries retured ret=%d", __func__, ret); + CLS_LOG(0, "ERROR: %s(): list_olh_entries retured ret=%d", __func__, ret); return ret; } -- 2.39.5