mirror of
https://github.com/ceph/ceph
synced 2025-01-20 10:01:45 +00:00
rgw: copy_obj uses req_id as tag
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
This commit is contained in:
parent
b295c64959
commit
4b142a1207
@ -651,6 +651,8 @@ struct req_state {
|
||||
|
||||
string dialect;
|
||||
|
||||
string req_id;
|
||||
|
||||
req_state(CephContext *_cct, struct RGWEnv *e);
|
||||
~req_state();
|
||||
};
|
||||
|
@ -295,6 +295,8 @@ void RGWProcess::handle_request(RGWRequest *req)
|
||||
s->obj_ctx = store->create_context(s);
|
||||
store->set_intent_cb(s->obj_ctx, call_log_intent);
|
||||
|
||||
s->req_id = store->unique_id(req->id);
|
||||
|
||||
req->log(s, "initializing");
|
||||
|
||||
RGWOp *op = NULL;
|
||||
|
@ -1217,6 +1217,7 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, map<string, bufferlist>
|
||||
|
||||
extra_params.data = &first_chunk;
|
||||
extra_params.manifest = &manifest;
|
||||
extra_params.ptag = &s->req_id; /* use req_id as operation tag */
|
||||
|
||||
int r = store->put_obj_meta(s->obj_ctx, head_obj, obj_len, attrs,
|
||||
RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE,
|
||||
@ -1764,7 +1765,9 @@ void RGWCopyObj::execute()
|
||||
if_match,
|
||||
if_nomatch,
|
||||
replace_attrs,
|
||||
attrs, RGW_OBJ_CATEGORY_MAIN, &s->err);
|
||||
attrs, RGW_OBJ_CATEGORY_MAIN,
|
||||
&s->req_id, /* use req_id as tag */
|
||||
&s->err);
|
||||
}
|
||||
|
||||
int RGWGetACLs::verify_permission()
|
||||
@ -2300,6 +2303,8 @@ void RGWCompleteMultipart::execute()
|
||||
extra_params.manifest = &manifest;
|
||||
extra_params.remove_objs = &remove_objs;
|
||||
|
||||
extra_params.ptag = &s->req_id; /* use req_id as operation tag */
|
||||
|
||||
ret = store->put_obj_meta(s->obj_ctx, target_obj, ofs, attrs,
|
||||
RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE,
|
||||
extra_params);
|
||||
|
@ -1728,6 +1728,7 @@ int RGWRados::copy_obj(void *ctx,
|
||||
bool replace_attrs,
|
||||
map<string, bufferlist>& attrs,
|
||||
RGWObjCategory category,
|
||||
string *ptag,
|
||||
struct rgw_err *err)
|
||||
{
|
||||
int ret;
|
||||
@ -1789,7 +1790,7 @@ int RGWRados::copy_obj(void *ctx,
|
||||
}
|
||||
|
||||
if (copy_data) { /* refcounting tail wouldn't work here, just copy the data */
|
||||
return copy_obj_data(ctx, handle, end, dest_obj, src_obj, mtime, attrset, category, err);
|
||||
return copy_obj_data(ctx, handle, end, dest_obj, src_obj, mtime, attrset, category, ptag, err);
|
||||
}
|
||||
|
||||
map<uint64_t, RGWObjManifestPart>::iterator miter = astate->manifest.objs.begin();
|
||||
@ -1810,14 +1811,21 @@ int RGWRados::copy_obj(void *ctx,
|
||||
|
||||
bufferlist first_chunk;
|
||||
|
||||
string tag;
|
||||
bool copy_itself = (dest_obj == src_obj);
|
||||
RGWObjManifest *pmanifest;
|
||||
ldout(cct, 0) << "dest_obj=" << dest_obj << " src_obj=" << src_obj << " copy_itself=" << (int)copy_itself << dendl;
|
||||
|
||||
if (!copy_itself) {
|
||||
append_rand_alpha(cct, tag, tag, 32);
|
||||
|
||||
string tag;
|
||||
|
||||
if (ptag)
|
||||
tag = *ptag;
|
||||
|
||||
if (tag.empty()) {
|
||||
append_rand_alpha(cct, tag, tag, 32);
|
||||
}
|
||||
|
||||
if (!copy_itself) {
|
||||
for (; miter != astate->manifest.objs.end(); ++miter) {
|
||||
RGWObjManifestPart& part = miter->second;
|
||||
ObjectWriteOperation op;
|
||||
@ -1838,8 +1846,6 @@ int RGWRados::copy_obj(void *ctx,
|
||||
pmanifest = &manifest;
|
||||
} else {
|
||||
pmanifest = &astate->manifest;
|
||||
tag = astate->obj_tag.c_str();
|
||||
|
||||
/* don't send the object's tail for garbage collection */
|
||||
astate->keep_tail = true;
|
||||
}
|
||||
@ -1895,11 +1901,13 @@ int RGWRados::copy_obj_data(void *ctx,
|
||||
time_t *mtime,
|
||||
map<string, bufferlist>& attrs,
|
||||
RGWObjCategory category,
|
||||
string *ptag,
|
||||
struct rgw_err *err)
|
||||
{
|
||||
bufferlist first_chunk;
|
||||
RGWObjManifest manifest;
|
||||
RGWObjManifestPart *first_part;
|
||||
map<string, bufferlist>::iterator iter;
|
||||
|
||||
rgw_obj shadow_obj = dest_obj;
|
||||
string shadow_oid;
|
||||
@ -1954,6 +1962,7 @@ int RGWRados::copy_obj_data(void *ctx,
|
||||
|
||||
ep.data = &first_chunk;
|
||||
ep.manifest = &manifest;
|
||||
ep.ptag = ptag;
|
||||
|
||||
ret = put_obj_meta(ctx, dest_obj, end + 1, attrs, category, PUT_OBJ_CREATE, ep);
|
||||
if (mtime)
|
||||
@ -2861,7 +2870,9 @@ int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
|
||||
buf[len] = '\0';
|
||||
tag = buf;
|
||||
} else {
|
||||
append_rand_alpha(cct, tag, tag, 32);
|
||||
if (tag.empty()) {
|
||||
append_rand_alpha(cct, tag, tag, 32);
|
||||
}
|
||||
}
|
||||
int ret = cls_obj_prepare_op(bucket, CLS_RGW_OP_ADD, tag,
|
||||
obj.object, obj.key);
|
||||
|
@ -782,6 +782,7 @@ public:
|
||||
bool replace_attrs,
|
||||
map<std::string, bufferlist>& attrs,
|
||||
RGWObjCategory category,
|
||||
string *ptag,
|
||||
struct rgw_err *err);
|
||||
|
||||
int copy_obj_data(void *ctx,
|
||||
@ -791,6 +792,7 @@ public:
|
||||
time_t *mtime,
|
||||
map<string, bufferlist>& attrs,
|
||||
RGWObjCategory category,
|
||||
string *ptag,
|
||||
struct rgw_err *err);
|
||||
/**
|
||||
* Delete a bucket.
|
||||
@ -1002,6 +1004,13 @@ public:
|
||||
int bucket_rebuild_index(rgw_bucket& bucket);
|
||||
int remove_objs_from_index(rgw_bucket& bucket, list<string>& oid_list);
|
||||
|
||||
string unique_id(uint64_t unique_num) {
|
||||
char buf[32];
|
||||
snprintf(buf, sizeof(buf), ".%llu.%llu", (unsigned long long)instance_id(), (unsigned long long)unique_num);
|
||||
string s = zone.name + buf;
|
||||
return s;
|
||||
}
|
||||
|
||||
private:
|
||||
int process_intent_log(rgw_bucket& bucket, string& oid,
|
||||
time_t epoch, int flags, bool purge);
|
||||
@ -1050,7 +1059,6 @@ public:
|
||||
|
||||
uint64_t instance_id();
|
||||
uint64_t next_bucket_id();
|
||||
|
||||
};
|
||||
|
||||
class RGWStoreManager {
|
||||
|
Loading…
Reference in New Issue
Block a user