]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove meta file after deleting bucket 4283/head
authorOrit Wasserman <owasserm@redhat.com>
Fri, 3 Apr 2015 11:43:31 +0000 (13:43 +0200)
committerOrit Wasserman <owasserm@redhat.com>
Tue, 7 Apr 2015 08:35:51 +0000 (10:35 +0200)
The meta file is deleted only if the bucket meta data is not synced

Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Fixes: #11149
Backport: hammer, firefly

src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 5183747aff33b62292de14d4f438bd900a9f37cc..d7c312fce7d0fcc0d0507fef4c576ba7fa175175 100644 (file)
@@ -3922,6 +3922,31 @@ int RGWRados::copy_obj_data(RGWObjectCtx& obj_ctx,
   return ret;
 }
 
+/**
+  * Check to see if the bucket metadata could be synced
+  * bucket: the bucket to check
+  * Returns false is the bucket is not synced
+  */
+bool RGWRados::is_syncing_bucket_meta(rgw_bucket& bucket)
+{
+  /* region is not master region */
+  if (!region.is_master) {
+    return false;
+  }
+
+  /* single region and a single zone */
+  if (region_map.regions.size() == 1 && region.zones.size() == 1) {
+    return false;
+  }
+
+  /* zone is not master */
+  if (region.master_zone.compare(zone_name) != 0) {
+    return false;
+  }
+
+  return true;
+}
+  
 /**
  * Delete a bucket.
  * bucket: the name of the bucket to delete
@@ -3963,6 +3988,16 @@ int RGWRados::delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_track
   if (r < 0)
     return r;
 
+  /* if the bucked is not synced we can remove the meta file */
+  if (!is_syncing_bucket_meta(bucket)) {
+    RGWObjVersionTracker objv_tracker;
+    string entry;
+    get_bucket_instance_entry(bucket, entry);
+    r= rgw_bucket_instance_remove_entry(this, entry, &objv_tracker);
+    if (r < 0) {
+      return r;
+    }
+  }
   return 0;
 }
 
index a3fd6c09d73795e83229b5fd898b53c8e12ae85e..45b7f61c30fccf3730066f58cfd99e8113151d1f 100644 (file)
@@ -1787,6 +1787,11 @@ public:
    */
   virtual int delete_bucket(rgw_bucket& bucket, RGWObjVersionTracker& objv_tracker);
 
+  /**
+   * Check to see if the bucket metadata is synced
+   */
+  bool is_syncing_bucket_meta(rgw_bucket& bucket);
+  
   int set_bucket_owner(rgw_bucket& bucket, ACLOwner& owner);
   int set_buckets_enabled(std::vector<rgw_bucket>& buckets, bool enabled);
   int bucket_suspended(rgw_bucket& bucket, bool *suspended);