rgw: multipart abort if upload meta object doesn't exist

Signed-off-by: fang yuxiang fang.yuxiang@eisoo.com
This commit is contained in:
fang yuxiang 2018-01-11 15:27:25 +08:00
parent 1f32d63e6d
commit e20987c8e3
3 changed files with 16 additions and 12 deletions

View File

@ -3129,9 +3129,8 @@ int RGWPutObjProcessor_Multipart::do_complete(size_t accounted_size,
rgw_raw_obj raw_meta_obj;
store->obj_to_raw(s->bucket_info.placement_rule, meta_obj, &raw_meta_obj);
r = store->omap_set(raw_meta_obj, p, bl);
const bool must_exist = true;// detect races with abort
r = store->omap_set(raw_meta_obj, p, bl, must_exist);
return r;
}

View File

@ -12169,7 +12169,7 @@ int RGWRados::omap_get_all(rgw_raw_obj& obj, bufferlist& header,
return 0;
}
int RGWRados::omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl)
int RGWRados::omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist)
{
rgw_rados_ref ref;
int r = get_raw_obj_ref(obj, &ref);
@ -12180,13 +12180,15 @@ int RGWRados::omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl)
map<string, bufferlist> m;
m[key] = bl;
r = ref.ioctx.omap_set(ref.oid, m);
ObjectWriteOperation op;
if (must_exist)
op.assert_exists();
op.omap_set(m);
r = ref.ioctx.operate(ref.oid, &op);
return r;
}
int RGWRados::omap_set(rgw_raw_obj& obj, std::map<std::string, bufferlist>& m)
int RGWRados::omap_set(rgw_raw_obj& obj, std::map<std::string, bufferlist>& m, bool must_exist)
{
rgw_rados_ref ref;
int r = get_raw_obj_ref(obj, &ref);
@ -12194,8 +12196,11 @@ int RGWRados::omap_set(rgw_raw_obj& obj, std::map<std::string, bufferlist>& m)
return r;
}
r = ref.ioctx.omap_set(ref.oid, m);
ObjectWriteOperation op;
if (must_exist)
op.assert_exists();
op.omap_set(m);
r = ref.ioctx.operate(ref.oid, &op);
return r;
}

View File

@ -3364,8 +3364,8 @@ public:
int omap_get_vals(rgw_raw_obj& obj, bufferlist& header, const std::string& marker, uint64_t count, std::map<string, bufferlist>& m);
int omap_get_all(rgw_raw_obj& obj, bufferlist& header, std::map<string, bufferlist>& m);
int omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl);
int omap_set(rgw_raw_obj& obj, map<std::string, bufferlist>& m);
int omap_set(rgw_raw_obj& obj, const std::string& key, bufferlist& bl, bool must_exist = false);
int omap_set(rgw_raw_obj& obj, map<std::string, bufferlist>& m, bool must_exist = false);
int omap_del(rgw_raw_obj& obj, const std::string& key);
int update_containers_stats(map<string, RGWBucketEnt>& m);
int append_async(rgw_raw_obj& obj, size_t size, bufferlist& bl);