]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: store ref to librados::IoCtx in rgw::AioResult
authorCasey Bodley <cbodley@redhat.com>
Mon, 3 Dec 2018 21:50:27 +0000 (16:50 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 5 Dec 2018 16:16:54 +0000 (11:16 -0500)
the IoCtx has to outlive its aio completions

Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_aio.h
src/rgw/rgw_aio_throttle.cc
src/rgw/rgw_aio_throttle.h
src/rgw/rgw_putobj_processor.cc
src/rgw/rgw_putobj_processor.h
src/rgw/rgw_rados.cc
src/test/rgw/test_rgw_throttle.cc

index 0269c2c0d56fa2333244f1178a7d929e37966dae..53d91ca3833b218b873dd232f24b6efe4d4d1b1b 100644 (file)
@@ -26,7 +26,7 @@ class ObjectWriteOperation;
 namespace rgw {
 
 struct AioResult {
-  rgw_raw_obj obj;
+  RGWSI_RADOS::Obj obj;
   uint64_t id = 0; // id allows caller to associate a result with its request
   bufferlist data; // result buffer for reads
   int result = 0;
@@ -63,12 +63,10 @@ class Aio {
   virtual ~Aio() {}
 
   virtual AioResultList submit(RGWSI_RADOS::Obj& obj,
-                               const rgw_raw_obj& raw_obj,
                                librados::ObjectReadOperation *op,
                                uint64_t cost, uint64_t id) = 0;
 
   virtual AioResultList submit(RGWSI_RADOS::Obj& obj,
-                               const rgw_raw_obj& raw_obj,
                                librados::ObjectWriteOperation *op,
                                uint64_t cost, uint64_t id) = 0;
 
index bacfd50a62ad896537479f58dcdf6c44b7bced54..7513e04e9461a0c986015c4e8ba2d48775e66792 100644 (file)
@@ -37,12 +37,11 @@ bool AioThrottle::waiter_ready() const
 }
 
 AioResultList AioThrottle::submit(RGWSI_RADOS::Obj& obj,
-                                  const rgw_raw_obj& raw_obj,
                                   librados::ObjectWriteOperation *op,
                                   uint64_t cost, uint64_t id)
 {
   auto p = std::make_unique<Pending>();
-  p->obj = raw_obj;
+  p->obj = obj;
   p->id = id;
   p->cost = cost;
 
@@ -61,12 +60,11 @@ AioResultList AioThrottle::submit(RGWSI_RADOS::Obj& obj,
 }
 
 AioResultList AioThrottle::submit(RGWSI_RADOS::Obj& obj,
-                                  const rgw_raw_obj& raw_obj,
                                   librados::ObjectReadOperation *op,
                                   uint64_t cost, uint64_t id)
 {
   auto p = std::make_unique<Pending>();
-  p->obj = raw_obj;
+  p->obj = obj;
   p->id = id;
   p->cost = cost;
 
index 64b24979a700c448bbc4ae3142abcdc4227a3b03..97dea4bea0e9597a1440ee3fde74248ecc31ba01 100644 (file)
@@ -67,11 +67,11 @@ class AioThrottle : public Aio {
     ceph_assert(completed.empty());
   }
 
-  AioResultList submit(RGWSI_RADOS::Obj& obj, const rgw_raw_obj& raw_obj,
+  AioResultList submit(RGWSI_RADOS::Obj& obj,
                        librados::ObjectReadOperation *op,
                        uint64_t cost, uint64_t id) override;
 
-  AioResultList submit(RGWSI_RADOS::Obj& obj, const rgw_raw_obj& raw_obj,
+  AioResultList submit(RGWSI_RADOS::Obj& obj,
                        librados::ObjectWriteOperation *op,
                        uint64_t cost, uint64_t id) override;
 
index 4d908263e42bf4fc89d02f22781588d9bd6da4b2..6877d0cfc3e978a7e42a54c962c9ae765b4d1fe7 100644 (file)
@@ -63,7 +63,7 @@ static int process_completed(const AioResultList& completed, RawObjSet *written)
   std::optional<int> error;
   for (auto& r : completed) {
     if (r.result >= 0) {
-      written->insert(r.obj);
+      written->insert(r.obj.get_ref().obj);
     } else if (!error) { // record first error code
       error = r.result;
     }
@@ -71,10 +71,9 @@ static int process_completed(const AioResultList& completed, RawObjSet *written)
   return error.value_or(0);
 }
 
-int RadosWriter::set_stripe_obj(rgw_raw_obj&& raw_obj)
+int RadosWriter::set_stripe_obj(const rgw_raw_obj& raw_obj)
 {
-  stripe_raw = std::move(raw_obj);
-  stripe_obj = store->svc.rados->obj(stripe_raw);
+  stripe_obj = store->svc.rados->obj(raw_obj);
   return stripe_obj.open();
 }
 
@@ -92,7 +91,7 @@ int RadosWriter::process(bufferlist&& bl, uint64_t offset)
     op.write(offset, data);
   }
   constexpr uint64_t id = 0; // unused
-  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost, id);
+  auto c = aio->submit(stripe_obj, &op, cost, id);
   return process_completed(c, &written);
 }
 
@@ -105,7 +104,7 @@ int RadosWriter::write_exclusive(const bufferlist& data)
   op.write_full(data);
 
   constexpr uint64_t id = 0; // unused
-  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost, id);
+  auto c = aio->submit(stripe_obj, &op, cost, id);
   auto d = aio->drain();
   c.splice(c.end(), d);
   return process_completed(c, &written);
@@ -179,7 +178,7 @@ int ManifestObjectProcessor::next(uint64_t offset, uint64_t *pstripe_size)
   if (r < 0) {
     return r;
   }
-  r = writer.set_stripe_obj(std::move(stripe_obj));
+  r = writer.set_stripe_obj(stripe_obj);
   if (r < 0) {
     return r;
   }
@@ -223,7 +222,7 @@ int AtomicObjectProcessor::prepare()
   if (r < 0) {
     return r;
   }
-  r = writer.set_stripe_obj(std::move(stripe_obj));
+  r = writer.set_stripe_obj(stripe_obj);
   if (r < 0) {
     return r;
   }
@@ -344,7 +343,7 @@ int MultipartObjectProcessor::prepare_head()
   if (r < 0) {
     return r;
   }
-  r = writer.set_stripe_obj(std::move(stripe_obj));
+  r = writer.set_stripe_obj(stripe_obj);
   if (r < 0) {
     return r;
   }
index 4aca1a3225dde134991253b08f328937ca583403..ba3c65896ef23c1b2c20118ec2dcef0ce174c95b 100644 (file)
@@ -80,7 +80,6 @@ class RadosWriter : public DataProcessor {
   const RGWBucketInfo& bucket_info;
   RGWObjectCtx& obj_ctx;
   const rgw_obj& head_obj;
-  rgw_raw_obj stripe_raw;
   RGWSI_RADOS::Obj stripe_obj; // current stripe object
   RawObjSet written; // set of written objects for deletion
 
@@ -93,7 +92,7 @@ class RadosWriter : public DataProcessor {
   ~RadosWriter();
 
   // change the current stripe object
-  int set_stripe_obj(rgw_raw_obj&& obj);
+  int set_stripe_obj(const rgw_raw_obj& obj);
 
   // write the data at the given offset of the current stripe object
   int process(bufferlist&& data, uint64_t stripe_offset) override;
index f2561f88af02601483f4681995413ba9d698fda0..33033985e0b9fe278c9118a29a198ae8f501bc32 100644 (file)
@@ -6582,7 +6582,7 @@ int RGWRados::get_obj_iterate_cb(const rgw_raw_obj& read_obj, off_t obj_ofs,
   const uint64_t cost = len;
   const uint64_t id = obj_ofs; // use logical object offset for sorting replies
 
-  auto completed = d->aio->submit(obj, read_obj, &op, cost, id);
+  auto completed = d->aio->submit(obj, &op, cost, id);
 
   return d->flush(std::move(completed));
 }
index d2b20a0de808e5df414ade8917b8b6cf8f80e31c..c1b97a0482ae832553636350c43632d379163a04 100644 (file)
@@ -44,11 +44,8 @@ auto *const rados_env = ::testing::AddGlobalTestEnvironment(new RadosEnv);
 // test fixture for global setup/teardown
 class RadosFixture : public ::testing::Test {
  protected:
-  rgw_raw_obj make_raw_obj(const std::string& oid) {
-    return {{RadosEnv::poolname}, oid};
-  }
-  RGWSI_RADOS::Obj make_obj(const rgw_raw_obj& raw) {
-    auto obj = RadosEnv::rados->obj(raw);
+  RGWSI_RADOS::Obj make_obj(const std::string& oid) {
+    auto obj = RadosEnv::rados->obj({{RadosEnv::poolname}, oid});
     ceph_assert_always(0 == obj.open());
     return obj;
   }
@@ -61,20 +58,19 @@ namespace rgw {
 TEST_F(Aio_Throttle, NoThrottleUpToMax)
 {
   AioThrottle throttle(4);
-  auto raw = make_raw_obj(__PRETTY_FUNCTION__);
-  auto obj = make_obj(raw);
+  auto obj = make_obj(__PRETTY_FUNCTION__);
   {
     librados::ObjectWriteOperation op1;
-    auto c1 = throttle.submit(obj, raw, &op1, 1, 0);
+    auto c1 = throttle.submit(obj, &op1, 1, 0);
     EXPECT_TRUE(c1.empty());
     librados::ObjectWriteOperation op2;
-    auto c2 = throttle.submit(obj, raw, &op2, 1, 0);
+    auto c2 = throttle.submit(obj, &op2, 1, 0);
     EXPECT_TRUE(c2.empty());
     librados::ObjectWriteOperation op3;
-    auto c3 = throttle.submit(obj, raw, &op3, 1, 0);
+    auto c3 = throttle.submit(obj, &op3, 1, 0);
     EXPECT_TRUE(c3.empty());
     librados::ObjectWriteOperation op4;
-    auto c4 = throttle.submit(obj, raw, &op4, 1, 0);
+    auto c4 = throttle.submit(obj, &op4, 1, 0);
     EXPECT_TRUE(c4.empty());
     // no completions because no ops had to wait
     auto c5 = throttle.poll();
@@ -89,11 +85,10 @@ TEST_F(Aio_Throttle, NoThrottleUpToMax)
 TEST_F(Aio_Throttle, CostOverWindow)
 {
   AioThrottle throttle(4);
-  auto raw = make_raw_obj(__PRETTY_FUNCTION__);
-  auto obj = make_obj(raw);
+  auto obj = make_obj(__PRETTY_FUNCTION__);
 
   librados::ObjectWriteOperation op;
-  auto c = throttle.submit(obj, raw, &op, 8, 0);
+  auto c = throttle.submit(obj, &op, 8, 0);
   ASSERT_EQ(1u, c.size());
   EXPECT_EQ(-EDEADLK, c.front().result);
 }
@@ -103,8 +98,7 @@ TEST_F(Aio_Throttle, ThrottleOverMax)
   constexpr uint64_t window = 4;
   AioThrottle throttle(window);
 
-  auto raw = make_raw_obj(__PRETTY_FUNCTION__);
-  auto obj = make_obj(raw);
+  auto obj = make_obj(__PRETTY_FUNCTION__);
 
   // issue 32 writes, and verify that max_outstanding <= window
   constexpr uint64_t total = 32;
@@ -113,7 +107,7 @@ TEST_F(Aio_Throttle, ThrottleOverMax)
 
   for (uint64_t i = 0; i < total; i++) {
     librados::ObjectWriteOperation op;
-    auto c = throttle.submit(obj, raw, &op, 1, 0);
+    auto c = throttle.submit(obj, &op, 1, 0);
     outstanding++;
     outstanding -= c.size();
     if (max_outstanding < outstanding) {