]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix a few regressions
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 11 Dec 2014 23:43:17 +0000 (15:43 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 19 Jan 2015 23:57:56 +0000 (15:57 -0800)
 - need to increase olh epoch if converting plain entry, otherwise
   ordering is skewed
 - if entry is olh (e.g., colocated data + olh), need to make sure we
   write olh idtag xattr
 - completely revalidate obj state after writing it, otherwise attrs
   won't have idtag, and later check to verify if it's olh will fail

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/rgw/cls_rgw.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index a45e1ffe81af690ea0b7e5f8075fc713390dbfde..3e767f7154e1a7b1fa157a2aaa72857950ddfda0 100644 (file)
@@ -1216,6 +1216,10 @@ public:
     return true;
   }
 
+  void inc_epoch() {
+    olh_data_entry.epoch++;
+  }
+
   uint64_t get_epoch() {
     return olh_data_entry.epoch;
   }
@@ -1440,6 +1444,7 @@ static int rgw_bucket_link_olh(cls_method_context_t hctx, bufferlist *in, buffer
       CLS_LOG(0, "ERROR: convert_plain_entry_to_versioned ret=%d", ret);
       return ret;
     }
+    olh.inc_epoch(); /* need to increase epoch, otherwise entries are going to be in the wrong order */
     olh.set_tag(op.olh_tag);
   }
 
index 85d3546fc1ea97ee8b50ef10194cc868fceb072a..0fae33005696827a597a00927017ead1decefd20 100644 (file)
@@ -2829,7 +2829,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   if (r < 0)
     return r;
 
-  rgw_obj& obj = state->obj;
+  rgw_obj& obj = target->get_obj();
   r = store->get_obj_ref(obj, &ref, &bucket);
   if (r < 0)
     return r;
@@ -2849,6 +2849,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
     meta.set_mtime = ut.sec();
   }
 
+  op.setxattr(RGW_ATTR_OLH_ID_TAG, state->olh_tag);
   op.mtime(&meta.set_mtime);
 
   if (meta.data) {
@@ -2905,6 +2906,9 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   uint64_t epoch;
   int64_t poolid;
 
+  bool orig_exists = state->exists;
+  uint64_t orig_size = state->size;
+
   index_tag = state->write_tag;
 
   RGWRados::Bucket bop(store, bucket);
@@ -2924,14 +2928,6 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   epoch = ref.ioctx.get_last_version();
   poolid = ref.ioctx.get_id();
 
-  /* successfully modified object, update internal object state */
-  state->exists = true;
-  state->mtime = meta.set_mtime;
-  state->size = size;
-  state->has_attrs = true;
-  state->epoch = epoch;
-  state->attrset = attrs;
-
   r = target->complete_atomic_modification();
   if (r < 0) {
     ldout(store->ctx(), 0) << "ERROR: complete_atomic_modification returned r=" << r << dendl;
@@ -2947,6 +2943,10 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
     *meta.mtime = meta.set_mtime;
   }
 
+  /* note that index_op was using state so we couldn't invalidate it earlier */
+  target->invalidate_state();
+  state = NULL;
+
   if (target->versioning_enabled() || is_olh) {
     r = store->set_olh(target->get_ctx(), target->get_bucket_info(), obj, false, NULL, meta.olh_epoch);
     if (r < 0) {
@@ -2955,7 +2955,7 @@ int RGWRados::Object::Write::write_meta(uint64_t size,
   }
 
   /* update quota cache */
-  store->quota_handler->update_stats(meta.owner, bucket, (state->exists ? 0 : 1), size, state->size);
+  store->quota_handler->update_stats(meta.owner, bucket, (orig_exists ? 0 : 1), size, orig_size);
 
   return 0;
 
@@ -4393,6 +4393,11 @@ int RGWRados::Object::get_state(RGWObjState **pstate, bool follow_olh)
   return store->get_obj_state(&ctx, obj, pstate, NULL, follow_olh);
 }
 
+void RGWRados::Object::invalidate_state()
+{
+  ctx.invalidate(obj);
+}
+
 int RGWRados::Object::prepare_atomic_modification(ObjectWriteOperation& op, bool reset_obj, const string *ptag,
                                                   const char *if_match, const char *if_nomatch)
 {
index 67662cf9c14a5e628cebf9f0a94913bbbf01d22f..34995c657985dbba231d7286a61c0c475c63b7d2 100644 (file)
@@ -1397,6 +1397,7 @@ public:
 
   protected:
     int get_state(RGWObjState **pstate, bool follow_olh);
+    void invalidate_state();
 
     int prepare_atomic_modification(librados::ObjectWriteOperation& op, bool reset_obj, const string *ptag,
                                     const char *ifmatch, const char *ifnomatch);