]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: share object tag and index tag
authorYehuda Sadeh <yehuda@inktank.com>
Mon, 15 Apr 2013 19:32:48 +0000 (12:32 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 8 May 2013 17:57:46 +0000 (10:57 -0700)
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>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 02d2dc4fb97a398315b30efbc506c162ed870d3c..9888ee0fc50d665b833b63f9af7a485101dda5fb 100644 (file)
@@ -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);
   }
index 60ad5e481ea50cb7066bd4518a2aaa42f4f8fb49..f2821f257232aad09f38c999d8d9d2394d211a5d 100644 (file)
@@ -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);
index b81a38acea3dd8ca2b45cd61d9941c3afeb99aa3..fd700ef9963f0fe21aa8869f2e82a5ccca886906 100644 (file)
@@ -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;