From 3e48a49f49434a34544b3065029340151d4e36f9 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Tue, 28 Oct 2014 17:01:34 -0700 Subject: [PATCH] rgw: fix access to object through the null instance Beforehand we were following olh if the explicit 'null' instance was specified. Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_common.h | 14 +++++++++++--- src/rgw/rgw_rados.cc | 6 ++++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index a2c9b0a7d822a..40c9f257cd044 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1173,15 +1173,23 @@ public: loc.clear(); } + bool have_null_instance() { + return instance == "null"; + } + bool have_instance() { - return !instance.empty() && instance != "null"; + return !instance.empty(); + } + + bool need_to_encode_instance() { + return have_instance() && !have_null_instance(); } void set_obj(const string& o) { object.reserve(128); orig_obj = o; - if (ns.empty() && !have_instance()) { + if (ns.empty() && !need_to_encode_instance()) { if (o.empty()) { return; } @@ -1194,7 +1202,7 @@ public: } else { object = "_"; object.append(ns); - if (have_instance()) { + if (need_to_encode_instance()) { object.append(string(":") + instance); } object.append("_"); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index b5947382fb570..cbe3337419bcc 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -4132,11 +4132,13 @@ int RGWRados::get_olh_target_state(RGWObjectCtx& obj_ctx, rgw_obj& obj, RGWObjSt int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState **state, RGWObjVersionTracker *objv_tracker, bool follow_olh) #warning FIXME: get rid objv_tracker for non system objects { + bool need_follow_olh = follow_olh && !obj.have_instance(); + RGWObjState *s = rctx->get_state(obj); ldout(cct, 20) << "get_obj_state: rctx=" << (void *)rctx << " obj=" << obj << " state=" << (void *)s << " s->prefetch_data=" << s->prefetch_data << dendl; *state = s; if (s->has_attrs) { - if (s->is_olh && follow_olh) { + if (s->is_olh && need_follow_olh) { return get_olh_target_state(*rctx, obj, s, state, objv_tracker); } return 0; @@ -4202,7 +4204,7 @@ int RGWRados::get_obj_state_impl(RGWObjectCtx *rctx, rgw_obj& obj, RGWObjState * if (is_olh(s->attrset)) { s->is_olh = true; - if (follow_olh) { + if (need_follow_olh) { return get_olh_target_state(*rctx, obj, s, state, objv_tracker); } } -- 2.39.5