]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
radosgw: tolerate race creating .rgw* metadata pools
authorSage Weil <sage@newdream.net>
Tue, 27 Sep 2011 04:35:52 +0000 (21:35 -0700)
committerSage Weil <sage@newdream.net>
Tue, 27 Sep 2011 04:47:42 +0000 (21:47 -0700)
There may be multiple people trying to create these pools.  That's just
fine.

Signed-off-by: Sage Weil <sage@newdream.net>
src/rgw/rgw_rados.cc

index 404bddb33fb8e4b1f0f70d06bfca67ddf8abaa5f..c66889a220b7f62521a4684f0d0a4b71aa15de31 100644 (file)
@@ -76,6 +76,8 @@ int RGWRados::open_root_pool_ctx()
   int r = rados->ioctx_create(RGW_ROOT_BUCKET, root_pool_ctx);
   if (r == -ENOENT) {
     r = rados->pool_create(RGW_ROOT_BUCKET);
+    if (r == -EEXIST)
+      r = 0;
     if (r < 0)
       return r;
 
@@ -90,6 +92,8 @@ int RGWRados::init_watch()
   int r = rados->ioctx_create(RGW_CONTROL_BUCKET, control_pool_ctx);
   if (r == -ENOENT) {
     r = rados->pool_create(RGW_CONTROL_BUCKET);
+    if (r == -EEXIST)
+      r = 0;
     if (r < 0)
       return r;
 
@@ -311,7 +315,9 @@ int RGWRados::list_objects(string& id, rgw_bucket& bucket, int max, string& pref
  * if auid is set, it sets the auid of the underlying rados io_ctx
  * returns 0 on success, -ERR# otherwise.
  */
-int RGWRados::create_bucket(std::string& id, rgw_bucket& bucket, map<std::string, bufferlist>& attrs, bool create_pool, bool exclusive, uint64_t auid)
+int RGWRados::create_bucket(std::string& id, rgw_bucket& bucket, 
+                           map<std::string, bufferlist>& attrs, 
+                           bool create_pool, bool exclusive, uint64_t auid)
 {
   librados::ObjectWriteOperation op;
   op.create(exclusive);
@@ -326,6 +332,8 @@ int RGWRados::create_bucket(std::string& id, rgw_bucket& bucket, map<std::string
 
   if (create_pool) {
     ret = rados->pool_create(bucket.pool.c_str(), auid);
+    if (ret == -EEXIST)
+      ret = 0;
     if (ret < 0)
       root_pool_ctx.remove(bucket.name.c_str());
   }