Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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>
  • Loading branch information...
commit ca403fa450e987b55c73e9a5ff85dbf8e6374b93 1 parent 17c9194
Yehuda Sadeh yehudasa authored
Showing with 12 additions and 52 deletions.
  1. +1 −5 src/rgw/rgw_op.cc
  2. +10 −47 src/rgw/rgw_rados.cc
  3. +1 −0  src/rgw/rgw_rados.h
6 src/rgw/rgw_op.cc
View
@@ -1262,11 +1262,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);
}
57 src/rgw/rgw_rados.cc
View
@@ -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."
@@ -1597,6 +1596,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;
@@ -2473,46 +2477,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);
@@ -2524,22 +2488,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);
1  src/rgw/rgw_rados.h
View
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.