This commit implements a missing handling of librados_test_stub of objver reading
Signed-off-by: Or Ozeri <oro@il.ibm.com>
TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
TestObjectOperationImpl *ops = reinterpret_cast<TestObjectOperationImpl*>(op->impl);
return ctx->aio_operate_read(oid, *ops, c->pc, flags, pbl,
- ctx->get_snap_read());
+ ctx->get_snap_read(), nullptr);
}
int IoCtx::aio_operate(const std::string& oid, AioCompletion *c,
TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
return ctx->execute_operation(
oid, std::bind(&TestIoCtxImpl::read, _1, _2, len, off, &bl,
- ctx->get_snap_read()));
+ ctx->get_snap_read(), nullptr));
}
int IoCtx::remove(const std::string& oid) {
cmp_bl, _4);
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
out_snaps);
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
_2, out_watchers);
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
ObjectOperationTestImpl op;
if (pbl != NULL) {
- op = std::bind(&TestIoCtxImpl::read, _1, _2, len, off, pbl, _4);
+ op = std::bind(&TestIoCtxImpl::read, _1, _2, len, off, pbl, _4, nullptr);
} else {
- op = std::bind(&TestIoCtxImpl::read, _1, _2, len, off, _3, _4);
+ op = std::bind(&TestIoCtxImpl::read, _1, _2, len, off, _3, _4, nullptr);
}
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
if (prval != NULL) {
op = std::bind(save_operation_result,
- std::bind(op, _1, _2, _3, _4, _5), prval);
+ std::bind(op, _1, _2, _3, _4, _5, _6), prval);
}
o->ops.push_back(op);
}
bufferlist *outbl, uint32_t op_flags) {
librados::TestClassHandler::MethodContext *ctx =
reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
- return ctx->io_ctx_impl->read(ctx->oid, len, ofs, outbl, ctx->snap_id);
+ return ctx->io_ctx_impl->read(
+ ctx->oid, len, ofs, outbl, ctx->snap_id, nullptr);
}
int cls_cxx_setxattr(cls_method_context_t hctx, const char *name,
return TestMemIoCtxImpl::sparse_read(oid, off, len, m, bl, snap_id);
}
- MOCK_METHOD5(read, int(const std::string& oid,
+ MOCK_METHOD6(read, int(const std::string& oid,
size_t len,
uint64_t off,
- bufferlist *bl, uint64_t snap_id));
+ bufferlist *bl, uint64_t snap_id, uint64_t* objver));
int do_read(const std::string& oid, size_t len, uint64_t off,
- bufferlist *bl, uint64_t snap_id) {
- return TestMemIoCtxImpl::read(oid, len, off, bl, snap_id);
+ bufferlist *bl, uint64_t snap_id, uint64_t* objver) {
+ return TestMemIoCtxImpl::read(oid, len, off, bl, snap_id, objver);
}
MOCK_METHOD2(remove, int(const std::string& oid, const SnapContext &snapc));
ON_CALL(*this, list_snaps(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_list_snaps));
ON_CALL(*this, list_watchers(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_list_watchers));
ON_CALL(*this, notify(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_notify));
- ON_CALL(*this, read(_, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_read));
+ ON_CALL(*this, read(_, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_read));
ON_CALL(*this, set_snap_read(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_set_snap_read));
ON_CALL(*this, sparse_read(_, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_sparse_read));
ON_CALL(*this, remove(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove));
&librados::TestIoCtxImpl::cmpext, _1, _2, off, cmp_bl, _4);
if (s != nullptr) {
op = std::bind(
- save_operation_size, std::bind(op, _1, _2, _3, _4, _5), s);
+ save_operation_size, std::bind(op, _1, _2, _3, _4, _5, _6), s);
}
o->ops.push_back(op);
}
librados::ObjectOperationTestImpl op =
[cls_handler, cls, method, inbl = const_cast<bufferlist&>(inbl), out]
(librados::TestIoCtxImpl* io_ctx, const std::string& oid, bufferlist* outbl,
- uint64_t snap_id, const SnapContext& snapc) mutable -> int {
+ uint64_t snap_id, const SnapContext& snapc, uint64_t*) mutable -> int {
return io_ctx->exec(
oid, cls_handler, std::string(cls).c_str(),
std::string(method).c_str(), inbl,
};
if (ec != nullptr) {
op = std::bind(
- save_operation_ec, std::bind(op, _1, _2, _3, _4, _5), ec);
+ save_operation_ec, std::bind(op, _1, _2, _3, _4, _5, _6), ec);
}
o->ops.push_back(op);
}
librados::ObjectOperationTestImpl op =
[cls_handler, cls, method, inbl = const_cast<bufferlist&>(inbl)]
(librados::TestIoCtxImpl* io_ctx, const std::string& oid, bufferlist* outbl,
- uint64_t snap_id, const SnapContext& snapc) mutable -> int {
+ uint64_t snap_id, const SnapContext& snapc, uint64_t*) mutable -> int {
return io_ctx->exec(
oid, cls_handler, std::string(cls).c_str(),
std::string(method).c_str(), inbl, outbl, snap_id, snapc);
};
if (ec != NULL) {
op = std::bind(
- save_operation_ec, std::bind(op, _1, _2, _3, _4, _5), ec);
+ save_operation_ec, std::bind(op, _1, _2, _3, _4, _5, _6), ec);
}
o->ops.push_back(op);
}
auto o = *reinterpret_cast<librados::TestObjectOperationImpl**>(&impl);
librados::ObjectOperationTestImpl op;
if (out != nullptr) {
- op = std::bind(&librados::TestIoCtxImpl::read, _1, _2, len, off, out, _4);
+ op = std::bind(
+ &librados::TestIoCtxImpl::read, _1, _2, len, off, out, _4, _6);
} else {
- op = std::bind(&librados::TestIoCtxImpl::read, _1, _2, len, off, _3, _4);
+ op = std::bind(
+ &librados::TestIoCtxImpl::read, _1, _2, len, off, _3, _4, _6);
}
if (ec != NULL) {
op = std::bind(
- save_operation_ec, std::bind(op, _1, _2, _3, _4, _5), ec);
+ save_operation_ec, std::bind(op, _1, _2, _3, _4, _5, _6), ec);
}
o->ops.push_back(op);
}
librados::ObjectOperationTestImpl op =
[off, len, out, extents]
(librados::TestIoCtxImpl* io_ctx, const std::string& oid, bufferlist* outbl,
- uint64_t snap_id, const SnapContext& snapc) mutable -> int {
+ uint64_t snap_id, const SnapContext& snapc, uint64_t*) mutable -> int {
std::map<uint64_t,uint64_t> m;
int r = io_ctx->sparse_read(
oid, off, len, &m, (out != nullptr ? out : outbl), snap_id);
};
if (ec != NULL) {
op = std::bind(save_operation_ec,
- std::bind(op, _1, _2, _3, _4, _5), ec);
+ std::bind(op, _1, _2, _3, _4, _5, _6), ec);
}
o->ops.push_back(op);
}
librados::ObjectOperationTestImpl op =
[snaps]
(librados::TestIoCtxImpl* io_ctx, const std::string& oid, bufferlist*,
- uint64_t, const SnapContext&) mutable -> int {
+ uint64_t, const SnapContext&, uint64_t*) mutable -> int {
librados::snap_set_t snap_set;
int r = io_ctx->list_snaps(oid, &snap_set);
if (r >= 0 && snaps != nullptr) {
};
if (ec != NULL) {
op = std::bind(save_operation_ec,
- std::bind(op, _1, _2, _3, _4, _5), ec);
+ std::bind(op, _1, _2, _3, _4, _5, _6), ec);
}
o->ops.push_back(op);
}
auto completion = create_aio_completion(std::move(c));
auto r = io_ctx->aio_operate_read(std::string{o}, *ops, completion, 0U, bl,
- snap_id);
+ snap_id, objver);
ceph_assert(r == 0);
}
m_client->add_aio_operation(oid, true, std::bind(
&TestIoCtxImpl::execute_aio_operations, this, oid, &ops,
reinterpret_cast<bufferlist*>(0), m_snap_seq,
- snap_context != NULL ? *snap_context : m_snapc), c);
+ snap_context != NULL ? *snap_context : m_snapc, nullptr), c);
return 0;
}
int TestIoCtxImpl::aio_operate_read(const std::string& oid,
TestObjectOperationImpl &ops,
AioCompletionImpl *c, int flags,
- bufferlist *pbl, uint64_t snap_id) {
+ bufferlist *pbl, uint64_t snap_id,
+ uint64_t* objver) {
// TODO ignoring flags for now
ops.get();
m_pending_ops++;
m_client->add_aio_operation(oid, true, std::bind(
&TestIoCtxImpl::execute_aio_operations, this, oid, &ops, pbl, snap_id,
- m_snapc), c);
+ m_snapc, objver), c);
return 0;
}
m_pending_ops++;
m_client->add_aio_operation(oid, false, std::bind(
&TestIoCtxImpl::execute_aio_operations, this, oid, &ops,
- reinterpret_cast<bufferlist*>(0), m_snap_seq, m_snapc), comp);
+ reinterpret_cast<bufferlist*>(0), m_snap_seq, m_snapc, nullptr), comp);
comp->wait_for_complete();
int ret = comp->get_return_value();
m_pending_ops++;
m_client->add_aio_operation(oid, false, std::bind(
&TestIoCtxImpl::execute_aio_operations, this, oid, &ops, pbl,
- m_snap_seq, m_snapc), comp);
+ m_snap_seq, m_snapc, nullptr), comp);
comp->wait_for_complete();
int ret = comp->get_return_value();
if (size > 0) {
bufferlist inbl;
- r = read(oid, size, 0, &inbl, CEPH_NOSNAP);
+ r = read(oid, size, 0, &inbl, CEPH_NOSNAP, nullptr);
if (r < 0) {
return r;
}
int TestIoCtxImpl::execute_aio_operations(const std::string& oid,
TestObjectOperationImpl *ops,
bufferlist *pbl, uint64_t snap_id,
- const SnapContext &snapc) {
+ const SnapContext &snapc,
+ uint64_t* objver) {
int ret = 0;
if (m_client->is_blocklisted()) {
ret = -EBLOCKLISTED;
TestRadosClient::Transaction transaction(m_client, get_namespace(), oid);
for (ObjectOperations::iterator it = ops->ops.begin();
it != ops->ops.end(); ++it) {
- ret = (*it)(this, oid, pbl, snap_id, snapc);
+ ret = (*it)(this, oid, pbl, snap_id, snapc, objver);
if (ret < 0) {
break;
}
typedef boost::function<int(TestIoCtxImpl*,
const std::string&,
bufferlist *,
- uint64_t,
- const SnapContext &)> ObjectOperationTestImpl;
+ uint64_t,
+ const SnapContext &,
+ uint64_t*)> ObjectOperationTestImpl;
typedef std::list<ObjectOperationTestImpl> ObjectOperations;
struct TestObjectOperationImpl {
int flags);
virtual int aio_operate_read(const std::string& oid, TestObjectOperationImpl &ops,
AioCompletionImpl *c, int flags,
- bufferlist *pbl, uint64_t snap_id);
+ bufferlist *pbl, uint64_t snap_id,
+ uint64_t* objver);
virtual int aio_remove(const std::string& oid, AioCompletionImpl *c,
int flags = 0) = 0;
virtual int aio_watch(const std::string& o, AioCompletionImpl *c,
virtual int operate_read(const std::string& oid, TestObjectOperationImpl &ops,
bufferlist *pbl);
virtual int read(const std::string& oid, size_t len, uint64_t off,
- bufferlist *bl, uint64_t snap_id) = 0;
+ bufferlist *bl, uint64_t snap_id, uint64_t* objver) = 0;
virtual int remove(const std::string& oid, const SnapContext &snapc) = 0;
virtual int selfmanaged_snap_create(uint64_t *snapid) = 0;
virtual void aio_selfmanaged_snap_create(uint64_t *snapid,
int execute_aio_operations(const std::string& oid,
TestObjectOperationImpl *ops,
bufferlist *pbl, uint64_t,
- const SnapContext &snapc);
+ const SnapContext &snapc,
+ uint64_t* objver);
private:
struct C_AioNotify : public Context {
}
int TestMemIoCtxImpl::read(const std::string& oid, size_t len, uint64_t off,
- bufferlist *bl, uint64_t snap_id) {
+ bufferlist *bl, uint64_t snap_id,
+ uint64_t* objver) {
if (m_client->is_blocklisted()) {
return -EBLOCKLISTED;
}
bit.substr_of(file->data, off, len);
append_clone(bit, bl);
}
+ if (objver != nullptr) {
+ *objver = file->objver;
+ }
return len;
}
int omap_set(const std::string& oid, const std::map<std::string,
bufferlist> &map) override;
int read(const std::string& oid, size_t len, uint64_t off,
- bufferlist *bl, uint64_t snap_id) override;
+ bufferlist *bl, uint64_t snap_id, uint64_t* objver) override;
int remove(const std::string& oid, const SnapContext &snapc) override;
int selfmanaged_snap_create(uint64_t *snapid) override;
int selfmanaged_snap_remove(uint64_t snapid) override;
void expect_v1_read_header(MockRefreshImageCtx &mock_image_ctx, int r) {
auto &expect = EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.md_ctx),
- read(mock_image_ctx.header_oid, _, _, _, _));
+ read(mock_image_ctx.header_oid, _, _, _, _, _));
if (r < 0) {
expect.WillOnce(Return(r));
} else {
void expect_read_rbd_info(librados::MockTestMemIoCtxImpl &mock_io_ctx,
const std::string& data, int r) {
- auto& expect = EXPECT_CALL(mock_io_ctx, read(StrEq(RBD_INFO), 0, 0, _, _));
+ auto& expect = EXPECT_CALL(
+ mock_io_ctx, read(StrEq(RBD_INFO), 0, 0, _, _, _));
if (r < 0) {
expect.WillOnce(Return(r));
} else {
auto& mock_io_ctx = librados::get_mock_io_ctx(
mock_image_ctx.rados_api, *mock_image_ctx.get_data_io_context());
- auto& expect = EXPECT_CALL(mock_io_ctx, read(oid, len, off, _, _));
+ auto& expect = EXPECT_CALL(mock_io_ctx, read(oid, len, off, _, _, _));
if (r < 0) {
expect.WillOnce(Return(r));
} else {
if (r < 0) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
read(ObjectMap<>::object_map_name(ictx->id, CEPH_NOSNAP),
- 0, 0, _, _)).WillOnce(Return(r));
+ 0, 0, _, _, _)).WillOnce(Return(r));
} else {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
read(ObjectMap<>::object_map_name(ictx->id, CEPH_NOSNAP),
- 0, 0, _, _)).WillOnce(DoDefault());
+ 0, 0, _, _, _)).WillOnce(DoDefault());
}
}
if (r < 0) {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
read(ObjectMap<>::object_map_name(ictx->id, snap_id),
- 0, 0, _, _)).WillOnce(Return(r));
+ 0, 0, _, _, _)).WillOnce(Return(r));
} else {
EXPECT_CALL(get_mock_io_ctx(ictx->md_ctx),
read(ObjectMap<>::object_map_name(ictx->id, snap_id),
- 0, 0, _, _)).WillOnce(DoDefault());
+ 0, 0, _, _, _)).WillOnce(DoDefault());
}
}