From: Casey Bodley Date: Thu, 19 Apr 2018 18:45:29 +0000 (-0400) Subject: rgw: move all pool creation into rgw_init_ioctx X-Git-Tag: v12.2.6~126^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=130d3c431e77ec658f16f7cd5fb431968b20855d;p=ceph.git rgw: move all pool creation into rgw_init_ioctx the pool_create/application_enable logic was duplicated in three places, and only one of them was reporting the error on ERANGE Fixes: http://tracker.ceph.com/issues/23480 Signed-off-by: Casey Bodley (cherry picked from commit 02f64e7f8b18146d093978045d2f8ae04dd7e18e) --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index fd30c347b99..09738008494 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -170,6 +170,14 @@ int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, IoCtx& ioctx, b int r = rados->ioctx_create(pool.name.c_str(), ioctx); if (r == -ENOENT && create) { r = rados->pool_create(pool.name.c_str()); + if (r == -ERANGE) { + dout(0) + << __func__ + << " ERROR: librados::Rados::pool_create returned " << cpp_strerror(-r) + << " (this can be due to a pool or placement group misconfiguration, e.g." + << " pg_num < pgp_num or mon_max_pg_per_osd exceeded)" + << dendl; + } if (r < 0 && r != -EEXIST) { return r; } @@ -4861,28 +4869,10 @@ void RGWRados::pick_control_oid(const string& key, string& notify_oid) notify_oid.append(buf); } -int RGWRados::open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx) +int RGWRados::open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx) { - librados::Rados *rad = get_rados_handle(); - int r = rgw_init_ioctx(rad, pool, io_ctx); - if (r != -ENOENT) - return r; - - if (!pools_initialized) - return r; - - r = rad->pool_create(pool.name.c_str()); - if (r < 0 && r != -EEXIST) - return r; - - r = rgw_init_ioctx(rad, pool, io_ctx); - if (r < 0) - return r; - - r = io_ctx.application_enable(pg_pool_t::APPLICATION_NAME_RGW, false); - if (r < 0 && r != -EOPNOTSUPP) - return r; - return 0; + constexpr bool create = true; // create the pool if it doesn't exist + return rgw_init_ioctx(get_rados_handle(), pool, io_ctx, create); } void RGWRados::build_bucket_index_marker(const string& shard_id_str, const string& shard_marker, @@ -5767,32 +5757,9 @@ done: */ int RGWRados::create_pool(const rgw_pool& pool) { - int ret = 0; - - librados::Rados *rad = get_rados_handle(); - ret = rad->pool_create(pool.name.c_str(), 0); - if (ret == -EEXIST) - ret = 0; - else if (ret == -ERANGE) { - ldout(cct, 0) - << __func__ - << " ERROR: librados::Rados::pool_create returned " << cpp_strerror(-ret) - << " (this can be due to a pool or placement group misconfiguration, e.g." - << " pg_num < pgp_num or mon_max_pg_per_osd exceeded)" - << dendl; - } - if (ret < 0) - return ret; - librados::IoCtx io_ctx; - ret = rad->ioctx_create(pool.name.c_str(), io_ctx); - if (ret < 0) - return ret; - - ret = io_ctx.application_enable(pg_pool_t::APPLICATION_NAME_RGW, false); - if (ret < 0 && ret != -EOPNOTSUPP) - return ret; - return 0; + constexpr bool create = true; + return rgw_init_ioctx(get_rados_handle(), pool, io_ctx, create); } int RGWRados::init_bucket_index(RGWBucketInfo& bucket_info, int num_shards)