From 6a05cc1013494086090eec6c0f43db11fbdabdd5 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 11 Dec 2014 15:43:17 -0800 Subject: [PATCH] rgw: fix a few regressions - 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 --- src/cls/rgw/cls_rgw.cc | 5 +++++ src/rgw/rgw_rados.cc | 25 +++++++++++++++---------- src/rgw/rgw_rados.h | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/cls/rgw/cls_rgw.cc b/src/cls/rgw/cls_rgw.cc index a45e1ffe81af6..3e767f7154e1a 100644 --- a/src/cls/rgw/cls_rgw.cc +++ b/src/cls/rgw/cls_rgw.cc @@ -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); } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 85d3546fc1ea9..0fae330056968 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 67662cf9c14a5..34995c657985d 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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); -- 2.39.5