diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-16 16:58:31 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-16 16:58:31 -0700 |
commit | dc6d6c3da68e46a358dc09ce26e2ae4616d472fc (patch) | |
tree | e74027c66822e136f02b5be4980db5535f50ea3a | |
parent | dcfbf691ed84ad87bb5a5bb1f744c0151f6bd9f5 (diff) | |
download | ceph-dc6d6c3da68e46a358dc09ce26e2ae4616d472fc.tar.gz |
rgw: copy_obj uses req_id as tag
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_common.h | 2 | ||||
-rw-r--r-- | src/rgw/rgw_main.cc | 2 | ||||
-rw-r--r-- | src/rgw/rgw_op.cc | 7 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 22 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 10 |
5 files changed, 36 insertions, 7 deletions
diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 026185e0804..9ecda6a9fae 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -648,6 +648,8 @@ struct req_state { string dialect; + string req_id; + req_state(CephContext *_cct, struct RGWEnv *e); ~req_state(); }; diff --git a/src/rgw/rgw_main.cc b/src/rgw/rgw_main.cc index c80037520b3..66cfc73c3d8 100644 --- a/src/rgw/rgw_main.cc +++ b/src/rgw/rgw_main.cc @@ -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; diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index fea703684d4..ed140b8f5b3 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1181,6 +1181,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, @@ -1728,7 +1729,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() @@ -2264,6 +2267,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); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 62c29430295..2d7c9956ed4 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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) { + + 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,7 +1846,6 @@ int RGWRados::copy_obj(void *ctx, pmanifest = &manifest; } else { pmanifest = &astate->manifest; - tag = astate->obj_tag.c_str(); } if (copy_first) { @@ -1892,11 +1899,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; @@ -1951,6 +1960,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) @@ -2858,7 +2868,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); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 6de7ddd675e..b12e58a2901 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -781,6 +781,7 @@ public: bool replace_attrs, map<std::string, bufferlist>& attrs, RGWObjCategory category, + string *ptag, struct rgw_err *err); int copy_obj_data(void *ctx, @@ -790,6 +791,7 @@ public: time_t *mtime, map<string, bufferlist>& attrs, RGWObjCategory category, + string *ptag, struct rgw_err *err); /** * Delete a bucket. @@ -1000,6 +1002,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); @@ -1048,7 +1057,6 @@ public: uint64_t instance_id(); uint64_t next_bucket_id(); - }; class RGWStoreManager { |