diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-04-15 12:32:48 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-05-08 10:57:46 -0700 |
commit | 7e08c57d2584031fc04d11666ba8d715e7663ffe (patch) | |
tree | 0dbc5c404ffbea627b138bcca973e6fc9e42d22b | |
parent | 2a16bafdd96207c3bc95582158fd909d6bfb0477 (diff) | |
download | ceph-7e08c57d2584031fc04d11666ba8d715e7663ffe.tar.gz |
rgw: share object tag and index tag
object tag is now being written to the index, so that both
object and index hold the same tag. This is needed so that we
could know whether object and index refer to the same instance.
Also cleanup old legacy code that did atomic ops through cloning
objects.
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/rgw/rgw_op.cc | 6 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 57 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 1 |
3 files changed, 12 insertions, 52 deletions
diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 02d2dc4fb97..9888ee0fc50 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -1301,11 +1301,7 @@ RGWPutObjProcessor *RGWPutObj::select_processor() uint64_t part_size = s->cct->_conf->rgw_obj_stripe_size; if (!multipart) { - if (s->content_length <= RGW_MAX_CHUNK_SIZE && !chunked_upload) { - processor = new RGWPutObjProcessor_Plain(); - } else { - processor = new RGWPutObjProcessor_Atomic(part_size); - } + processor = new RGWPutObjProcessor_Atomic(part_size); } else { processor = new RGWPutObjProcessor_Multipart(part_size); } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 60ad5e481ea..f2821f25723 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -58,7 +58,6 @@ static string default_region_info_oid = "default.region"; static string region_map_oid = "region_map"; -static RGWObjCategory shadow_category = RGW_OBJ_CATEGORY_SHADOW; static RGWObjCategory main_category = RGW_OBJ_CATEGORY_MAIN; #define RGW_USAGE_OBJ_PREFIX "usage." @@ -1590,6 +1589,11 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj, uint64_t size, uint64_t epoch; int64_t poolid; utime_t ut; + + if (state) { + index_tag = state->write_tag; + } + r = prepare_update_index(NULL, bucket, obj, index_tag); if (r < 0) return r; @@ -2492,46 +2496,6 @@ int RGWRados::prepare_atomic_for_write_impl(RGWRadosCtx *rctx, rgw_obj& obj, return 0; } - if (state->obj_tag.length() == 0 || - state->shadow_obj.size() == 0) { - ldout(cct, 10) << "can't clone object " << obj << " to shadow object, tag/shadow_obj haven't been set" << dendl; - // FIXME: need to test object does not exist - } else if (state->has_manifest) { - ldout(cct, 10) << "obj contains manifest" << dendl; - } else if (state->size <= RGW_MAX_CHUNK_SIZE) { - ldout(cct, 10) << "not cloning object, object size (" << state->size << ")" << " <= chunk size" << dendl; - } else { - ldout(cct, 10) << "cloning object " << obj << " to name=" << state->shadow_obj << dendl; - rgw_obj dest_obj(obj.bucket, state->shadow_obj); - dest_obj.set_ns(shadow_ns); - if (obj.key.size()) - dest_obj.set_key(obj.key); - else - dest_obj.set_key(obj.object); - - pair<string, bufferlist> cond(RGW_ATTR_ID_TAG, state->obj_tag); - ldout(cct, 10) << "cloning: dest_obj=" << dest_obj << " size=" << state->size << " tag=" << state->obj_tag.c_str() << dendl; - r = clone_obj_cond(NULL, dest_obj, 0, obj, 0, state->size, state->attrset, shadow_category, &state->mtime, false, true, &cond); - if (r == -EEXIST) - r = 0; - if (r == -ECANCELED) { - /* we lost in a race here, original object was replaced, we assume it was cloned - as required */ - ldout(cct, 5) << "clone_obj_cond was cancelled, lost in a race" << dendl; - state->clear(); - return r; - } else { - int ret = rctx->notify_intent(this, dest_obj, DEL_OBJ); - if (ret < 0) { - ldout(cct, 0) << "WARNING: failed to log intent ret=" << ret << dendl; - } - } - if (r < 0) { - ldout(cct, 0) << "ERROR: failed to clone object r=" << r << dendl; - return r; - } - } - if (need_guard) { /* first verify that the object wasn't replaced under */ op.cmpxattr(RGW_ATTR_ID_TAG, LIBRADOS_CMPXATTR_OP_EQ, state->obj_tag); @@ -2543,22 +2507,21 @@ int RGWRados::prepare_atomic_for_write_impl(RGWRadosCtx *rctx, rgw_obj& obj, op.remove(); } - string tag; if (ptag) { - tag = *ptag; + state->write_tag = *ptag; } else { - append_rand_alpha(cct, tag, tag, 32); + append_rand_alpha(cct, state->write_tag, state->write_tag, 32); } bufferlist bl; - bl.append(tag.c_str(), tag.size() + 1); + bl.append(state->write_tag.c_str(), state->write_tag.size() + 1); - ldout(cct, 0) << "setting object tag=" << tag << dendl; + ldout(cct, 0) << "setting object write_tag=" << state->write_tag << dendl; op.setxattr(RGW_ATTR_ID_TAG, bl); string shadow = obj.object; shadow.append("."); - shadow.append(tag); + shadow.append(state->write_tag); bufferlist shadow_bl; shadow_bl.append(shadow); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index b81a38acea3..fd700ef9963 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -207,6 +207,7 @@ struct RGWObjState { time_t mtime; uint64_t epoch; bufferlist obj_tag; + string write_tag; bool fake_tag; RGWObjManifest manifest; bool has_manifest; |