From dfdc7afb59cc8e32cf8bff55faa09076c853de06 Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Fri, 3 Apr 2015 13:43:31 +0200 Subject: [PATCH] rgw: remove meta file after deleting bucket The meta file is deleted only if the bucket meta data is not synced Signed-off-by: Orit Wasserman Fixes: #11149 Backport: hammer, firefly --- src/rgw/rgw_rados.cc | 35 +++++++++++++++++++++++++++++++++++ src/rgw/rgw_rados.h | 5 +++++ 2 files changed, 40 insertions(+) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 5183747aff3..d7c312fce7d 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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; } diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index a3fd6c09d73..45b7f61c30f 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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& buckets, bool enabled); int bucket_suspended(rgw_bucket& bucket, bool *suspended); -- 2.47.3