]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/admin_socket: pass input bufferlist
authorSage Weil <sage@redhat.com>
Mon, 9 Sep 2019 19:52:01 +0000 (14:52 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Oct 2019 21:30:53 +0000 (16:30 -0500)
Pass this to the async handler only for now, since the sync implementations
don't currently use it.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/admin_socket.cc
src/common/admin_socket.h
src/osd/OSD.cc
src/osd/OSD.h

index e30451821cc4ea71999a67e50a000fffa6f31865..63652dc6ee9f44245ac2b19add4cf10e698d7118 100644 (file)
@@ -357,8 +357,10 @@ bool AdminSocket::do_accept()
   ceph::mutex mylock = ceph::make_mutex("admin_socket::do_accept::mylock");
   ceph::condition_variable mycond;
   C_SafeCond fin(mylock, mycond, &done, &rval);
+  bufferlist empty;
   execute_command(
     cmdvec,
+    empty /* inbl */,
     [&rs, &out, &fin](int r, const std::string& err, bufferlist& outbl) {
       rs = err;
       out.claim(outbl);
@@ -407,6 +409,7 @@ void AdminSocket::do_tell_queue()
     bufferlist outbl;
     execute_command(
       m->cmd,
+      m->get_data(),
       [m](int r, const std::string& err, bufferlist& outbl) {
        auto reply = new MCommandReply(r, err);
        reply->set_tid(m->get_tid());
@@ -418,6 +421,7 @@ void AdminSocket::do_tell_queue()
 
 void AdminSocket::execute_command(
   const std::vector<std::string>& cmdvec,
+  const bufferlist& inbl,
   std::function<void(int,const std::string&,bufferlist&)> on_finish)
 {
   cmdmap_t cmdmap;
@@ -460,7 +464,7 @@ void AdminSocket::execute_command(
   if (!validate(prefix, cmdmap, empty)) {
     on_finish(-EINVAL, "invalid command json", empty);
   } else {
-    hook->call_async(prefix, cmdmap, format, on_finish);
+    hook->call_async(prefix, cmdmap, format, inbl, on_finish);
   }
   l.lock();
   in_hook = false;
index e64fc4fe28db7982091b031cca13153772499646..b6e634768d1526de68d418996b395d5c3528414a 100644 (file)
@@ -35,12 +35,15 @@ inline constexpr auto CEPH_ADMIN_SOCK_VERSION = "2"sv;
 
 class AdminSocketHook {
 public:
+  // NOTE: the sync handler doesn't take an input buffer currently because
+  // no users need it yet.
   virtual int call(std::string_view command, const cmdmap_t& cmdmap,
                   std::string_view format, ceph::buffer::list& out) = 0;
   virtual void call_async(
     std::string_view command,
     const cmdmap_t& cmdmap,
     std::string_view format,
+    const bufferlist& inbl,
     std::function<void(int,const std::string&,bufferlist&)> on_finish) {
     // by default, call the synchronous handler and then finish
     bufferlist out;
@@ -95,6 +98,7 @@ public:
   void chmod(mode_t mode);
   void execute_command(
     const std::vector<std::string>& cmd,
+    const bufferlist& inbl,
     std::function<void(int,const std::string&,bufferlist&)> on_fin);
 
   void queue_tell_command(ref_t<MCommand> m);
index 132b3ec8c27c60c9aaa53be3e6815d699c2a377d..ad0471e77dd68fff23d088e8d53ac7029518ec25 100644 (file)
@@ -2338,10 +2338,11 @@ public:
     std::string_view prefix,
     const cmdmap_t& cmdmap,
     std::string_view format,
+    const bufferlist& inbl,
     std::function<void(int,const std::string&,bufferlist&)> on_finish) override {
     stringstream ss;
     try {
-      osd->asok_command(prefix, cmdmap, format, on_finish);
+      osd->asok_command(prefix, cmdmap, format, inbl, on_finish);
     } catch (const bad_cmd_get& e) {
       bufferlist empty;
       on_finish(-EINVAL, e.what(), empty);
@@ -2363,6 +2364,7 @@ std::set<int64_t> OSD::get_mapped_pools()
 void OSD::asok_command(
   std::string_view prefix, const cmdmap_t& cmdmap,
   std::string_view format,
+  const bufferlist& inbl,
   std::function<void(int,const std::string&,bufferlist&)> on_finish)
 {
   int ret = 0;
index 85758fe09708476508b36c237cf1ecb089dad3ca..010612947ba564ab330a0bf0fbb8c9bf04a4f111 100644 (file)
@@ -1180,6 +1180,7 @@ protected:
     std::string_view prefix,
     const cmdmap_t& cmdmap,
     std::string_view format,
+    const bufferlist& inbl,
     std::function<void(int,const std::string&,bufferlist&)> on_finish);
 
 public: