]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: move objexp pool creation into separate function.
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Mon, 25 May 2015 12:28:01 +0000 (14:28 +0200)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 27 Aug 2015 17:39:53 +0000 (10:39 -0700)
Fixes: #4099
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 19bc923b1986c111f050e1971854493516c104c4..e58bbbdfefd1e3c12545cb6a44b1ea83c1fde563 100644 (file)
@@ -1615,6 +1615,10 @@ int RGWRados::init_complete()
   if (ret < 0)
     return ret;
 
+  ret = open_objexp_pool_ctx();
+  if (ret < 0)
+    return ret;
+
   pools_initialized = true;
 
   gc = new RGWGC();
@@ -1756,6 +1760,25 @@ int RGWRados::open_gc_pool_ctx()
   return r;
 }
 
+int RGWRados::open_objexp_pool_ctx()
+{
+  const char * const pool_name = zone.log_pool.name.c_str();
+  librados::Rados * const rad = get_rados_handle();
+  int r = rad->ioctx_create(pool_name, objexp_pool_ctx);
+  if (r == -ENOENT) {
+    r = rad->pool_create(pool_name);
+    if (r == -EEXIST) {
+      r = 0;
+    } else if (r < 0) {
+      return r;
+    }
+
+    r = rad->ioctx_create(pool_name, objexp_pool_ctx);
+  }
+
+  return r;
+}
+
 int RGWRados::init_watch()
 {
   const char *control_pool = zone.control_pool.name.c_str();
@@ -2338,24 +2361,6 @@ int RGWRados::objexp_hint_add(const utime_t& delete_at,
                               const string& bucket_id,
                               const rgw_obj_key& obj_key)
 {
-  librados::IoCtx io_ctx;
-
-  const char * const log_pool = zone.log_pool.name.c_str();
-  int r = rados->ioctx_create(log_pool, io_ctx);
-  if (r == -ENOENT) {
-    rgw_bucket pool(log_pool);
-    r = create_pool(pool);
-    if (r < 0) {
-      return r;
-    } else {
-      /* retry */
-      r = rados->ioctx_create(log_pool, io_ctx);
-    }
-  }
-  if (r < 0) {
-    return r;
-  }
-
   const string keyext = objexp_hint_get_keyext(bucket_name,
           bucket_id, obj_key);
   objexp_hint_entry he = {
@@ -2369,8 +2374,7 @@ int RGWRados::objexp_hint_add(const utime_t& delete_at,
   cls_timeindex_add(op, delete_at, keyext, hebl);
 
   string shard_name = objexp_hint_get_shardname(delete_at);
-  r = io_ctx.operate(shard_name, &op);
-  return r;
+  return objexp_pool_ctx.operate(shard_name, &op);
 }
 
 void  RGWRados::objexp_get_shard(const utime_t& start_time,
@@ -2415,26 +2419,18 @@ int RGWRados::objexp_hint_list(const string& oid,
                                string *out_marker,                 /* out */
                                bool *truncated)                    /* out */
 {
-  librados::IoCtx io_ctx;
-
-  const char * const log_pool = zone.log_pool.name.c_str();
-  int ret = rados->ioctx_create(log_pool, io_ctx);
-  if (ret < 0) {
-    return ret;
-  }
-
   librados::ObjectReadOperation op;
   cls_timeindex_list(op, start_time, end_time, marker, max_entries, entries,
               out_marker, truncated);
 
   bufferlist obl;
-  ret = io_ctx.operate(oid, &op, &obl);
+  int ret = objexp_pool_ctx.operate(oid, &op, &obl);
 
   if ((ret < 0 ) && (ret != -ENOENT)) {
     return ret;
   }
 
-  if (ret == -ENOENT && truncated) {
+  if ((ret == -ENOENT) && truncated) {
     *truncated = false;
   }
 
@@ -2460,15 +2456,7 @@ int RGWRados::objexp_hint_trim(const string& oid,
                                const string& from_marker,
                                const string& to_marker)
 {
-  librados::IoCtx io_ctx;
-
-  const char * const log_pool = zone.log_pool.name.c_str();
-  int ret = rados->ioctx_create(log_pool, io_ctx);
-  if (ret < 0) {
-    return ret;
-  }
-
-  ret = cls_timeindex_trim(io_ctx, oid, start_time, end_time,
+  int ret = cls_timeindex_trim(objexp_pool_ctx, oid, start_time, end_time,
           from_marker, to_marker);
   if ((ret < 0 ) && (ret != -ENOENT)) {
     return ret;
index 0ee187409d592329e8cb0e706ae1b56ca3b8acb9..68faada74bd281e8c7fbed07fcec004aab1e454b 100644 (file)
@@ -1204,6 +1204,7 @@ class RGWRados
   /** Open the pool used as root for this gateway */
   int open_root_pool_ctx();
   int open_gc_pool_ctx();
+  int open_objexp_pool_ctx();
 
   int open_bucket_pool_ctx(const string& bucket_name, const string& pool, librados::IoCtx&  io_ctx);
   int open_bucket_index_ctx(rgw_bucket& bucket, librados::IoCtx&  index_ctx);
@@ -1282,6 +1283,7 @@ protected:
   std::map<pthread_t, int> rados_map;
 
   librados::IoCtx gc_pool_ctx;        // .rgw.gc
+  librados::IoCtx objexp_pool_ctx;
 
   bool pools_initialized;