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: v13.1.0~115^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=02f64e7f8b18146d093978045d2f8ae04dd7e18e;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 --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 0fb6bdab765c..016ced764eb8 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -181,6 +181,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; } @@ -4878,28 +4886,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, @@ -5936,32 +5926,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)