]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove meta file after deleting bucket 4641/head
authorOrit Wasserman <owasserm@redhat.com>
Fri, 3 Apr 2015 11:43:31 +0000 (13:43 +0200)
committerNathan Cutler <ncutler@suse.cz>
Sun, 10 May 2015 16:54:30 +0000 (18:54 +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
(cherry picked from commit dfdc7afb59cc8e32cf8bff55faa09076c853de06)

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

index 0fbdf407544ec3baa7faa613a2c09a2410e9a7c8..32e545fa4b3076230ae9d8e75c1b17454daeb050 100644 (file)
@@ -3523,6 +3523,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
@@ -3562,6 +3587,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 ff161b837a76a74e15b871c7c654065b50a89d65..8bb32ab6265190cf833413b5d9e96a1304ac9842 100644 (file)
@@ -1590,6 +1590,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);