From: Abhishek Lekshmanan Date: Mon, 19 Aug 2019 10:50:37 +0000 (+0200) Subject: rgw: move rgw_init_ioctx() to rgw_tools.cc X-Git-Tag: v14.2.3~17^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=49bbc189fc46b17270ae16e883a6a67398f0be0b;p=ceph.git rgw: move rgw_init_ioctx() to rgw_tools.cc move rgw_init_ioctx() out of rgw_rados.cc so that it doesn't need to be duplicated by services/svc_rados.cc Signed-off-by: Casey Bodley (cherry picked from commit 1cf90269057ed18636879edef28b6e038352e335) Conflicts: src/rgw/rgw_gc.cc include conflicts with scope_guard, added rgw_tools include as well which introduces rgw_init_ioctx --- diff --git a/src/rgw/rgw_gc.cc b/src/rgw/rgw_gc.cc index 8167c8e7af44..0e796f99a75d 100644 --- a/src/rgw/rgw_gc.cc +++ b/src/rgw/rgw_gc.cc @@ -4,6 +4,7 @@ #include "rgw_gc.h" #include "include/scope_guard.h" +#include "rgw_tools.h" #include "include/rados/librados.hpp" #include "cls/rgw/cls_rgw_client.h" #include "cls/refcount/cls_refcount_client.h" diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 8e47d0f9ea2d..630fd224f6ac 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -158,41 +158,6 @@ rgw_raw_obj rgw_obj_select::get_raw_obj(RGWRados *store) const return raw_obj; } -int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, IoCtx& ioctx, bool create) -{ - 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; - } - - r = rados->ioctx_create(pool.name.c_str(), ioctx); - if (r < 0) { - return r; - } - - r = ioctx.application_enable(pg_pool_t::APPLICATION_NAME_RGW, false); - if (r < 0 && r != -EOPNOTSUPP) { - return r; - } - } else if (r < 0) { - return r; - } - if (!pool.ns.empty()) { - ioctx.set_namespace(pool.ns); - } - return 0; -} - void RGWObjVersionTracker::prepare_op_for_read(ObjectReadOperation *op) { obj_version *check_objv = version_for_check(); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 22319caaebf9..2871f69df889 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -119,8 +119,6 @@ static inline void get_obj_bucket_and_oid_loc(const rgw_obj& obj, string& oid, s } } -int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, librados::IoCtx& ioctx, bool create = false); - int rgw_policy_from_attrset(CephContext *cct, map& attrset, RGWAccessControlPolicy *policy); static inline bool rgw_raw_obj_to_obj(const rgw_bucket& bucket, const rgw_raw_obj& raw_obj, rgw_obj *obj) diff --git a/src/rgw/rgw_realm_watcher.cc b/src/rgw/rgw_realm_watcher.cc index 6ad38c6e40ac..02e8b130e27f 100644 --- a/src/rgw/rgw_realm_watcher.cc +++ b/src/rgw/rgw_realm_watcher.cc @@ -4,7 +4,7 @@ #include "common/errno.h" #include "rgw_realm_watcher.h" -#include "rgw_rados.h" +#include "rgw_tools.h" #include "rgw_zone.h" #define dout_subsys ceph_subsys_rgw diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 11645dabb397..5b931825f348 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -19,6 +19,7 @@ #include "rgw_aio_throttle.h" #include "rgw_compression.h" #include "rgw_zone.h" +#include "osd/osd_types.h" #include "services/svc_sys_obj.h" #include "services/svc_zone_utils.h" @@ -30,6 +31,42 @@ static std::map* ext_mime_map; +int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, + librados::IoCtx& ioctx, bool create) +{ + 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; + } + + r = rados->ioctx_create(pool.name.c_str(), ioctx); + if (r < 0) { + return r; + } + + r = ioctx.application_enable(pg_pool_t::APPLICATION_NAME_RGW, false); + if (r < 0 && r != -EOPNOTSUPP) { + return r; + } + } else if (r < 0) { + return r; + } + if (!pool.ns.empty()) { + ioctx.set_namespace(pool.ns); + } + return 0; +} + int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive, RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs) { diff --git a/src/rgw/rgw_tools.h b/src/rgw/rgw_tools.h index b77e99c4f679..e30f80868a65 100644 --- a/src/rgw/rgw_tools.h +++ b/src/rgw/rgw_tools.h @@ -17,6 +17,9 @@ class optional_yield; struct obj_version; +int rgw_init_ioctx(librados::Rados *rados, const rgw_pool& pool, + librados::IoCtx& ioctx, bool create = false); + int rgw_put_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string& oid, bufferlist& data, bool exclusive, RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs = NULL); int rgw_get_system_obj(RGWRados *rgwstore, RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl, diff --git a/src/rgw/services/svc_rados.cc b/src/rgw/services/svc_rados.cc index 30bf849f7ef3..408d25d9fdc9 100644 --- a/src/rgw/services/svc_rados.cc +++ b/src/rgw/services/svc_rados.cc @@ -7,41 +7,6 @@ #define dout_subsys ceph_subsys_rgw -static int init_ioctx(CephContext *cct, librados::Rados *rados, const rgw_pool& pool, librados::IoCtx& ioctx, bool create) -{ - 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) { - ldout(cct, 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; - } - - r = rados->ioctx_create(pool.name.c_str(), ioctx); - if (r < 0) { - return r; - } - - r = ioctx.application_enable(pg_pool_t::APPLICATION_NAME_RGW, false); - if (r < 0 && r != -EOPNOTSUPP) { - return r; - } - } else if (r < 0) { - return r; - } - if (!pool.ns.empty()) { - ioctx.set_namespace(pool.ns); - } - return 0; -} - int RGWSI_RADOS::do_start() { int ret = rados.init_with_context(cct); @@ -68,7 +33,7 @@ uint64_t RGWSI_RADOS::instance_id() int RGWSI_RADOS::open_pool_ctx(const rgw_pool& pool, librados::IoCtx& io_ctx) { constexpr bool create = true; // create the pool if it doesn't exist - return init_ioctx(cct, get_rados_handle(), pool, io_ctx, create); + return rgw_init_ioctx(get_rados_handle(), pool, io_ctx, create); } int RGWSI_RADOS::pool_iterate(librados::IoCtx& io_ctx,