]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: sequential rgw_write works
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 17 Dec 2015 19:54:26 +0000 (14:54 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:06:52 +0000 (12:06 -0500)
This commit finishes hooking up RGWWriteRequest, and its supporting
RGWLibContinuedRequest.

The rgw_read call now fails--trivially, because it never handled
starting offset correctly.

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

index 3fb7b88dcc2bf923cbdd8e1387cfabc5ce936fa6..40cf4562a1152d1a6b74b55f116100cf160d8d8c 100644 (file)
@@ -273,8 +273,6 @@ done:
 
 int RGWLibProcess::start_request(RGWLibContinuedReq* req)
 {
-  int ret = 0;
-  int op_ret = 0;
 
   dout(1) << "====== " << __func__
          << " starting new continued request req=" << hex << req << dec
@@ -294,21 +292,8 @@ int RGWLibProcess::start_request(RGWLibContinuedReq* req)
 
   struct req_state* s = req->get_state();
 
-  /* XXXX the below stanza can be completely internalized--req has
-   * all these objects */
-
-#if 0
-  /* XXX and -then- stash req_state pointers everywhere they are needed */
-  ret = req->init(rgw_env, &rados_ctx, io, s);
-  if (ret < 0) {
-    dout(10) << "failed to initialize request" << dendl;
-    abort_req(s, op, ret);
-    goto done;
-  }
-#endif
-
   /* req is-a RGWOp, currently initialized separately */
-  ret = req->op_init();
+  int ret = req->op_init();
   if (ret < 0) {
     dout(10) << "failed to initialize RGWOp" << dendl;
     abort_req(s, op, ret);
@@ -367,15 +352,27 @@ int RGWLibProcess::start_request(RGWLibContinuedReq* req)
   op->pre_exec();
   req->exec_start();
 
-  op_ret = op->get_ret();
-
 done:
   return (ret < 0 ? ret : s->err.ret);
 }
 
 int RGWLibProcess::finish_request(RGWLibContinuedReq* req)
 {
-  return 0;
+  RGWOp *op = (req->op) ? req->op : dynamic_cast<RGWOp*>(req);
+  if (! op) {
+    dout(1) << "failed to derive cognate RGWOp (invalid op?)" << dendl;
+    return -EINVAL;
+  }
+
+  int ret = req->exec_finish();
+  int op_ret = op->get_ret();
+
+  dout(1) << "====== " << __func__
+         << " finishing continued request req=" << hex << req << dec
+         << " op status=" << op_ret
+         << " ======" << dendl;
+
+  return ret;
 }
 
 int RGWLibFrontend::init()
index 137abb755fd4b7ff7514da0917018e4da9dc9235..7f3f20803b0ba370e99b8cd25aa4521af31985b9 100644 (file)
@@ -142,7 +142,8 @@ int RGWFileHandle::close()
   int rc = 0;
   file* f = get<file>(&variant_type);
   if (f && (f->write_req)) {
-    rc = librgw.get_fe()->finish_req(f->write_req);
+    rc = f->write_req->exec_finish();
+    // rc = librgw.get_fe()->finish_req(f->write_req); // XXX
     if (! rc) {
       rc = f->write_req->get_ret();
       if (! rc) {
index c6b2e2d7feb045a0cb4dfc40293b06a3526774fd..ef85a690596dc8be0e39ced3003cd35bcf66e8dc 100644 (file)
@@ -204,8 +204,8 @@ namespace rgw {
   public:
     RGWFileHandle(RGWLibFS* fs, uint32_t fs_inst, RGWFileHandle* _parent,
                  const fh_key& _fhk, std::string& _name, uint32_t _flags)
-      : bucket(nullptr), parent(_parent), name(std::move(_name)), fhk(_fhk),
-       flags(_flags) {
+      : refcnt(0), fs(fs), bucket(nullptr), parent(_parent),
+       name(std::move(_name)), fhk(_fhk), flags(_flags) {
 
       if (parent->is_root()) {
        fh.fh_type = RGW_FS_TYPE_DIRECTORY;
@@ -1472,6 +1472,12 @@ public:
     : RGWLibContinuedReq(_cct, _user), bucket_name(_bname), obj_name(_oname),
       rgw_fh(_fh), processor(nullptr), last_off(0), next_off(0),
       bytes_written(0), multipart(false) {
+
+    int ret = header_init();
+    if (ret == 0) {
+      ret = init_from_header(get_state());
+    }
+
     magic = 81;
     op = this;
   }
@@ -1540,7 +1546,7 @@ public:
   }
 
   void put_data(off_t off, buffer::list& _bl) {
-    next_off = off;
+    ofs = off;
     data.claim(_bl);
   }
 
index a139fc9cea65a7bee62d4eb552dbaeee2c3e5514..ad87b17fb89c2d636ed6709badf095c3a83fdc12 100644 (file)
@@ -46,7 +46,9 @@ class RGWLibIO : public RGWClientIO
 {
   RGWUserInfo user_info;
 public:
-  RGWLibIO() {}
+  RGWLibIO() {
+    get_env().set("HTTP_HOST", "");
+  }
   RGWLibIO(const RGWUserInfo &_user_info)
     : user_info(_user_info) {}
 
@@ -155,14 +157,26 @@ class RGWLibContinuedReq : public RGWLibRequest {
 public:
 
 RGWLibContinuedReq(CephContext* _cct, RGWUserInfo* _user)
-  :  RGWLibRequest(_cct, _user), rstate(_cct, &io_ctx.get_env(), _user),
-     rados_ctx(librgw.get_store(), &rstate)
+  :  RGWLibRequest(_cct, _user), io_ctx(),
+     rstate(_cct, &io_ctx.get_env(), _user), rados_ctx(librgw.get_store(),
+                                                      &rstate)
     {
       io_ctx.init(_cct);
 
-      /* XXX for now, use "";  could be a legit hostname, or, in future,
-       * perhaps a tenant (Yehuda) */
-      io_ctx.get_env().set("HTTP_HOST", "");
+      RGWRequest::init_state(&rstate);
+      RGWHandler::init(rados_ctx.store, &rstate, &io_ctx);
+
+      /* fixup _s->req */
+      get_state()->req = this;
+
+      log_init();
+
+      get_state()->obj_ctx = &rados_ctx;
+      get_state()->req_id = store->unique_id(id);
+      get_state()->trans_id = store->unique_trans_id(id);
+
+      log_format(get_state(), "initializing for trans_id = %s",
+                get_state()->trans_id.c_str());
     }
 
   inline RGWRados* get_store() { return store; }
index 0ab3fb481b8adc40678781fd728db42600578d08..b25af049509264fc83c3e2a95069153260cbddc0 100644 (file)
@@ -231,7 +231,7 @@ TEST(LibRGW, GET_OBJECT) {
   struct iovec *iovs = zp_set1.get_iovs();
   for (int ix : {2 , 3}) {
     struct iovec *iov = &iovs[ix];
-    int ret = rgw_read(fs, object_fh, offset, iov[ix-2].iov_len, &nread,
+    int ret = rgw_read(fs, object_fh, offset, iovs[ix-2].iov_len, &nread,
                       iov->iov_base);
     offset += iov->iov_len;
     ASSERT_EQ(ret, 0);