]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: wire up RGWLibFrontend enqueue and exec operations
authorMatt Benjamin <mbenjamin@redhat.com>
Fri, 2 Oct 2015 21:51:22 +0000 (17:51 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:04:35 +0000 (12:04 -0500)
Adds the missing bits of RGWLibProcess and RGWLibFrontend, and
calls them from rgw_readdir().

Clients can call enqueue_req() to route a request through the
work queue, or execute_req() to run it inline.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/rgw/librgw.cc
src/rgw/rgw_file.cc
src/rgw/rgw_lib.h

index 112719d6864a62ddcb5d2ce69a7c97187aae5928..cb663c216f847d439b56461519dbce868a4c0bad 100644 (file)
@@ -101,34 +101,6 @@ int RGWLibRequestEnv::sign(RGWAccessKey& access_key)
 }
 #endif /* 0 */
 
-class RGWLibFrontend : public RGWProcessFrontend {
-public:
-  RGWLibFrontend(RGWProcessEnv& pe, RGWFrontendConfig *_conf)
-    : RGWProcessFrontend(pe, _conf) {}
-  int init();
-}; /* RGWLibFrontend */
-
-class RGWLibProcess : public RGWProcess {
-    RGWAccessKey access_key;
-public:
-  RGWLibProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
-               RGWFrontendConfig* _conf) :
-    RGWProcess(cct, pe, num_threads, _conf) {}
-  void run();
-  void checkpoint();
-
-  void enqueue_req(RGWLibRequest* req) {
-    dout(10) << __func__ << " enqueue request req=" << hex << req << dec
-            << dendl;
-
-    req_throttle.get(1);
-    req_wq.queue(req);
-  } /* enqueue_req */
-
-  void handle_request(RGWRequest* req);
-  void set_access_key(RGWAccessKey& key) { access_key = key; }
-}; /* RGWLibProcess */
-
 void RGWLibProcess::checkpoint()
 {
     m_tp.drain(&req_wq);
index 1c2fd83c27ef7daf7cf9e6d25697c58496bf254a..e7c3de5abafaff77a40c8e2b8ca6c751a88ae498 100644 (file)
@@ -308,6 +308,7 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
   if (is_root(uri)) {
     /* for now, root always contains one user's bucket namespace */
     RGWListBucketsRequest req(cct, rgw_fs->user_id, rcb, cb_arg, offset);
+    (void) librgw.get_fe()->execute_req(&req);
   } else {
     /*
       RGWListBucketRequest req(cct, rgw_fs->user_id, uri, rcb, cb_arg, offset);
index 0462828279459ef6e7ced21107f781d64bf4a33a..c1e49410f4196bd8d5cbda75371085abdcd63a89 100644 (file)
@@ -8,6 +8,7 @@
 #include "rgw_client_io.h"
 #include "rgw_rest.h"
 #include "rgw_request.h"
+#include "rgw_frontend.h"
 #include "rgw_process.h"
 #include "rgw_rest_s3.h" // RGW_Auth_S3
 
@@ -32,6 +33,8 @@ public:
 
   RGWRados* get_store() { return store; }
 
+  RGWLibFrontend* get_fe() { return fe; }
+
   int init();
   int init(vector<const char *>& args);
   int stop();
@@ -146,4 +149,44 @@ public:
 
 }; /* RGWLibRequest */
 
+class RGWLibProcess : public RGWProcess {
+    RGWAccessKey access_key;
+public:
+  RGWLibProcess(CephContext* cct, RGWProcessEnv* pe, int num_threads,
+               RGWFrontendConfig* _conf) :
+    RGWProcess(cct, pe, num_threads, _conf) {}
+
+  void run();
+  void checkpoint();
+
+  void enqueue_req(RGWLibRequest* req) {
+
+    lsubdout(g_ceph_context, rgw, 10)
+      << __func__ << " enqueue request req=" << hex << req << dec << dendl;
+
+    req_throttle.get(1);
+    req_wq.queue(req);
+  } /* enqueue_req */
+
+  void handle_request(RGWRequest* req);
+  void set_access_key(RGWAccessKey& key) { access_key = key; }
+}; /* RGWLibProcess */
+
+class RGWLibFrontend : public RGWProcessFrontend {
+public:
+  RGWLibFrontend(RGWProcessEnv& pe, RGWFrontendConfig *_conf)
+    : RGWProcessFrontend(pe, _conf) {}
+
+  int init();
+
+  inline void enqueue_req(RGWLibRequest* req) {
+    static_cast<RGWLibProcess*>(pprocess)->enqueue_req(req); // async
+  }
+
+  inline void execute_req(RGWLibRequest* req) {
+    static_cast<RGWLibProcess*>(pprocess)->handle_request(req); // !async
+  }
+
+}; /* RGWLibFrontend */
+
 #endif /* RGW_LIB_H */