]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: check_disk_state() removes multipart parts from index
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 28 Nov 2012 00:35:48 +0000 (16:35 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 28 Nov 2012 21:52:44 +0000 (13:52 -0800)
Besides suggesting changes to the object's index, we also need
to remove the parts that build the object. This only applies to
parts of multipart objects.

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

index 40bae78d7280470a1b045895d4bca0b26c31f918..c84116815a7a11994648141265feeb9a5b7f5bf0 100644 (file)
@@ -26,8 +26,8 @@
 using namespace std;
 using ceph::crypto::MD5;
 
-static string mp_ns = "multipart";
-static string shadow_ns = "shadow";
+static string mp_ns = RGW_OBJ_NS_MULTIPART;
+static string shadow_ns = RGW_OBJ_NS_SHADOW;
 
 class MultipartMetaFilter : public RGWAccessListFilter {
 public:
index c09fffba4408ed5fe67ed39a1aaa63403842f23c..f877883c7ebaa3fd7cf06a9ed3b3b823762103bc 100644 (file)
@@ -1746,6 +1746,18 @@ int RGWRados::delete_obj(void *ctx, rgw_obj& obj)
   return r;
 }
 
+int RGWRados::delete_obj_index(rgw_obj& obj)
+{
+  rgw_bucket bucket;
+  std::string oid, key;
+  get_obj_bucket_and_oid_key(obj, bucket, oid, key);
+
+  string tag;
+  int r = complete_update_index_del(bucket, obj.object, tag, 0);
+
+  return r;
+}
+
 static void generate_fake_tag(CephContext *cct, map<string, bufferlist>& attrset, RGWObjManifest& manifest, bufferlist& manifest_bl, bufferlist& tag_bl)
 {
   string tag;
@@ -3254,6 +3266,24 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
     }
   }
 
+  if (astate->has_manifest) {
+    map<uint64_t, RGWObjManifestPart>::iterator miter;
+    RGWObjManifest& manifest = astate->manifest;
+    for (miter = manifest.objs.begin(); miter != manifest.objs.end(); ++miter) {
+      RGWObjManifestPart& part = miter->second;
+
+      rgw_obj& loc = part.loc;
+
+      if (loc.ns == RGW_OBJ_NS_MULTIPART) {
+       dout(10) << "check_disk_state(): removing manifest part from index: " << loc << dendl;
+       r = delete_obj_index(loc);
+       if (r < 0) {
+         dout(0) << "WARNING: delete_obj_index() returned r=" << r << dendl;
+       }
+      }
+    }
+  }
+
   object.etag = etag;
   object.content_type = content_type;
   object.owner = owner.get_id();
@@ -3271,7 +3301,6 @@ int RGWRados::check_disk_state(librados::IoCtx io_ctx,
   list_state.meta.owner = owner.get_id();
   list_state.meta.owner_display_name = owner.get_display_name();
 
-
   list_state.exists = true;
   cls_rgw_encode_suggestion(CEPH_RGW_UPDATE, list_state, suggested_updates);
   return 0;
index 0209977763fb2bbed38635e177c1d2113da6055b..50d8572f0819e66788102149069331e8b67664ed 100644 (file)
@@ -17,6 +17,9 @@ class RGWGC;
 #define PUT_OBJ_EXCL        0x02
 #define PUT_OBJ_CREATE_EXCL (PUT_OBJ_CREATE | PUT_OBJ_EXCL)
 
+#define RGW_OBJ_NS_MULTIPART "multipart"
+#define RGW_OBJ_NS_SHADOW    "shadow"
+
 static inline void prepend_bucket_marker(rgw_bucket& bucket, string& orig_oid, string& oid)
 {
   if (bucket.marker.empty() || orig_oid.empty()) {
@@ -555,6 +558,9 @@ public:
   /** Delete an object.*/
   virtual int delete_obj(void *ctx, rgw_obj& src_obj);
 
+  /** Remove an object from the bucket index */
+  int delete_obj_index(rgw_obj& obj);
+
   /**
    * Get the attributes for an object.
    * bucket: name of the bucket holding the object.