From: Matt Benjamin Date: Fri, 2 Oct 2015 21:51:22 +0000 (-0400) Subject: librgw: wire up RGWLibFrontend enqueue and exec operations X-Git-Tag: v10.1.0~382^2~224 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=143bd14fe8c538f296d4208e3c5be6ff83e5d5d0;p=ceph.git librgw: wire up RGWLibFrontend enqueue and exec operations 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 --- diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc index 112719d6864a..cb663c216f84 100644 --- a/src/rgw/librgw.cc +++ b/src/rgw/librgw.cc @@ -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); diff --git a/src/rgw/rgw_file.cc b/src/rgw/rgw_file.cc index 1c2fd83c27ef..e7c3de5abafa 100644 --- a/src/rgw/rgw_file.cc +++ b/src/rgw/rgw_file.cc @@ -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); diff --git a/src/rgw/rgw_lib.h b/src/rgw/rgw_lib.h index 046282827945..c1e49410f419 100644 --- a/src/rgw/rgw_lib.h +++ b/src/rgw/rgw_lib.h @@ -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& 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(pprocess)->enqueue_req(req); // async + } + + inline void execute_req(RGWLibRequest* req) { + static_cast(pprocess)->handle_request(req); // !async + } + +}; /* RGWLibFrontend */ + #endif /* RGW_LIB_H */