mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
Merge pull request #4351 from ceph/wip-11256
Wip 11256 Reviewed-by: Josh Durgin <jdurgin@redhat.com>
This commit is contained in:
commit
3819055c75
@ -657,10 +657,11 @@ int rgw_bucket_prepare_op(cls_method_context_t hctx, bufferlist *in, bufferlist
|
||||
}
|
||||
|
||||
// fill in proper state
|
||||
struct rgw_bucket_pending_info& info = entry.pending_map[op.tag];
|
||||
struct rgw_bucket_pending_info info;
|
||||
info.timestamp = ceph_clock_now(g_ceph_context);
|
||||
info.state = CLS_RGW_STATE_PENDING_MODIFY;
|
||||
info.op = op.op;
|
||||
entry.pending_map.insert(pair<string, rgw_bucket_pending_info>(op.tag, info));
|
||||
|
||||
struct rgw_bucket_dir_header header;
|
||||
rc = read_bucket_header(hctx, &header);
|
||||
|
@ -268,7 +268,7 @@ struct rgw_bucket_dir_entry {
|
||||
std::string locator;
|
||||
bool exists;
|
||||
struct rgw_bucket_dir_entry_meta meta;
|
||||
map<string, struct rgw_bucket_pending_info> pending_map;
|
||||
multimap<string, struct rgw_bucket_pending_info> pending_map;
|
||||
uint64_t index_ver;
|
||||
string tag;
|
||||
uint16_t flags;
|
||||
|
@ -185,6 +185,23 @@ void decode_json_obj(map<K, V>& m, JSONObj *obj)
|
||||
}
|
||||
}
|
||||
|
||||
template<class K, class V>
|
||||
void decode_json_obj(multimap<K, V>& m, JSONObj *obj)
|
||||
{
|
||||
m.clear();
|
||||
|
||||
JSONObjIter iter = obj->find_first();
|
||||
|
||||
for (; !iter.end(); ++iter) {
|
||||
K key;
|
||||
V val;
|
||||
JSONObj *o = *iter;
|
||||
JSONDecoder::decode_json("key", key, o);
|
||||
JSONDecoder::decode_json("val", val, o);
|
||||
m.insert(make_pair<K, V>(key, val));
|
||||
}
|
||||
}
|
||||
|
||||
template<class C>
|
||||
void decode_json_obj(C& container, void (*cb)(C&, JSONObj *obj), JSONObj *obj)
|
||||
{
|
||||
@ -302,6 +319,18 @@ static void encode_json(const char *name, const std::map<K, V>& m, ceph::Formatt
|
||||
f->close_section();
|
||||
}
|
||||
|
||||
template<class K, class V>
|
||||
static void encode_json(const char *name, const std::multimap<K, V>& m, ceph::Formatter *f)
|
||||
{
|
||||
f->open_array_section(name);
|
||||
for (typename std::multimap<K, V>::const_iterator i = m.begin(); i != m.end(); ++i) {
|
||||
f->open_object_section("entry");
|
||||
encode_json("key", i->first, f);
|
||||
encode_json("val", i->second, f);
|
||||
f->close_section();
|
||||
}
|
||||
f->close_section();
|
||||
}
|
||||
template<class T>
|
||||
static void encode_json(const char *name, const std::list<T>& l, ceph::Formatter *f)
|
||||
{
|
||||
|
@ -4902,13 +4902,22 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
|
||||
if (!op.size())
|
||||
return 0;
|
||||
|
||||
bufferlist bl;
|
||||
RGWRados::Bucket bop(this, bucket);
|
||||
RGWRados::Bucket::UpdateIndex index_op(&bop, obj, state);
|
||||
|
||||
if (state) {
|
||||
string tag;
|
||||
append_rand_alpha(cct, tag, tag, 32);
|
||||
state->write_tag = tag;
|
||||
r = index_op.prepare(CLS_RGW_OP_ADD);
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
bl.append(tag.c_str(), tag.size() + 1);
|
||||
|
||||
op.setxattr(RGW_ATTR_ID_TAG, bl);
|
||||
}
|
||||
|
||||
r = ref.ioctx.operate(ref.oid, &op);
|
||||
@ -4936,6 +4945,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
|
||||
return r;
|
||||
|
||||
if (state) {
|
||||
state->obj_tag.swap(bl);
|
||||
if (rmattrs) {
|
||||
for (iter = rmattrs->begin(); iter != rmattrs->end(); ++iter) {
|
||||
state->attrset.erase(iter->first);
|
||||
|
Loading…
Reference in New Issue
Block a user