]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix access to object through the null instance
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 29 Oct 2014 00:01:34 +0000 (17:01 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 19 Jan 2015 23:57:48 +0000 (15:57 -0800)
Beforehand we were following olh if the explicit 'null' instance was
specified.

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

index a2c9b0a7d822aad2c3896e388317465ab54ea79c..40c9f257cd044c85a6ddee86ffb6acd03c566a38 100644 (file)
@@ -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("_");
index b5947382fb5700e2f64b390ae9db38934ba0fa5b..cbe3337419bcc1219c70fc3a94494415a06b4931 100644 (file)
@@ -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);
     }
   }