int IoCtx::create(const std::string& oid, bool exclusive) {
TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
return ctx->execute_operation(
- oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive));
+ oid, boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive,
+ ctx->get_snap_context()));
}
void IoCtx::dup(const IoCtx& rhs) {
void ObjectWriteOperation::create(bool exclusive) {
TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
- o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive));
+ o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive, _4));
}
void ObjectWriteOperation::omap_set(const std::map<std::string, bufferlist> &map) {
int cls_cxx_create(cls_method_context_t hctx, bool exclusive) {
librados::TestClassHandler::MethodContext *ctx =
reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
- return ctx->io_ctx_impl->create(ctx->oid, exclusive);
+ return ctx->io_ctx_impl->create(ctx->oid, exclusive, ctx->snapc);
}
int cls_cxx_remove(cls_method_context_t hctx) {
return TestMemIoCtxImpl::assert_exists(oid);
}
- MOCK_METHOD2(create, int(const std::string&, bool));
- int do_create(const std::string& oid, bool exclusive) {
- return TestMemIoCtxImpl::create(oid, exclusive);
+ MOCK_METHOD3(create, int(const std::string&, bool, const SnapContext &));
+ int do_create(const std::string& oid, bool exclusive,
+ const SnapContext &snapc) {
+ return TestMemIoCtxImpl::create(oid, exclusive, snapc);
}
MOCK_METHOD3(cmpext, int(const std::string&, uint64_t, bufferlist&));
ON_CALL(*this, aio_watch(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_watch));
ON_CALL(*this, aio_unwatch(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_aio_unwatch));
ON_CALL(*this, assert_exists(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_assert_exists));
- ON_CALL(*this, create(_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create));
+ ON_CALL(*this, create(_, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_create));
ON_CALL(*this, cmpext(_,_,_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_cmpext));
ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec));
ON_CALL(*this, get_instance_id()).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_get_instance_id));
uint64_t size = 0;
int r = stat(oid, &size, NULL);
if (r == -ENOENT) {
- r = create(oid, false);
+ r = create(oid, false, m_snapc);
}
if (r < 0) {
return r;
const SnapContext &snapc) = 0;
virtual int assert_exists(const std::string &oid) = 0;
- virtual int create(const std::string& oid, bool exclusive) = 0;
+ virtual int create(const std::string& oid, bool exclusive,
+ const SnapContext &snapc) = 0;
virtual int exec(const std::string& oid, TestClassHandler *handler,
const char *cls, const char *method,
bufferlist& inbl, bufferlist* outbl,
return 0;
}
-int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive) {
+int TestMemIoCtxImpl::create(const std::string& oid, bool exclusive,
+ const SnapContext &snapc) {
if (get_snap_read() != CEPH_NOSNAP) {
return -EROFS;
} else if (m_client->is_blacklisted()) {
}
RWLock::WLocker l(m_pool->file_lock);
- get_file(oid, true, get_snap_context());
+ get_file(oid, true, snapc);
return 0;
}
int assert_exists(const std::string &oid) override;
- int create(const std::string& oid, bool exclusive) override;
+ int create(const std::string& oid, bool exclusive,
+ const SnapContext &snapc) override;
int list_snaps(const std::string& o, snap_set_t *out_snaps) override;
int omap_get_vals(const std::string& oid,
const std::string& start_after,
}
void expect_create(MockTestImageCtx &mock_image_ctx, bool exclusive) {
- EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive))
+ EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, exclusive, _))
.Times(1);
}
expect_assert_exists(mock_image_ctx, 0);
expect_truncate(mock_image_ctx, 0, 0);
- EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0);
+ EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _))
+ .Times(0);
C_SaferCond ctx;
auto req = MockObjectDiscardRequest::create_discard(
expect_object_map_update(mock_image_ctx, 0, 1, OBJECT_EXISTS, {}, false, 0);
expect_truncate(mock_image_ctx, 1, 0);
- EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _)).Times(0);
+ EXPECT_CALL(get_mock_io_ctx(mock_image_ctx.data_ctx), create(_, _, _))
+ .Times(0);
C_SaferCond ctx;
auto req = MockObjectDiscardRequest::create_discard(
}
void expect_create_trash(librados::IoCtx &io_ctx, int r) {
- EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false))
+ EXPECT_CALL(get_mock_io_ctx(io_ctx), create(RBD_TRASH, false, _))
.WillOnce(Return(r));
}