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 <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2017-05-05 14:56:40 -04:00
parent 9667761ecf
commit b29a1633a5

View File

@ -95,11 +95,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);
}
@ -2257,9 +2261,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<string, bufferlist> keys;
@ -2507,7 +2510,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;
}