]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: decouple object name from index representation
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 6 Aug 2014 19:49:55 +0000 (12:49 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 16 Jan 2015 22:18:45 +0000 (14:18 -0800)
We can't have a direct mapping between the object name to the way we
index it in the bucket index. Have rgw_obj provide different
representations appropriately and use the proper ones where needed.
Introduce the instance element which will be used to refer to versioned
objects.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/cls/rgw/cls_rgw_client.cc
src/cls/rgw/cls_rgw_client.h
src/cls/rgw/cls_rgw_ops.cc
src/cls/rgw/cls_rgw_ops.h
src/rgw/rgw_bucket.cc
src/rgw/rgw_cache.h
src/rgw/rgw_common.h
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_rest_client.cc

index c13c1a1559c62b7c68cbe7f691925bb013f1df54..9431904654b7e5900f09eec8914eeb85929d4147 100644 (file)
@@ -27,7 +27,7 @@ void cls_rgw_bucket_set_tag_timeout(ObjectWriteOperation& o, uint64_t tag_timeou
 }
 
 void cls_rgw_bucket_prepare_op(ObjectWriteOperation& o, RGWModifyOp op, string& tag,
-                               string& name, string& locator, bool log_op)
+                               const string& name, const string& instance, const string& locator, bool log_op)
 {
   struct rgw_cls_obj_prepare_op call;
   call.op = op;
@@ -35,13 +35,16 @@ void cls_rgw_bucket_prepare_op(ObjectWriteOperation& o, RGWModifyOp op, string&
   call.name = name;
   call.locator = locator;
   call.log_op = log_op;
+  call.instance = instance;
   bufferlist in;
   ::encode(call, in);
   o.exec("rgw", "bucket_prepare_op", in);
 }
 
 void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, string& tag,
-                                rgw_bucket_entry_ver& ver, string& name, rgw_bucket_dir_entry_meta& dir_meta,
+                                rgw_bucket_entry_ver& ver,
+                                const string& name, const string& instance,
+                                rgw_bucket_dir_entry_meta& dir_meta,
                                list<string> *remove_objs, bool log_op)
 {
 
@@ -53,6 +56,7 @@ void cls_rgw_bucket_complete_op(ObjectWriteOperation& o, RGWModifyOp op, string&
   call.ver = ver;
   call.meta = dir_meta;
   call.log_op = log_op;
+  call.instance = instance;
   if (remove_objs)
     call.remove_objs = *remove_objs;
   ::encode(call, in);
index c6b5b757fa843d0e587cb2a43ecb94951ceb8f6e..a30d8cf4ec74abc0a816fcb6671c55b8df8ac46f 100644 (file)
@@ -18,10 +18,12 @@ void cls_rgw_bucket_init(librados::ObjectWriteOperation& o);
 void cls_rgw_bucket_set_tag_timeout(librados::ObjectWriteOperation& o, uint64_t tag_timeout);
 
 void cls_rgw_bucket_prepare_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag,
-                               string& name, string& locator, bool log_op);
+                               const string& name, const string& instance, const string& locator, bool log_op);
 
 void cls_rgw_bucket_complete_op(librados::ObjectWriteOperation& o, RGWModifyOp op, string& tag,
-                                rgw_bucket_entry_ver& ver, string& name, rgw_bucket_dir_entry_meta& dir_meta,
+                                rgw_bucket_entry_ver& ver,
+                                const string& name, const string& instance,
+                                rgw_bucket_dir_entry_meta& dir_meta,
                                list<string> *remove_objs, bool log_op);
 
 int cls_rgw_list_op(librados::IoCtx& io_ctx, string& oid, string& start_obj,
index 01c0666d9ebe9bf1069732b963341494b9c42e79..53f43b546ca2a40bf79455b6c3c732cdb41dbf66 100644 (file)
@@ -139,6 +139,7 @@ void rgw_cls_obj_complete_op::dump(Formatter *f) const
   meta.dump(f);
   f->close_section();
   f->dump_string("tag", tag);
+  f->dump_string("instance", instance);
 }
 
 void rgw_cls_list_op::generate_test_instances(list<rgw_cls_list_op*>& o)
index e5db06010dc240c0929f46f22097e9f54e1eae27..38082869bfa5932f24ad7dff8559d550eb5f5193 100644 (file)
@@ -34,21 +34,23 @@ struct rgw_cls_obj_prepare_op
   string tag;
   string locator;
   bool log_op;
+  string instance;
 
   rgw_cls_obj_prepare_op() : op(CLS_RGW_OP_UNKNOWN), log_op(false) {}
 
   void encode(bufferlist &bl) const {
-    ENCODE_START(4, 3, bl);
+    ENCODE_START(5, 3, bl);
     uint8_t c = (uint8_t)op;
     ::encode(c, bl);
     ::encode(name, bl);
     ::encode(tag, bl);
     ::encode(locator, bl);
     ::encode(log_op, bl);
+    ::encode(instance, bl);
     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator &bl) {
-    DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, bl);
     uint8_t c;
     ::decode(c, bl);
     op = (RGWModifyOp)c;
@@ -60,6 +62,9 @@ struct rgw_cls_obj_prepare_op
     if (struct_v >= 4) {
       ::decode(log_op, bl);
     }
+    if (struct_v >= 5) {
+      ::decode(instance, bl);
+    }
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
@@ -76,13 +81,14 @@ struct rgw_cls_obj_complete_op
   struct rgw_bucket_dir_entry_meta meta;
   string tag;
   bool log_op;
+  string instance;
 
   list<string> remove_objs;
 
   rgw_cls_obj_complete_op() : op(CLS_RGW_OP_ADD), log_op(false) {}
 
   void encode(bufferlist &bl) const {
-    ENCODE_START(6, 3, bl);
+    ENCODE_START(7, 3, bl);
     uint8_t c = (uint8_t)op;
     ::encode(c, bl);
     ::encode(name, bl);
@@ -93,6 +99,7 @@ struct rgw_cls_obj_complete_op
     ::encode(remove_objs, bl);
     ::encode(ver, bl);
     ::encode(log_op, bl);
+    ::encode(instance, bl);
     ENCODE_FINISH(bl);
  }
   void decode(bufferlist::iterator &bl) {
@@ -118,6 +125,9 @@ struct rgw_cls_obj_complete_op
     if (struct_v >= 6) {
       ::decode(log_op, bl);
     }
+    if (struct_v >= 7) {
+      ::decode(instance, bl);
+    }
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
index 4afe1ae10192a8bc5b4277adaa12aedb8b3ce9c0..1aca2ebab3f614467dc067b6b966449d8eaec8d9 100644 (file)
@@ -332,8 +332,9 @@ void check_bad_user_bucket_mapping(RGWRados *store, const string& user_id, bool
 static bool bucket_object_check_filter(const string& name)
 {
   string ns;
+  string ver;
   string obj = name;
-  return rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns);
+  return rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns, ver);
 }
 
 int rgw_remove_object(RGWRados *store, const string& bucket_owner, rgw_bucket& bucket, std::string& object)
@@ -657,10 +658,11 @@ int RGWBucket::check_bad_index_multipart(RGWBucketAdminOpState& op_state,
     for (iter = result.begin(); iter != result.end(); ++iter) {
       RGWObjEnt& ent = *iter;
 
-      rgw_obj obj(bucket, ent.name);
-      obj.set_ns(ns);
+      rgw_obj obj(bucket, ent.name, ns);
+      obj.set_instance(ent.instance);
 
-      string& oid = obj.object;
+      string oid = obj.get_index_key();
+#warning missing marker_ver
       marker = oid;
 
       int pos = oid.find_last_of('.');
index 8b1bc93bfb029e013d4ba9a401878798372b8464..c8015fef6c4e942ad3605493ca7b2b384fc5f14e 100644 (file)
@@ -172,7 +172,7 @@ class RGWCache  : public T
     return T::list_objects_raw_next(obj, handle);
   }
 
-  string normal_name(rgw_bucket& bucket, std::string& oid) {
+  string normal_name(rgw_bucket& bucket, const std::string& oid) {
     string& bucket_name = bucket.name;
     char buf[bucket_name.size() + 1 + oid.size() + 1];
     const char *bucket_str = bucket_name.c_str();
@@ -181,9 +181,9 @@ class RGWCache  : public T
     return string(buf);
   }
 
-  void normalize_bucket_and_obj(rgw_bucket& src_bucket, string& src_obj, rgw_bucket& dst_bucket, string& dst_obj);
+  void normalize_bucket_and_obj(rgw_bucket& src_bucket, const string& src_obj, rgw_bucket& dst_bucket, string& dst_obj);
   string normal_name(rgw_obj& obj) {
-    return normal_name(obj.bucket, obj.object);
+    return normal_name(obj.bucket, obj.get_object());
   }
 
   int init_rados() {
@@ -234,7 +234,7 @@ public:
 };
 
 template <class T>
-void RGWCache<T>::normalize_bucket_and_obj(rgw_bucket& src_bucket, string& src_obj, rgw_bucket& dst_bucket, string& dst_obj)
+void RGWCache<T>::normalize_bucket_and_obj(rgw_bucket& src_bucket, const string& src_obj, rgw_bucket& dst_bucket, string& dst_obj)
 {
   if (src_obj.size()) {
     dst_bucket = src_bucket;
@@ -250,7 +250,7 @@ int RGWCache<T>::delete_obj_impl(void *ctx, const string& bucket_owner, rgw_obj&
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   if (bucket.name[0] != '.')
     return T::delete_obj_impl(ctx, bucket_owner, obj, objv_tracker);
 
@@ -269,7 +269,7 @@ int RGWCache<T>::get_obj(void *ctx, RGWObjVersionTracker *objv_tracker, void **h
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   if (bucket.name[0] != '.' || ofs != 0)
     return T::get_obj(ctx, objv_tracker, handle, obj, obl, ofs, end, cache_info);
 
@@ -329,7 +329,7 @@ int RGWCache<T>::set_attr(void *ctx, rgw_obj& obj, const char *attr_name, buffer
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   ObjectCacheInfo info;
   bool cacheable = false;
   if (bucket.name[0] == '.') {
@@ -366,7 +366,7 @@ int RGWCache<T>::set_attrs(void *ctx, rgw_obj& obj,
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   ObjectCacheInfo info;
   bool cacheable = false;
   if (bucket.name[0] == '.') {
@@ -408,7 +408,7 @@ int RGWCache<T>::put_obj_meta_impl(void *ctx, rgw_obj& obj, uint64_t size, time_
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   ObjectCacheInfo info;
   bool cacheable = false;
   if (bucket.name[0] == '.') {
@@ -449,7 +449,7 @@ int RGWCache<T>::put_obj_data(void *ctx, rgw_obj& obj, const char *data,
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   ObjectCacheInfo info;
   bool cacheable = false;
   if ((bucket.name[0] == '.') && ((ofs == 0) || (ofs == -1))) {
@@ -485,7 +485,7 @@ int RGWCache<T>::obj_stat(void *ctx, rgw_obj& obj, uint64_t *psize, time_t *pmti
 {
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(obj.bucket, obj.object, bucket, oid);
+  normalize_bucket_and_obj(obj.bucket, obj.get_object(), bucket, oid);
   if (bucket.name[0] != '.')
     return T::obj_stat(ctx, obj, psize, pmtime, pepoch, attrs, first_chunk, objv_tracker);
 
@@ -574,7 +574,7 @@ int RGWCache<T>::watch_cb(int opcode, uint64_t ver, bufferlist& bl)
 
   rgw_bucket bucket;
   string oid;
-  normalize_bucket_and_obj(info.obj.bucket, info.obj.object, bucket, oid);
+  normalize_bucket_and_obj(info.obj.bucket, info.obj.get_object(), bucket, oid);
   string name = normal_name(bucket, oid);
   
   switch (info.op) {
index c9500884d9d37add08ea4c6685fbddd85138b165..95f251df361306f6c6d031d99990dd0472ec1564 100644 (file)
@@ -945,6 +945,7 @@ struct RGWObjEnt {
   string etag;
   string content_type;
   string tag;
+  string instance;
 
   RGWObjEnt() : size(0) {}
 
@@ -1018,11 +1019,15 @@ WRITE_CLASS_ENCODER(RGWBucketEnt)
 class rgw_obj {
   std::string orig_obj;
   std::string orig_key;
+  std::string key;
+  std::string object;
+  std::string instance;
 public:
+  const std::string& get_object() const { return object; }
+  const std::string& get_key() const { return key; }
+  const std::string& get_instance() const { return instance; }
   rgw_bucket bucket;
-  std::string key;
   std::string ns;
-  std::string object;
 
   bool in_extra_data; /* in-memory only member, does not serialize */
 
@@ -1071,6 +1076,12 @@ public:
     set_obj(orig_obj);
     return 0;
   }
+  void set_instance(const string& i) {
+    if (i[0] == '_')
+      return -EINVAL;
+    instance = i;
+    set_obj(orig_obj);
+  }
 
   void set_key(const string& k) {
     orig_key = k;
@@ -1099,6 +1110,9 @@ public:
     } else {
       object = "_";
       object.append(ns);
+      if (!instance.empty()) {
+        object.append(string(":") + instance);
+      }
       object.append("_");
       object.append(o);
     }
@@ -1108,6 +1122,34 @@ public:
       set_key(orig_obj);
   }
 
+  /*
+   * get the object's key name as being referred to by the bucket index. Note that
+   * this doesn't include the object version portion, as it's passed separately to the
+   * index.
+   */
+  string get_index_key() {
+    if (ns.empty()) {
+      if (orig_obj.size() < 1 || orig_obj[0] != '_') {
+        return orig_obj;
+      }
+      return string("_") + orig_obj;
+    };
+
+    char buf[ns.size() + 16];
+    snprintf(buf, sizeof(buf), "_%s_", ns.c_str());
+    return string(buf) + orig_obj;
+  };
+
+  static void parse_ns_field(string& ns, string& instance) {
+    int pos = ns.find(':');
+    if (pos >= 0) {
+      instance = ns.substr(pos + 1);
+      ns = ns.substr(0, pos);
+    } else {
+      instance.clear();
+    }
+  }
+
   /**
    * Translate a namespace-mangled object name to the user-facing name
    * existing in the given namespace.
@@ -1116,7 +1158,7 @@ public:
    * and cuts down the name to the unmangled version. If it is not
    * part of the given namespace, it returns false.
    */
-  static bool translate_raw_obj_to_obj_in_ns(string& obj, string& ns) {
+  static bool translate_raw_obj_to_obj_in_ns(string& obj, string& instance, string& ns) {
     if (ns.empty()) {
       if (obj[0] != '_')
         return true;
@@ -1137,6 +1179,7 @@ public:
       return false;
 
     string obj_ns = obj.substr(1, pos - 1);
+    parse_ns_field(obj_ns, instance);
     if (obj_ns.compare(ns) != 0)
         return false;
 
@@ -1152,8 +1195,9 @@ public:
    * It returns true after successfully doing so, or
    * false if it fails.
    */
-  static bool strip_namespace_from_object(string& obj, string& ns) {
+  static bool strip_namespace_from_object(string& obj, string& ns, string& instance) {
     ns.clear();
+    instance.clear();
     if (obj[0] != '_') {
       return true;
     }
@@ -1170,6 +1214,8 @@ public:
 
     ns = obj.substr(1, pos-1);
     obj = obj.substr(pos+1, string::npos);
+
+    parse_ns_field(ns, instance);
     return true;
   }
 
@@ -1182,22 +1228,25 @@ public:
   }
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(3, 3, bl);
+    ENCODE_START(4, 3, bl);
     ::encode(bucket.name, bl);
     ::encode(key, bl);
     ::encode(ns, bl);
     ::encode(object, bl);
     ::encode(bucket, bl);
+    ::encode(instance, bl);
     ENCODE_FINISH(bl);
   }
   void decode(bufferlist::iterator& bl) {
-    DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl);
+    DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl);
     ::decode(bucket.name, bl);
     ::decode(key, bl);
     ::decode(ns, bl);
     ::decode(object, bl);
     if (struct_v >= 2)
       ::decode(bucket, bl);
+    if (struct_v >= 4)
+      ::decode(instance, bl);
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
@@ -1206,7 +1255,8 @@ public:
   bool operator==(const rgw_obj& o) const {
     return (object.compare(o.object) == 0) &&
            (bucket.name.compare(o.bucket.name) == 0) &&
-           (ns.compare(o.ns) == 0);
+           (ns.compare(o.ns) == 0) &&
+           (instance.compare(o.instance) == 0);
   }
   bool operator<(const rgw_obj& o) const {
     int r = bucket.name.compare(o.bucket.name);
@@ -1214,6 +1264,9 @@ public:
      r = object.compare(o.object);
      if (r == 0) {
        r = ns.compare(o.ns);
+       if (r == 0) {
+         r = instance.compare(o.instance);
+       }
      }
     }
 
@@ -1230,7 +1283,7 @@ struct rgw_cache_entry_info {
 };
 
 inline ostream& operator<<(ostream& out, const rgw_obj &o) {
-  return out << o.bucket.name << ":" << o.object;
+  return out << o.bucket.name << ":" << o.get_object();
 }
 
 static inline bool str_startswith(const string& str, const string& prefix)
@@ -1292,7 +1345,7 @@ static inline int rgw_str_to_bool(const char *s, int def_val)
           strcasecmp(s, "1") == 0);
 }
 
-static inline void append_rand_alpha(CephContext *cct, string& src, string& dest, int len)
+static inline void append_rand_alpha(CephContext *cct, const string& src, string& dest, int len)
 {
   dest = src;
   char buf[len + 1];
index a68fb5a67badafbd568fdbab4c06c1d7f93c9fd7..4ef5e4d79e620ba0bc5388b73de37e55f0064209 100644 (file)
@@ -244,7 +244,7 @@ static int get_policy_from_attr(CephContext *cct, RGWRados *store, void *ctx,
     return 0;
   }
 
-  if (obj.object.empty()) {
+  if (obj.get_object().empty()) {
     rgw_obj instance_obj;
     store->get_bucket_instance_obj(bucket_info.bucket, instance_obj);
     return get_bucket_policy_from_attr(cct, store, ctx, bucket_info, bucket_attrs,
@@ -2849,7 +2849,7 @@ void RGWCompleteMultipart::execute()
         manifest.append(obj_part.manifest);
       }
 
-      remove_objs.push_back(src_obj.object);
+      remove_objs.push_back(src_obj.get_index_key());
 
       ofs += obj_part.size;
     }
index 90187a7bf3eeb6d43b7eff1226d9bd624e155b42..c3bffccfb8e40db625d1beaf0b540be7695df120 100644 (file)
@@ -1216,7 +1216,9 @@ int RGWPutObjProcessor_Atomic::do_complete(string& etag, time_t *mtime, time_t s
   extra_params.owner = bucket_owner;
 
   if (versioned_object) {
-    rgw_obj ver_head_obj(head_obj.bucket, head_obj.object, "ver");
+    rgw_obj ver_head_obj = head_obj;
+
+    ver_head_obj.set_instance("instance");
 
     r = store->put_obj_meta(NULL, ver_head_obj, obj_len, attrs,
                             RGW_OBJ_CATEGORY_MAIN, PUT_OBJ_CREATE,
@@ -1243,7 +1245,7 @@ public:
 };
 
 RGWObjState *RGWRadosCtx::get_state(rgw_obj& obj) {
-  if (obj.object.size()) {
+  if (!obj.get_object().empty()) {
     return &objs_state[obj];
   } else {
     rgw_obj new_obj(store->zone.domain_root, obj.bucket.name);
@@ -1252,7 +1254,7 @@ RGWObjState *RGWRadosCtx::get_state(rgw_obj& obj) {
 }
 
 void RGWRadosCtx::set_atomic(rgw_obj& obj) {
-  if (obj.object.size()) {
+  if (!obj.get_object().empty()) {
     objs_state[obj].is_atomic = true;
   } else {
     rgw_obj new_obj(store->zone.domain_root, obj.bucket.name);
@@ -1261,7 +1263,7 @@ void RGWRadosCtx::set_atomic(rgw_obj& obj) {
 }
 
 void RGWRadosCtx::set_prefetch_data(rgw_obj& obj) {
-  if (obj.object.size()) {
+  if (!obj.get_object().empty()) {
     objs_state[obj].prefetch_data = true;
   } else {
     rgw_obj new_obj(store->zone.domain_root, obj.bucket.name);
@@ -2223,11 +2225,12 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
   rgw_obj marker_obj, prefix_obj;
   marker_obj.set_ns(ns);
   marker_obj.set_obj(marker);
-  string cur_marker = marker_obj.object;
+#warning missing marker_ver
+  string cur_marker = marker_obj.get_index_key();
 
   prefix_obj.set_ns(ns);
   prefix_obj.set_obj(prefix);
-  string cur_prefix = prefix_obj.object;
+  string cur_prefix = prefix_obj.get_index_key();
 
   string bigger_than_delim;
 
@@ -2270,8 +2273,9 @@ int RGWRados::list_objects(rgw_bucket& bucket, int max, string& prefix, string&
     for (eiter = ent_map.begin(); eiter != ent_map.end(); ++eiter) {
       string obj = eiter->first;
       string key = obj;
+      string instance;
 
-      bool check_ns = rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns);
+      bool check_ns = rgw_obj::translate_raw_obj_to_obj_in_ns(obj, instance, ns);
 
       if (enforce_ns && !check_ns) {
         if (!ns.empty()) {
@@ -2961,7 +2965,7 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj,  uint64_t size,
     ldout(cct, 0) << "ERROR: complete_atomic_overwrite returned r=" << r << dendl;
   }
 
-  r = complete_update_index(bucket, obj.object, index_tag, poolid, epoch, size,
+  r = complete_update_index(bucket, obj, index_tag, poolid, epoch, size,
                             ut, etag, content_type, &acl_bl, category, remove_objs);
   if (r < 0)
     goto done_cancel;
@@ -2978,7 +2982,7 @@ int RGWRados::put_obj_meta_impl(void *ctx, rgw_obj& obj,  uint64_t size,
   return 0;
 
 done_cancel:
-  int ret = complete_update_index_cancel(bucket, obj.object, index_tag);
+  int ret = complete_update_index_cancel(bucket, obj, index_tag);
   if (ret < 0) {
     ldout(cct, 0) << "ERROR: complete_update_index_cancel() returned ret=" << ret << dendl;
   }
@@ -3254,7 +3258,7 @@ int RGWRados::copy_obj(void *ctx,
   bool remote_src;
   bool remote_dest;
 
-  append_rand_alpha(cct, dest_obj.object, shadow_oid, 32);
+  append_rand_alpha(cct, dest_obj.get_object(), shadow_oid, 32);
   shadow_obj.init_ns(dest_obj.bucket, shadow_oid, shadow_ns);
 
   remote_dest = !region.equals(dest_bucket_info.region);
@@ -3265,7 +3269,7 @@ int RGWRados::copy_obj(void *ctx,
     return -EINVAL;
   }
 
-  ldout(cct, 5) << "Copy object " << src_obj.bucket << ":" << src_obj.object << " => " << dest_obj.bucket << ":" << dest_obj.object << dendl;
+  ldout(cct, 5) << "Copy object " << src_obj.bucket << ":" << src_obj.get_object() << " => " << dest_obj.bucket << ":" << dest_obj.get_object() << dendl;
 
   void *handle = NULL;
   GetObjHandleDestructor handle_destructor(this);
@@ -3287,7 +3291,7 @@ int RGWRados::copy_obj(void *ctx,
     string tag;
     append_rand_alpha(cct, tag, tag, 32);
 
-    RGWPutObjProcessor_Atomic processor(dest_bucket_info.owner, dest_obj.bucket, dest_obj.object,
+    RGWPutObjProcessor_Atomic processor(dest_bucket_info.owner, dest_obj.bucket, dest_obj.get_object(),
                                         cct->_conf->rgw_obj_stripe_size, tag, dest_bucket_info.versioning_enabled);
     ret = processor.prepare(this, ctx, NULL);
     if (ret < 0)
@@ -3315,7 +3319,7 @@ int RGWRados::copy_obj(void *ctx,
       conn = iter->second;
     }
 
-    string obj_name = dest_obj.bucket.name + "/" + dest_obj.object;
+    string obj_name = dest_obj.bucket.name + "/" + dest_obj.get_object();
 
     RGWOpStateSingleOp opstate(this, client_id, op_id, obj_name);
 
@@ -3572,7 +3576,7 @@ int RGWRados::copy_obj_data(void *ctx,
   string tag;
   append_rand_alpha(cct, tag, tag, 32);
 
-  RGWPutObjProcessor_Atomic processor(owner, dest_obj.bucket, dest_obj.object,
+  RGWPutObjProcessor_Atomic processor(owner, dest_obj.bucket, dest_obj.get_object(),
                                       cct->_conf->rgw_obj_stripe_size, tag);
   int ret = processor.prepare(this, ctx, NULL);
   if (ret < 0)
@@ -3646,10 +3650,11 @@ int RGWRados::delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_track
     string ns;
     std::map<string, RGWObjEnt>::iterator eiter;
     string obj;
+    string instance;
     for (eiter = ent_map.begin(); eiter != ent_map.end(); ++eiter) {
       obj = eiter->first;
 
-      if (rgw_obj::translate_raw_obj_to_obj_in_ns(obj, ns))
+      if (rgw_obj::translate_raw_obj_to_obj_in_ns(obj, instance, ns))
         return -ENOTEMPTY;
     }
   } while (is_truncated);
@@ -3901,9 +3906,9 @@ int RGWRados::delete_obj_impl(void *ctx, const string& bucket_owner, rgw_obj& ob
   int64_t poolid = ref.ioctx.get_id();
   if (r >= 0 || r == -ENOENT) {
     uint64_t epoch = ref.ioctx.get_last_version();
-    r = complete_update_index_del(bucket, obj.object, tag, poolid, epoch);
+    r = complete_update_index_del(bucket, obj, tag, poolid, epoch);
   } else {
-    int ret = complete_update_index_cancel(bucket, obj.object, tag);
+    int ret = complete_update_index_cancel(bucket, obj, tag);
     if (ret < 0) {
       ldout(cct, 0) << "ERROR: complete_update_index_cancel returned ret=" << ret << dendl;
     }
@@ -3962,7 +3967,7 @@ int RGWRados::delete_obj_index(rgw_obj& obj)
   get_obj_bucket_and_oid_key(obj, bucket, oid, key);
 
   string tag;
-  int r = complete_update_index_del(bucket, obj.object, tag, -1 /* pool */, 0);
+  int r = complete_update_index_del(bucket, obj, tag, -1 /* pool */, 0);
 
   return r;
 }
@@ -3975,7 +3980,7 @@ static void generate_fake_tag(CephContext *cct, map<string, bufferlist>& attrset
   if (mi != manifest.obj_end()) {
     if (manifest.has_tail()) // first object usually points at the head, let's skip to a more unique part
       ++mi;
-    tag = mi.get_location().object;
+    tag = mi.get_location().get_object();
     tag.append("_");
   }
 
@@ -4538,13 +4543,12 @@ int RGWRados::prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
       append_rand_alpha(cct, tag, tag, 32);
     }
   }
-  ret = cls_obj_prepare_op(bucket, op, tag,
-                               obj.object, obj.key);
+  ret = cls_obj_prepare_op(bucket, op, tag, obj);
 
   return ret;
 }
 
-int RGWRados::complete_update_index(rgw_bucket& bucket, string& oid, string& tag, int64_t poolid, uint64_t epoch, uint64_t size,
+int RGWRados::complete_update_index(rgw_bucket& bucket, rgw_obj& obj, string& tag, int64_t poolid, uint64_t epoch, uint64_t size,
                                     utime_t& ut, string& etag, string& content_type, bufferlist *acl_bl, RGWObjCategory category,
                                     list<string> *remove_objs)
 {
@@ -4552,7 +4556,8 @@ int RGWRados::complete_update_index(rgw_bucket& bucket, string& oid, string& tag
     return 0;
 
   RGWObjEnt ent;
-  ent.name = oid;
+  ent.name = obj.get_index_key();
+  ent.instance = obj.get_instance();
   ent.size = size;
   ent.mtime = ut;
   ent.etag = etag;
@@ -4641,7 +4646,8 @@ int RGWRados::clone_objs_impl(void *ctx, rgw_obj& dst_obj,
       range.len += next.len;
     }
     if (range.len) {
-      ldout(cct, 20) << "calling op.clone_range(dst_ofs=" << range.dst_ofs << ", src.object=" <<  range.src.object << " range.src_ofs=" << range.src_ofs << " range.len=" << range.len << dendl;
+      ldout(cct, 20) << "calling op.clone_range(dst_ofs=" << range.dst_ofs << ", src.object=" <<  range.src.get_object()
+        << " range.src_ofs=" << range.src_ofs << " range.len=" << range.len << dendl;
       if (xattr_cond) {
         string src_cmp_obj, src_cmp_key;
         get_obj_bucket_and_oid_key(range.src, bucket, src_cmp_obj, src_cmp_key);
@@ -4686,10 +4692,10 @@ done:
 
   if (update_index) {
     if (ret >= 0) {
-      ret = complete_update_index(bucket, dst_obj.object, tag, poolid, epoch, size,
+      ret = complete_update_index(bucket, dst_obj, tag, poolid, epoch, size,
                                   ut, etag, content_type, &acl_bl, category, NULL);
     } else {
-      int r = complete_update_index_cancel(bucket, dst_obj.object, tag);
+      int r = complete_update_index_cancel(bucket, dst_obj, tag);
       if (r < 0) {
         ldout(cct, 0) << "ERROR: comlete_update_index_cancel() returned r=" << r << dendl;
       }
@@ -6060,7 +6066,7 @@ int RGWRados::cls_rgw_init_index(librados::IoCtx& index_ctx, librados::ObjectWri
 }
 
 int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, RGWModifyOp op, string& tag,
-                                 string& name, string& locator)
+                                 rgw_obj& obj)
 {
   librados::IoCtx index_ctx;
   string oid;
@@ -6070,7 +6076,7 @@ int RGWRados::cls_obj_prepare_op(rgw_bucket& bucket, RGWModifyOp op, string& tag
     return r;
 
   ObjectWriteOperation o;
-  cls_rgw_bucket_prepare_op(o, op, tag, name, locator, zone_public_config.log_data);
+  cls_rgw_bucket_prepare_op(o, op, tag, obj.get_index_key(), obj.get_instance(), obj.get_key(), zone_public_config.log_data);
   r = index_ctx.operate(oid, &o);
   return r;
 }
@@ -6101,7 +6107,7 @@ int RGWRados::cls_obj_complete_op(rgw_bucket& bucket, RGWModifyOp op, string& ta
   rgw_bucket_entry_ver ver;
   ver.pool = pool;
   ver.epoch = epoch;
-  cls_rgw_bucket_complete_op(o, op, tag, ver, ent.name, dir_meta, remove_objs, zone_public_config.log_data);
+  cls_rgw_bucket_complete_op(o, op, tag, ver, ent.name, ent.instance, dir_meta, remove_objs, zone_public_config.log_data);
 
   AioCompletion *c = librados::Rados::aio_create_completion(NULL, NULL, NULL);
   r = index_ctx.aio_operate(oid, c, &o);
@@ -6119,17 +6125,19 @@ int RGWRados::cls_obj_complete_add(rgw_bucket& bucket, string& tag,
 
 int RGWRados::cls_obj_complete_del(rgw_bucket& bucket, string& tag,
                                    int64_t pool, uint64_t epoch,
-                                   string& name)
+                                   rgw_obj& obj)
 {
   RGWObjEnt ent;
-  ent.name = name;
+  ent.name = obj.get_index_key();
+  ent.instance =  obj.get_instance();
   return cls_obj_complete_op(bucket, CLS_RGW_OP_DEL, tag, pool, epoch, ent, RGW_OBJ_CATEGORY_NONE, NULL);
 }
 
-int RGWRados::cls_obj_complete_cancel(rgw_bucket& bucket, string& tag, string& name)
+int RGWRados::cls_obj_complete_cancel(rgw_bucket& bucket, string& tag, rgw_obj& obj)
 {
   RGWObjEnt ent;
-  ent.name = name;
+  ent.name = obj.get_index_key();
+  ent.instance = obj.get_instance();
   return cls_obj_complete_op(bucket, CLS_RGW_OP_ADD, tag, -1 /* pool id */, 0, ent, RGW_OBJ_CATEGORY_NONE, NULL);
 }
 
@@ -6320,13 +6328,14 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
                                bufferlist& suggested_updates)
 {
   rgw_obj obj;
-  std::string oid, key, ns;
+  std::string oid, instance, key, ns;
   oid = list_state.name;
-  if (!rgw_obj::strip_namespace_from_object(oid, ns)) {
+  if (!rgw_obj::strip_namespace_from_object(oid, ns, instance)) {
     // well crap
     assert(0 == "got bad object name off disk");
   }
   obj.init(bucket, oid, list_state.locator, ns);
+  obj.set_instance(instance);
   get_obj_bucket_and_oid_key(obj, bucket, oid, key);
   io_ctx.locator_set_key(key);
 
index c8de6ccdcbdb4d5a7850fd38a2235ffd81afee3a..e074ab1266c6db63aa1b550c5856dc7621591969 100644 (file)
@@ -46,8 +46,8 @@ static inline void prepend_bucket_marker(rgw_bucket& bucket, const string& orig_
 static inline void get_obj_bucket_and_oid_key(const rgw_obj& obj, rgw_bucket& bucket, string& oid, string& key)
 {
   bucket = obj.bucket;
-  prepend_bucket_marker(bucket, obj.object, oid);
-  prepend_bucket_marker(bucket, obj.key, key);
+  prepend_bucket_marker(bucket, obj.get_object(), oid);
+  prepend_bucket_marker(bucket, obj.get_key(), key);
 }
 
 int rgw_policy_from_attrset(CephContext *cct, map<string, bufferlist>& attrset, RGWAccessControlPolicy *policy);
@@ -1841,12 +1841,12 @@ public:
 
   int cls_rgw_init_index(librados::IoCtx& io_ctx, librados::ObjectWriteOperation& op, string& oid);
   int cls_obj_prepare_op(rgw_bucket& bucket, RGWModifyOp op, string& tag,
-                         string& name, string& locator);
+                         rgw_obj& obj);
   int cls_obj_complete_op(rgw_bucket& bucket, RGWModifyOp op, string& tag, int64_t pool, uint64_t epoch,
                           RGWObjEnt& ent, RGWObjCategory category, list<string> *remove_objs);
   int cls_obj_complete_add(rgw_bucket& bucket, string& tag, int64_t pool, uint64_t epoch, RGWObjEnt& ent, RGWObjCategory category, list<string> *remove_objs);
-  int cls_obj_complete_del(rgw_bucket& bucket, string& tag, int64_t pool, uint64_t epoch, string& name);
-  int cls_obj_complete_cancel(rgw_bucket& bucket, string& tag, string& name);
+  int cls_obj_complete_del(rgw_bucket& bucket, string& tag, int64_t pool, uint64_t epoch, rgw_obj& obj);
+  int cls_obj_complete_cancel(rgw_bucket& bucket, string& tag, rgw_obj& obj);
   int cls_obj_set_bucket_tag_timeout(rgw_bucket& bucket, uint64_t timeout);
   int cls_bucket_list(rgw_bucket& bucket, string start, string prefix, uint32_t num,
                       map<string, RGWObjEnt>& m, bool *is_truncated,
@@ -1855,20 +1855,20 @@ public:
   int cls_bucket_head_async(rgw_bucket& bucket, RGWGetDirHeader_CB *ctx);
   int prepare_update_index(RGWObjState *state, rgw_bucket& bucket,
                            RGWModifyOp op, rgw_obj& oid, string& tag);
-  int complete_update_index(rgw_bucket& bucket, string& oid, string& tag, int64_t poolid, uint64_t epoch, uint64_t size,
+  int complete_update_index(rgw_bucket& bucket, rgw_obj& obj, string& tag, int64_t poolid, uint64_t epoch, uint64_t size,
                             utime_t& ut, string& etag, string& content_type, bufferlist *acl_bl, RGWObjCategory category,
                            list<string> *remove_objs);
-  int complete_update_index_del(rgw_bucket& bucket, string& oid, string& tag, int64_t pool, uint64_t epoch) {
+  int complete_update_index_del(rgw_bucket& bucket, rgw_obj& obj, string& tag, int64_t pool, uint64_t epoch) {
     if (bucket_is_system(bucket))
       return 0;
 
-    return cls_obj_complete_del(bucket, tag, pool, epoch, oid);
+    return cls_obj_complete_del(bucket, tag, pool, epoch, obj);
   }
-  int complete_update_index_cancel(rgw_bucket& bucket, string& oid, string& tag) {
+  int complete_update_index_cancel(rgw_bucket& bucket, rgw_obj& obj, string& tag) {
     if (bucket_is_system(bucket))
       return 0;
 
-    return cls_obj_complete_cancel(bucket, tag, oid);
+    return cls_obj_complete_cancel(bucket, tag, obj);
   }
   int list_bi_log_entries(rgw_bucket& bucket, string& marker, uint32_t max, std::list<rgw_bi_log_entry>& result, bool *truncated);
   int trim_bi_log_entries(rgw_bucket& bucket, string& marker, string& end_marker);
index 8801e4569cbf81bbd8c7c456377e7e809a6b9923..6ec44eae339cdca37fa8d4c99c2e908ddf547ba1 100644 (file)
@@ -382,7 +382,7 @@ static void add_grants_headers(map<int, string>& grants, map<string, string, lts
 
 int RGWRESTStreamWriteRequest::put_obj_init(RGWAccessKey& key, rgw_obj& obj, uint64_t obj_size, map<string, bufferlist>& attrs)
 {
-  string resource = obj.bucket.name + "/" + obj.object;
+  string resource = obj.bucket.name + "/" + obj.get_object();
   string new_url = url;
   if (new_url[new_url.size() - 1] != '/')
     new_url.append("/");
@@ -544,7 +544,7 @@ int RGWRESTStreamReadRequest::get_obj(RGWAccessKey& key, map<string, string>& ex
 {
   string urlsafe_bucket, urlsafe_object;
   url_encode(obj.bucket.name, urlsafe_bucket);
-  url_encode(obj.object, urlsafe_object);
+  url_encode(obj.get_object(), urlsafe_object);
   string resource = urlsafe_bucket + "/" + urlsafe_object;
   string new_url = url;
   if (new_url[new_url.size() - 1] != '/')