]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove meta file after deleting bucket The meta file is deleted only if the...
authorOrit Wasserman <owasserm@redhat.com>
Fri, 3 Apr 2015 11:43:31 +0000 (13:43 +0200)
committerKen Dreyer <kdreyer@redhat.com>
Wed, 10 Jun 2015 01:10:55 +0000 (19:10 -0600)
Signed-off-by: Orit Wasserman <owasserm@redhat.com>
Fixes: #11149
Backport: hammer, firefly
(cherry picked from commit dfdc7afb59cc8e32cf8bff55faa09076c853de06)

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

index 62d44aad669319179b509033cdb8dc56d5409c8a..8993d12daf4ef47666726482e5abcd1b28cd0f5a 100644 (file)
@@ -3502,6 +3502,31 @@ int RGWRados::copy_obj_data(void *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
@@ -3541,6 +3566,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 9aefe1efee98ec796c121154eb61fd4af3a1f78f..23c28e5a8c81997b0fac49eac3b3e98091708b98 100644 (file)
@@ -1588,6 +1588,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);