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;
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;
}
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;
}
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;
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;
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;
}
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();
}
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);
}
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);
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;
}
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;
}
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;
}
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
~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;
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));
}
// 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;
}
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();
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);
}
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;
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) {