]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: incremental
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 30 Sep 2015 21:34:50 +0000 (17:34 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 16:58:10 +0000 (11:58 -0500)
* move RGWLibRequest decls into rgw_file.h
* revise include guard token in rados/rgw_file.h (avoid conflict)
* save CephContext* in RGWLibRequest
* initialize RGWLibRequest cct in ctor, req_state in process_request

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/include/rados/rgw_file.h
src/rgw/librgw.cc
src/rgw/rgw_file.cc
src/rgw/rgw_file.h [new file with mode: 0644]
src/rgw/rgw_lib.h

index 7a830bfc8d9864f571b08d01f5607f8031982bba..18f7def36bb4f0a2191a3e0cc00dd69fc4caf958 100644 (file)
@@ -11,8 +11,8 @@
  * Foundation.  See file COPYING.
  *
  */
-#ifndef RGW_FILE_H
-#define RGW_FILE_H
+#ifndef RADOS_RGW_FILE_H
+#define RADOS_RGW_FILE_H
 
 #include <sys/types.h>
 #include <stdint.h>
@@ -215,4 +215,4 @@ int rgw_perm2acl();
 }
 #endif
 
-#endif
+#endif /* RADOS_RGW_FILE_H */
index 8ef60f4a3e41987eba09f37584bc2131bdea5ae0..20bc04bcab0b44a7776216f0f9259fb37c507576 100644 (file)
@@ -378,7 +378,7 @@ int process_request(RGWRados* store, RGWREST* rest, RGWRequest* base_req,
 
   RGWLibRequest *req = static_cast<RGWLibRequest*>(base_req);
 
-  io->init(g_ceph_context); // XXXX fix me--we have a local cct
+  io->init(req->cct);
 
   req->log_init();
 
@@ -390,10 +390,11 @@ int process_request(RGWRados* store, RGWREST* rest, RGWRequest* base_req,
 
   RGWEnv& rgw_env = io->get_env();
 
-  // XXXX fix me--we have a local cct
-  struct req_state rstate(g_ceph_context, &rgw_env);
+  struct req_state rstate(req->cct, &rgw_env);
   struct req_state *s = &rstate;
 
+  req->init_state(s);
+
   RGWObjectCtx rados_ctx(store, s);
   s->obj_ctx = &rados_ctx;
 
index 640cf20c633fd19cad394c0864a76103e103d828..80edd4dbbe9c64d97bd773ee9b34c03a07df07d1 100644 (file)
@@ -20,8 +20,7 @@
 #include "rgw_user.h"
 #include "rgw_bucket.h"
 
-#include "rgw_lib.h"
-
+#include "rgw_file.h"
 
 #define dout_subsys ceph_subsys_rgw
 
@@ -285,30 +284,6 @@ int rgw_close(struct rgw_fs *rgw_fs,
   return 0;
 }
 
-/*
-  read directory content
-*/
-class RGWListBucketsRequest : public RGWLibRequest,
-                             public RGWListBuckets_ObjStore_Lib /* RGWOp */
-{
-public:
-  uint64_t offset;
-  void* cb_arg;
-  rgw_readdir_cb rcb;
-
-  RGWListBucketsRequest(uint64_t _req_id,
-                       rgw_readdir_cb _rcb, void* _cb_arg, uint64_t _offset)
-    : RGWLibRequest(_req_id), offset(_offset), cb_arg(_cb_arg), rcb(_rcb) {
-    // req->op = op
-    op = this;
-  }
-
-  void operator()(const std::string& name, const std::string& marker) {
-    (void) rcb(name.c_str(), cb_arg, offset++);
-  }
-
-}; /* RGWListBucketsRequest */
-
 int rgw_readdir(struct rgw_fs *rgw_fs,
                const struct rgw_file_handle *parent_handle, uint64_t *offset,
                rgw_readdir_cb rcb, void *cb_arg, bool *eof)
@@ -322,11 +297,12 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
   }
 
   CephContext* cct = static_cast<CephContext*>(rgw_fs->rgw);
-  RGWRados* store = librgw.get_store();
 
 #if 1
-  /* TODO: get required req_id &c, and put a RGWListBucketsRequest -or-
-   * RGWListBucketRequest on the stack */
+  /* TODO:
+   * take actual, um, arguments
+   */
+  RGWListBucketsRequest req(cct, rcb, cb_arg, offset);
 
 #else
   /* XXX current open-coded logic should move into librgw (need
diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h
new file mode 100644 (file)
index 0000000..7cc0ee4
--- /dev/null
@@ -0,0 +1,35 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef RGW_FILE_H
+#define RGW_FILE_H
+
+/* internal header */
+
+/*
+  read directory content
+*/
+class RGWListBucketsRequest : public RGWLibRequest,
+                             public RGWListBuckets_ObjStore_Lib /* RGWOp */
+{
+public:
+  uint64_t* offset;
+  void* cb_arg;
+  rgw_readdir_cb rcb;
+
+  RGWListBucketsRequest(CephContext* _cct, rgw_readdir_cb _rcb, void* _cb_arg,
+                       uint64_t* _offset)
+    : RGWLibRequest(_cct), offset(_offset), cb_arg(_cb_arg), rcb(_rcb) {
+    // req->op = op
+    op = this;
+  }
+
+  virtual bool only_bucket() { return false; }
+
+  int operator()(const std::string& name, const std::string& marker) {
+    (void) rcb(name.c_str(), cb_arg, (*offset)++);
+  }
+
+}; /* RGWListBucketsRequest */
+
+#endif /* RGW_FILE_H */
index 73c5127ce9966ddfa21778b4a47b6c7a914ce1ab..facb559208b556cea1e35d504d232897bab8de55 100644 (file)
@@ -121,17 +121,12 @@ public:
 }; /* RGWLibIO */
 
 class RGWLibRequest : public RGWRequest {
-private:
-  struct req_state* s;
-
 public:
-  RGWLibRequest(uint64_t req_id)
-    :  RGWRequest(req_id), s(nullptr)
-    {}
+  CephContext* cct;
 
-  void set_state(req_state* _s) {
-    s = _s;
-  }
+  RGWLibRequest(CephContext* _cct)
+    :  RGWRequest(0), cct(_cct)
+    {}
 
   virtual bool only_bucket() = 0;