int IoCtx::remove(const std::string& oid) {
TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
return ctx->execute_operation(
- oid, boost::bind(&TestIoCtxImpl::remove, _1, _2));
- return ctx->remove(oid);
+ oid, boost::bind(&TestIoCtxImpl::remove, _1, _2, ctx->get_snap_context()));
}
int IoCtx::selfmanaged_snap_create(uint64_t *snapid) {
oid, boost::bind(&TestIoCtxImpl::tmap_update, _1, _2, cmdbl));
}
+int IoCtx::trunc(const std::string& oid, uint64_t off) {
+ TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+ return ctx->execute_operation(
+ oid, boost::bind(&TestIoCtxImpl::truncate, _1, _2, off,
+ ctx->get_snap_context()));
+}
+
int IoCtx::unwatch2(uint64_t handle) {
TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
return ctx->unwatch(handle);
void ObjectWriteOperation::remove() {
TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
- o->ops.push_back(boost::bind(&TestIoCtxImpl::remove, _1, _2));
+ o->ops.push_back(boost::bind(&TestIoCtxImpl::remove, _1, _2, _4));
}
void ObjectWriteOperation::selfmanaged_snap_rollback(uint64_t snapid) {
snapc);
}
+ MOCK_METHOD2(list_snaps, int(const std::string& o, snap_set_t *out_snaps));
+ int do_list_snaps(const std::string& o, snap_set_t *out_snaps) {
+ return TestMemIoCtxImpl::list_snaps(o, out_snaps);
+ }
+
MOCK_METHOD2(list_watchers, int(const std::string& o,
std::list<obj_watch_t> *out_watchers));
int do_list_watchers(const std::string& o,
return TestMemIoCtxImpl::read(oid, len, off, bl);
}
- MOCK_METHOD1(remove, int(const std::string& oid));
- int do_remove(const std::string& oid) {
- return TestMemIoCtxImpl::remove(oid);
+ MOCK_METHOD2(remove, int(const std::string& oid, const SnapContext &snapc));
+ int do_remove(const std::string& oid, const SnapContext &snapc) {
+ return TestMemIoCtxImpl::remove(oid, snapc);
}
MOCK_METHOD1(selfmanaged_snap_create, int(uint64_t *snap_id));
using namespace ::testing;
ON_CALL(*this, exec(_, _, _, _, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_exec));
+ 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, read(_, _, _, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_read));
- ON_CALL(*this, remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove));
+ ON_CALL(*this, remove(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_remove));
ON_CALL(*this, selfmanaged_snap_create(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_create));
ON_CALL(*this, selfmanaged_snap_remove(_)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_remove));
ON_CALL(*this, selfmanaged_snap_rollback(_, _)).WillByDefault(Invoke(this, &MockTestMemIoCtxImpl::do_selfmanaged_snap_rollback));
bufferlist *pbl);
virtual int read(const std::string& oid, size_t len, uint64_t off,
bufferlist *bl) = 0;
- virtual int remove(const std::string& oid) = 0;
+ virtual int remove(const std::string& oid, const SnapContext &snapc) = 0;
virtual int selfmanaged_snap_create(uint64_t *snapid) = 0;
virtual int selfmanaged_snap_remove(uint64_t snapid) = 0;
virtual int selfmanaged_snap_rollback(const std::string& oid,
int TestMemIoCtxImpl::aio_remove(const std::string& oid, AioCompletionImpl *c) {
m_client->add_aio_operation(oid, true,
- boost::bind(&TestMemIoCtxImpl::remove, this, oid),
+ boost::bind(&TestMemIoCtxImpl::remove, this, oid,
+ get_snap_context()),
c);
return 0;
}
return len;
}
-int TestMemIoCtxImpl::remove(const std::string& oid) {
+int TestMemIoCtxImpl::remove(const std::string& oid, const SnapContext &snapc) {
if (get_snap_read() != CEPH_NOSNAP) {
return -EROFS;
}
RWLock::WLocker l(m_pool->file_lock);
- TestMemRadosClient::SharedFile file = get_file(oid, false,
- get_snap_context());
+ TestMemRadosClient::SharedFile file = get_file(oid, false, snapc);
if (file == NULL) {
return -ENOENT;
}
- file = get_file(oid, true, get_snap_context());
+ file = get_file(oid, true, snapc);
RWLock::WLocker l2(file->lock);
file->exists = false;
bufferlist> &map);
virtual int read(const std::string& oid, size_t len, uint64_t off,
bufferlist *bl);
- virtual int remove(const std::string& oid);
+ virtual int remove(const std::string& oid, const SnapContext &snapc);
virtual int selfmanaged_snap_create(uint64_t *snapid);
virtual int selfmanaged_snap_remove(uint64_t snapid);
virtual int selfmanaged_snap_rollback(const std::string& oid,