olh.update(next_key, next.is_delete_marker());
olh.update_log(CLS_RGW_OLH_OP_LINK_OLH, op.op_tag, next_key, next.is_delete_marker());
} else {
- /* next_key is empty */
+ // next_key is empty, but we need to preserve its name in case this entry
+ // gets resharded, because this key is used for hash placement
+ next_key.name = dest_key.name;
olh.update(next_key, false);
olh.update_log(CLS_RGW_OLH_OP_UNLINK_OLH, op.op_tag, next_key, false);
olh.set_exists(false);
return -EINVAL;
}
- rgw_lc_entry_t lc_entry;
+ cls_rgw_lc_entry lc_entry;
int ret = read_omap_entry(hctx, op.marker, &lc_entry);
if (ret < 0)
return ret;
bufferlist bl;
encode(op.entry, bl);
- int ret = cls_cxx_map_set_val(hctx, op.entry.first, &bl);
+ int ret = cls_cxx_map_set_val(hctx, op.entry.bucket, &bl);
return ret;
}
return -EINVAL;
}
- int ret = cls_cxx_map_remove_key(hctx, op.entry.first);
+ int ret = cls_cxx_map_remove_key(hctx, op.entry.bucket);
return ret;
}
if (ret < 0)
return ret;
map<string, bufferlist>::iterator it;
- pair<string, int> entry;
+ cls_rgw_lc_entry entry;
if (!vals.empty()) {
it=vals.begin();
in_iter = it->second.begin();
return 0;
}
-static int rgw_cls_lc_list_entries(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
+static int rgw_cls_lc_list_entries(cls_method_context_t hctx, bufferlist *in,
+ bufferlist *out)
{
cls_rgw_lc_list_entries_op op;
auto in_iter = in->cbegin();
return -EINVAL;
}
- cls_rgw_lc_list_entries_ret op_ret;
+ cls_rgw_lc_list_entries_ret op_ret(op.compat_v);
bufferlist::const_iterator iter;
map<string, bufferlist> vals;
string filter_prefix;
- int ret = cls_cxx_map_get_vals(hctx, op.marker, filter_prefix, op.max_entries, &vals, &op_ret.is_truncated);
+ int ret = cls_cxx_map_get_vals(hctx, op.marker, filter_prefix, op.max_entries,
+ &vals, &op_ret.is_truncated);
if (ret < 0)
return ret;
map<string, bufferlist>::iterator it;
- pair<string, int> entry;
- for (it = vals.begin(); it != vals.end(); ++it) {
+ for (auto it = vals.begin(); it != vals.end(); ++it) {
+ cls_rgw_lc_entry entry;
iter = it->second.cbegin();
try {
- decode(entry, iter);
+ decode(entry, iter);
} catch (buffer::error& err) {
- CLS_LOG(1, "ERROR: rgw_cls_lc_list_entries(): failed to decode entry\n");
- return -EIO;
- }
- op_ret.entries.insert(entry);
+ /* try backward compat */
+ pair<string, int> oe;
+ try {
+ iter = it->second.begin();
+ decode(oe, iter);
+ entry = {oe.first, 0 /* start */, uint32_t(oe.second)};
+ } catch(buffer::error& err) {
+ CLS_LOG(
+ 1, "ERROR: rgw_cls_lc_list_entries(): failed to decode entry\n");
+ return -EIO;
+ }
+ }
+ op_ret.entries.push_back(entry);
}
encode(op_ret, *out);
return 0;