]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: added async application enable API
authorJason Dillaman <dillaman@redhat.com>
Wed, 21 Jun 2017 01:39:05 +0000 (21:39 -0400)
committerJason Dillaman <dillaman@redhat.com>
Wed, 19 Jul 2017 17:13:01 +0000 (13:13 -0400)
RGW has numerous pool creation calls, one of which utilizes
an async interface. This adds support for RGW's use-case.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/include/rados/librados.hpp
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/RadosClient.cc
src/librados/RadosClient.h
src/librados/librados.cc

index 830d3902650a3421eecbb037606980a4798bc5fb..f4cd777df036e15a3b34266c034ad6704516770b 100644 (file)
@@ -1251,6 +1251,8 @@ namespace librados
     void unset_osdmap_full_try();
 
     int application_enable(const std::string& app_name, bool force);
+    int application_enable_async(const std::string& app_name,
+                                 bool force, PoolAsyncCompletion *c);
     int application_list(std::set<std::string> *app_names);
     int application_metadata_get(const std::string& app_name,
                                  const std::string &key,
index d41b5a3d9cecd3f4c8a0fca0c95e56e6c4ffce84..2805ed8a03f24ab5c6ddfe5c8f0767f76f0cd770 100644 (file)
@@ -2082,12 +2082,32 @@ void librados::IoCtxImpl::object_list_slice(
 
 int librados::IoCtxImpl::application_enable(const std::string& app_name,
                                             bool force)
+{
+  auto c = new PoolAsyncCompletionImpl();
+  application_enable_async(app_name, force, c);
+
+  int r = c->wait();
+  assert(r == 0);
+
+  r = c->get_return_value();
+  c->release();
+  if (r < 0) {
+    return r;
+  }
+
+  return client->wait_for_latest_osdmap();
+}
+
+void librados::IoCtxImpl::application_enable_async(const std::string& app_name,
+                                                   bool force,
+                                                   PoolAsyncCompletionImpl *c)
 {
   // pre-Luminous clusters will return -EINVAL and application won't be
   // preserved until Luminous is configured as minimim version.
   if (!client->get_required_monitor_features().contains_all(
         ceph::features::mon::FEATURE_LUMINOUS)) {
-    return -EOPNOTSUPP;
+    client->finisher.queue(new C_PoolAsync_Safe(c), -EOPNOTSUPP);
+    return;
   }
 
   std::stringstream cmd;
@@ -2103,13 +2123,8 @@ int librados::IoCtxImpl::application_enable(const std::string& app_name,
   std::vector<std::string> cmds;
   cmds.push_back(cmd.str());
   bufferlist inbl;
-  int r = client->mon_command(cmds, inbl, nullptr, nullptr);
-  if (r < 0) {
-    return r;
-  }
-
-  // ensure we have the latest osd map epoch before proceeding
-  return client->wait_for_latest_osdmap();
+  client->mon_command_async(cmds, inbl, nullptr, nullptr,
+                            new C_PoolAsync_Safe(c));
 }
 
 int librados::IoCtxImpl::application_list(std::set<std::string> *app_names)
index eda0cf0c7ef4ddca5250dfe38bb1de8b33410464..b769fcd178cb821c9e1b5fe5aa985cfb7b9dbfdb 100644 (file)
@@ -283,6 +283,8 @@ struct librados::IoCtxImpl {
   int cache_unpin(const object_t& oid);
 
   int application_enable(const std::string& app_name, bool force);
+  void application_enable_async(const std::string& app_name, bool force,
+                                PoolAsyncCompletionImpl *c);
   int application_list(std::set<std::string> *app_names);
   int application_metadata_get(const std::string& app_name,
                                const std::string &key,
index 9bc45970e8dc98e3ec8585ae77979973d045b0d8..7131aa838acd413a646b298b5e63f61ad29801b6 100644 (file)
@@ -809,22 +809,21 @@ int librados::RadosClient::mon_command(const vector<string>& cmd,
                                       const bufferlist &inbl,
                                       bufferlist *outbl, string *outs)
 {
-  Mutex mylock("RadosClient::mon_command::mylock");
-  Cond cond;
-  bool done;
-  int rval;
+  C_SaferCond ctx;
+  mon_command_async(cmd, inbl, outbl, outs, &ctx);
+  return ctx.wait();
+}
+
+void librados::RadosClient::mon_command_async(const vector<string>& cmd,
+                                              const bufferlist &inbl,
+                                              bufferlist *outbl, string *outs,
+                                              Context *on_finish)
+{
   lock.Lock();
-  monclient.start_mon_command(cmd, inbl, outbl, outs,
-                              new C_SafeCond(&mylock, &cond, &done, &rval));
+  monclient.start_mon_command(cmd, inbl, outbl, outs, on_finish);
   lock.Unlock();
-  mylock.Lock();
-  while (!done)
-    cond.Wait(mylock);
-  mylock.Unlock();
-  return rval;
 }
 
-
 int librados::RadosClient::mgr_command(const vector<string>& cmd,
                                       const bufferlist &inbl,
                                       bufferlist *outbl, string *outs)
index cd3063d3e9cfac24eff58e262d86a38425d270b3..bff6ca33fce2b006bd0d63c275d643de238e0694 100644 (file)
@@ -27,6 +27,7 @@
 #include "IoCtxImpl.h"
 
 struct AuthAuthorizer;
+struct Context;
 class CephContext;
 struct Connection;
 struct md_config_t;
@@ -135,6 +136,8 @@ public:
 
   int mon_command(const vector<string>& cmd, const bufferlist &inbl,
                  bufferlist *outbl, string *outs);
+  void mon_command_async(const vector<string>& cmd, const bufferlist &inbl,
+                         bufferlist *outbl, string *outs, Context *on_finish);
   int mon_command(int rank,
                  const vector<string>& cmd, const bufferlist &inbl,
                  bufferlist *outbl, string *outs);
index ffe7fc2687c206a2b9f7854989bdb701272ec063..4609631d1c317228204a6c3edd079fcad4c1c56c 100644 (file)
@@ -6469,6 +6469,14 @@ int librados::IoCtx::application_enable(const std::string& app_name,
   return io_ctx_impl->application_enable(app_name, force);
 }
 
+int librados::IoCtx::application_enable_async(const std::string& app_name,
+                                              bool force,
+                                              PoolAsyncCompletion *c)
+{
+  io_ctx_impl->application_enable_async(app_name, force, c->pc);
+  return 0;
+}
+
 int librados::IoCtx::application_list(std::set<std::string> *app_names)
 {
   return io_ctx_impl->application_list(app_names);