From: Yehuda Sadeh Date: Wed, 17 Jul 2013 23:34:50 +0000 (-0700) Subject: rgw: fix bucket re-creation on secondary region X-Git-Tag: v0.67-rc1~16^2~10 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f4bdbd5cb84bc84fd578d56fc3340ef4173b025;p=ceph.git 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 --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 067a1adbabde..308adff5ae93 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;