From: Jason Dillaman Date: Thu, 11 Jun 2015 21:32:40 +0000 (-0400) Subject: librados_test_stub: added support for append op X-Git-Tag: v10.0.1~102^2~36 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c11d71c7a603072ee15bc676a5a20e18615c0f66;p=ceph.git librados_test_stub: added support for append op Signed-off-by: Jason Dillaman --- diff --git a/src/test/librados_test_stub/LibradosTestStub.cc b/src/test/librados_test_stub/LibradosTestStub.cc index 80690897af1..75f7fde46fe 100644 --- a/src/test/librados_test_stub/LibradosTestStub.cc +++ b/src/test/librados_test_stub/LibradosTestStub.cc @@ -90,6 +90,9 @@ TestRadosClientPtr get_rados_client() { cct->_conf->apply_changes(NULL); client->reset(new librados::TestMemRadosClient(cct), &librados::TestRadosClient::Deallocate); + if (g_ceph_context == NULL) { + g_ceph_context = cct; + } cct->put(); } (*client)->get(); @@ -695,6 +698,11 @@ void ObjectReadOperation::sparse_read(uint64_t off, uint64_t len, o->ops.push_back(op); } +void ObjectWriteOperation::append(const bufferlist &bl) { + TestObjectOperationImpl *o = reinterpret_cast(impl); + o->ops.push_back(boost::bind(&TestIoCtxImpl::append, _1, _2, bl, _4)); +} + void ObjectWriteOperation::create(bool exclusive) { TestObjectOperationImpl *o = reinterpret_cast(impl); o->ops.push_back(boost::bind(&TestIoCtxImpl::create, _1, _2, exclusive)); diff --git a/src/test/librados_test_stub/TestIoCtxImpl.h b/src/test/librados_test_stub/TestIoCtxImpl.h index 4d924f49883..37094adcc0f 100644 --- a/src/test/librados_test_stub/TestIoCtxImpl.h +++ b/src/test/librados_test_stub/TestIoCtxImpl.h @@ -82,6 +82,8 @@ public: bufferlist *pbl); virtual int aio_remove(const std::string& oid, AioCompletionImpl *c) = 0; + virtual int append(const std::string& oid, const bufferlist &bl, + const SnapContext &snapc) = 0; virtual int assert_exists(const std::string &oid) = 0; virtual int create(const std::string& oid, bool exclusive) = 0; diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.cc b/src/test/librados_test_stub/TestMemIoCtxImpl.cc index 6b124ed13a6..9b95c502f15 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.cc +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.cc @@ -51,6 +51,23 @@ int TestMemIoCtxImpl::aio_remove(const std::string& oid, AioCompletionImpl *c) { return 0; } +int TestMemIoCtxImpl::append(const std::string& oid, const bufferlist &bl, + const SnapContext &snapc) { + if (get_snap_read() != CEPH_NOSNAP) { + return -EROFS; + } + + TestMemRadosClient::SharedFile file; + { + RWLock::WLocker l(m_pool->file_lock); + file = get_file(oid, true, snapc); + } + + RWLock::WLocker l(file->lock); + file->data.append(bl); + return 0; +} + int TestMemIoCtxImpl::assert_exists(const std::string &oid) { RWLock::RLocker l(m_pool->file_lock); TestMemRadosClient::SharedFile file = get_file(oid, false, diff --git a/src/test/librados_test_stub/TestMemIoCtxImpl.h b/src/test/librados_test_stub/TestMemIoCtxImpl.h index aa6541530b5..6556c9c723e 100644 --- a/src/test/librados_test_stub/TestMemIoCtxImpl.h +++ b/src/test/librados_test_stub/TestMemIoCtxImpl.h @@ -21,6 +21,8 @@ public: virtual int aio_remove(const std::string& oid, AioCompletionImpl *c); + virtual int append(const std::string& oid, const bufferlist &bl, + const SnapContext &snapc); virtual int assert_exists(const std::string &oid); virtual int create(const std::string& oid, bool exclusive);