]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move rgw_init_ioctx() to rgw_tools.cc
authorAbhishek Lekshmanan <abhishek@suse.com>
Mon, 19 Aug 2019 10:50:37 +0000 (12:50 +0200)
committerAbhishek Lekshmanan <abhishek@suse.com>
Mon, 19 Aug 2019 10:50:37 +0000 (12:50 +0200)
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 <cbodley@redhat.com>
(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

src/rgw/rgw_gc.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_realm_watcher.cc
src/rgw/rgw_tools.cc
src/rgw/rgw_tools.h
src/rgw/services/svc_rados.cc

index 8167c8e7af442ad377b910eb065c67b3b5a0221f..0e796f99a75d77aecd9aa1ccf4838d3d1d017260 100644 (file)
@@ -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"
index 8e47d0f9ea2db3d069ca586e24429911c18d4cfd..630fd224f6ace1fa7803d2fe7b7c7168532057c2 100644 (file)
@@ -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();
index 22319caaebf94ce53aa54c57026cee0c6f1e9423..2871f69df8898aab40a332eb4cba8ebc45f366ae 100644 (file)
@@ -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<string, bufferlist>& attrset, RGWAccessControlPolicy *policy);
 
 static inline bool rgw_raw_obj_to_obj(const rgw_bucket& bucket, const rgw_raw_obj& raw_obj, rgw_obj *obj)
index 6ad38c6e40ac0582c0b7b33f6eb57dd105c128b6..02e8b130e27f8c99f76e5b59facaa56eb4458f7f 100644 (file)
@@ -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
index 11645dabb397728c8eba454cb15878bb5602173a..5b931825f348cde8656ee7b7efa712e4f084983f 100644 (file)
@@ -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"
 
 static std::map<std::string, std::string>* 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<string, bufferlist> *pattrs)
 {
index b77e99c4f679a147cfc5915b8d2ab6004dc3da72..e30f80868a6582effbae159dc88fa9bb84c438cc 100644 (file)
@@ -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<string, bufferlist> *pattrs = NULL);
 int rgw_get_system_obj(RGWRados *rgwstore, RGWSysObjectCtx& obj_ctx, const rgw_pool& pool, const string& key, bufferlist& bl,
index 30bf849f7ef37261256145b696d0b30669433b0b..408d25d9fdc9f42e894a9f0e6b35a734beebf525 100644 (file)
@@ -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,