]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: obj_stat() follows on olh
authorYehuda Sadeh <yehuda@redhat.com>
Thu, 4 Sep 2014 22:20:39 +0000 (15:20 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Jan 2015 22:33:43 +0000 (14:33 -0800)
Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 9fc416b0ba2eaeefdcf96ec71837592e3dd77494..351bd903a0f6f70dfe05c2e8e843706efd565a4f 100644 (file)
@@ -5309,6 +5309,35 @@ int RGWRados::set_olh(rgw_obj& obj, RGWOLHInfo& olh)
   return 0;
 }
 
+int RGWRados::follow_olh(map<string, bufferlist>& attrset, rgw_obj& target)
+{
+  map<string, bufferlist> pending_entries;
+  filter_attrset(attrset, RGW_ATTR_OLH_PENDING_PREFIX, &pending_entries);
+
+  if (!pending_entries.empty()) {
+#warning fixme
+  }
+
+  map<string, bufferlist>::iterator iter = attrset.find(RGW_ATTR_OLH_INFO);
+  assert(iter != attrset.end());
+  RGWOLHInfo olh;
+  try {
+    bufferlist::iterator biter = iter->second.begin();
+    ::decode(olh, biter);
+  } catch (buffer::error& err) {
+    ldout(cct, 0) << "ERROR: failed to decode olh info" << dendl;
+    return -EIO;
+  }
+
+  if (olh.removed) {
+    return -ENOENT;
+  }
+
+  target = olh.target;
+
+  return 0;
+}
+
 int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime, uint64_t *epoch,
                        map<string, bufferlist> *attrs, bufferlist *first_chunk,
                        RGWObjVersionTracker *objv_tracker)
@@ -5347,6 +5376,15 @@ int RGWRados::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmtime,
 
   map<string, bufferlist>::iterator iter = attrset.find(RGW_ATTR_OLH_INFO);
   if (iter != attrset.end()) {
+    /* this is an olh */
+    rgw_obj target;
+
+    r = follow_olh(attrset, target);
+    if (r < 0) {
+      return r;
+    }
+
+    return obj_stat(ctx, target, psize, pmtime, epoch, attrs, first_chunk, objv_tracker);
 #warning implment me
   }
 
index 080b6c2a173b7f71fdfd6ed3660f06359ecbbc59..902a911df3dd8ade31e4069ff49c728ec7a170c3 100644 (file)
@@ -59,16 +59,21 @@ int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& attrset,
 
 struct RGWOLHInfo {
   rgw_obj target;
+  bool removed;
+
+  RGWOLHInfo() : removed(false) {}
 
   void encode(bufferlist& bl) const {
     ENCODE_START(1, 1, bl);
     ::encode(target, bl);
+    ::encode(removed, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
      DECODE_START(1, bl);
      ::decode(target, bl);
+     ::decode(removed, bl);
      DECODE_FINISH(bl);
   }
 
@@ -1746,6 +1751,7 @@ public:
 
   int olh_init_modification(rgw_obj& obj, string *tag);
 
+  int follow_olh(map<string, bufferlist>& attrset, rgw_obj& target);
   int get_olh(rgw_obj& obj, RGWOLHInfo *olh);
   int set_olh(rgw_obj& obj, RGWOLHInfo& olh);