summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-07-17 16:34:50 -0700
committerGreg Farnum <greg@inktank.com>2013-07-19 13:21:49 -0700
commit4f4bdbd5cb84bc84fd578d56fc3340ef4173b025 (patch)
treeeeee7e74ea0b666edc170e7c19986ea3a183af89
parent0de708516c48907a548856d64d1657d2fc576e32 (diff)
downloadceph-4f4bdbd5cb84bc84fd578d56fc3340ef4173b025.tar.gz
rgw: fix bucket re-creation on secondary region
We had a problem with bucket recreation, where we identified that bucket has already existed, but missed the fact that it's the same bucket, so removal of the bucket index was wrong. Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_rados.cc34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index 067a1adbabd..308adff5ae9 100644
--- a/src/rgw/rgw_rados.cc
+++ b/src/rgw/rgw_rados.cc
@@ -1835,21 +1835,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
info.creation_time = creation_time;
ret = put_linked_bucket_info(info, exclusive, 0, &attrs, true);
if (ret == -EEXIST) {
- /* remove bucket meta instance */
- string entry;
- get_bucket_instance_entry(bucket, entry);
- r = rgw_bucket_instance_remove_entry(this, entry, &info.objv_tracker);
- if (r < 0)
- return r;
-
- /* remove bucket index */
- librados::IoCtx index_ctx; // context for new bucket
- int r = open_bucket_index_ctx(bucket, index_ctx);
- if (r < 0)
- return r;
-
- /* we need to reread the info and return it, caller will have a use for it */
- index_ctx.remove(dir_oid);
+ /* we need to reread the info and return it, caller will have a use for it */
r = get_bucket_info(NULL, bucket.name, info, NULL, NULL);
if (r < 0) {
if (r == -ENOENT) {
@@ -1858,6 +1844,24 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
ldout(cct, 0) << "get_bucket_info returned " << r << dendl;
return r;
}
+
+ /* only remove it if it's a different bucket instance */
+ if (info.bucket.bucket_id != bucket.bucket_id) {
+ /* remove bucket meta instance */
+ string entry;
+ get_bucket_instance_entry(bucket, entry);
+ r = rgw_bucket_instance_remove_entry(this, entry, &info.objv_tracker);
+ if (r < 0)
+ return r;
+
+ /* remove bucket index */
+ librados::IoCtx index_ctx; // context for new bucket
+ int r = open_bucket_index_ctx(bucket, index_ctx);
+ if (r < 0)
+ return r;
+
+ index_ctx.remove(dir_oid);
+ }
/* ret == -ENOENT here */
}
return ret;