From: Casey Bodley Date: Mon, 3 Dec 2018 21:50:27 +0000 (-0500) Subject: rgw: store ref to librados::IoCtx in rgw::AioResult X-Git-Tag: v14.1.0~704^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c7bf1be10e305e759c6a52d346bb5f6c73e12804;p=ceph-ci.git rgw: store ref to librados::IoCtx in rgw::AioResult the IoCtx has to outlive its aio completions Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_aio.h b/src/rgw/rgw_aio.h index 0269c2c0d56..53d91ca3833 100644 --- a/src/rgw/rgw_aio.h +++ b/src/rgw/rgw_aio.h @@ -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; diff --git a/src/rgw/rgw_aio_throttle.cc b/src/rgw/rgw_aio_throttle.cc index bacfd50a62a..7513e04e946 100644 --- a/src/rgw/rgw_aio_throttle.cc +++ b/src/rgw/rgw_aio_throttle.cc @@ -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(); - 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(); - p->obj = raw_obj; + p->obj = obj; p->id = id; p->cost = cost; diff --git a/src/rgw/rgw_aio_throttle.h b/src/rgw/rgw_aio_throttle.h index 64b24979a70..97dea4bea0e 100644 --- a/src/rgw/rgw_aio_throttle.h +++ b/src/rgw/rgw_aio_throttle.h @@ -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; diff --git a/src/rgw/rgw_putobj_processor.cc b/src/rgw/rgw_putobj_processor.cc index 4d908263e42..6877d0cfc3e 100644 --- a/src/rgw/rgw_putobj_processor.cc +++ b/src/rgw/rgw_putobj_processor.cc @@ -63,7 +63,7 @@ static int process_completed(const AioResultList& completed, RawObjSet *written) std::optional 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; } diff --git a/src/rgw/rgw_putobj_processor.h b/src/rgw/rgw_putobj_processor.h index 4aca1a3225d..ba3c65896ef 100644 --- a/src/rgw/rgw_putobj_processor.h +++ b/src/rgw/rgw_putobj_processor.h @@ -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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f2561f88af0..33033985e0b 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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)); } diff --git a/src/test/rgw/test_rgw_throttle.cc b/src/test/rgw/test_rgw_throttle.cc index d2b20a0de80..c1b97a0482a 100644 --- a/src/test/rgw/test_rgw_throttle.cc +++ b/src/test/rgw/test_rgw_throttle.cc @@ -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) {