]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: add id to distinguish between Aio results
authorCasey Bodley <cbodley@redhat.com>
Sat, 17 Nov 2018 04:59:56 +0000 (23:59 -0500)
committerCasey Bodley <cbodley@redhat.com>
Wed, 5 Dec 2018 16:16:54 +0000 (11:16 -0500)
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/test/rgw/test_rgw_throttle.cc

index fe83b1f23add19372c84e4c7871a90534a4af48f..0269c2c0d56fa2333244f1178a7d929e37966dae 100644 (file)
@@ -27,6 +27,7 @@ namespace rgw {
 
 struct AioResult {
   rgw_raw_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;
 };
@@ -64,12 +65,12 @@ class Aio {
   virtual AioResultList submit(RGWSI_RADOS::Obj& obj,
                                const rgw_raw_obj& raw_obj,
                                librados::ObjectReadOperation *op,
-                               uint64_t cost) = 0;
+                               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) = 0;
+                               uint64_t cost, uint64_t id) = 0;
 
   // poll for any ready completions without waiting
   virtual AioResultList poll() = 0;
index 1ec0aa5d51361c6b7f1ccadd4fc1cafbde81c9e6..bacfd50a62ad896537479f58dcdf6c44b7bced54 100644 (file)
@@ -39,10 +39,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 cost, uint64_t id)
 {
   auto p = std::make_unique<Pending>();
   p->obj = raw_obj;
+  p->id = id;
   p->cost = cost;
 
   if (cost > window) {
@@ -62,10 +63,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 cost, uint64_t id)
 {
   auto p = std::make_unique<Pending>();
   p->obj = raw_obj;
+  p->id = id;
   p->cost = cost;
 
   if (cost > window) {
index b07eae3ae48b255a4a2fc49f5f541c93595ad2bb..64b24979a700c448bbc4ae3142abcdc4227a3b03 100644 (file)
@@ -69,11 +69,11 @@ class AioThrottle : public Aio {
 
   AioResultList submit(RGWSI_RADOS::Obj& obj, const rgw_raw_obj& raw_obj,
                        librados::ObjectReadOperation *op,
-                       uint64_t cost) override;
+                       uint64_t cost, uint64_t id) override;
 
   AioResultList submit(RGWSI_RADOS::Obj& obj, const rgw_raw_obj& raw_obj,
                        librados::ObjectWriteOperation *op,
-                       uint64_t cost) override;
+                       uint64_t cost, uint64_t id) override;
 
   AioResultList poll() override;
 
index 4dbb2599fca2433d2cc43225f9d90e847fdc5c71..4d908263e42bf4fc89d02f22781588d9bd6da4b2 100644 (file)
@@ -91,7 +91,8 @@ int RadosWriter::process(bufferlist&& bl, uint64_t offset)
   } else {
     op.write(offset, data);
   }
-  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost);
+  constexpr uint64_t id = 0; // unused
+  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost, id);
   return process_completed(c, &written);
 }
 
@@ -103,7 +104,8 @@ int RadosWriter::write_exclusive(const bufferlist& data)
   op.create(true); // exclusive create
   op.write_full(data);
 
-  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost);
+  constexpr uint64_t id = 0; // unused
+  auto c = aio->submit(stripe_obj, stripe_raw, &op, cost, id);
   auto d = aio->drain();
   c.splice(c.end(), d);
   return process_completed(c, &written);
index 37132816c7723e2c37ad1ab069598198f51950a8..d2b20a0de808e5df414ade8917b8b6cf8f80e31c 100644 (file)
@@ -58,13 +58,6 @@ using Aio_Throttle = RadosFixture;
 
 namespace rgw {
 
-inline bool operator==(const AioResult& lhs, const AioResult& rhs) {
-  return lhs.obj == rhs.obj && lhs.result == rhs.result;
-}
-std::ostream& operator<<(std::ostream& out, const AioResult& r) {
-  return out << "{r=" << r.result << " obj='" << r.obj << "'";
-}
-
 TEST_F(Aio_Throttle, NoThrottleUpToMax)
 {
   AioThrottle throttle(4);
@@ -72,16 +65,16 @@ TEST_F(Aio_Throttle, NoThrottleUpToMax)
   auto obj = make_obj(raw);
   {
     librados::ObjectWriteOperation op1;
-    auto c1 = throttle.submit(obj, raw, &op1, 1);
+    auto c1 = throttle.submit(obj, raw, &op1, 1, 0);
     EXPECT_TRUE(c1.empty());
     librados::ObjectWriteOperation op2;
-    auto c2 = throttle.submit(obj, raw, &op2, 1);
+    auto c2 = throttle.submit(obj, raw, &op2, 1, 0);
     EXPECT_TRUE(c2.empty());
     librados::ObjectWriteOperation op3;
-    auto c3 = throttle.submit(obj, raw, &op3, 1);
+    auto c3 = throttle.submit(obj, raw, &op3, 1, 0);
     EXPECT_TRUE(c3.empty());
     librados::ObjectWriteOperation op4;
-    auto c4 = throttle.submit(obj, raw, &op4, 1);
+    auto c4 = throttle.submit(obj, raw, &op4, 1, 0);
     EXPECT_TRUE(c4.empty());
     // no completions because no ops had to wait
     auto c5 = throttle.poll();
@@ -89,7 +82,7 @@ TEST_F(Aio_Throttle, NoThrottleUpToMax)
   auto completions = throttle.drain();
   ASSERT_EQ(4u, completions.size());
   for (auto& c : completions) {
-    EXPECT_EQ(AioResult({raw, -EINVAL}), c);
+    EXPECT_EQ(-EINVAL, c.result);
   }
 }
 
@@ -100,9 +93,9 @@ TEST_F(Aio_Throttle, CostOverWindow)
   auto obj = make_obj(raw);
 
   librados::ObjectWriteOperation op;
-  auto c = throttle.submit(obj, raw, &op, 8);
+  auto c = throttle.submit(obj, raw, &op, 8, 0);
   ASSERT_EQ(1u, c.size());
-  EXPECT_EQ(AioResult({raw, -EDEADLK}), c.front());
+  EXPECT_EQ(-EDEADLK, c.front().result);
 }
 
 TEST_F(Aio_Throttle, ThrottleOverMax)
@@ -120,7 +113,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);
+    auto c = throttle.submit(obj, raw, &op, 1, 0);
     outstanding++;
     outstanding -= c.size();
     if (max_outstanding < outstanding) {