]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librados_test_stub: enable sparse_read
authorMykola Golub <mgolub@suse.com>
Thu, 31 Jan 2019 13:51:32 +0000 (13:51 +0000)
committerMykola Golub <mgolub@suse.com>
Fri, 15 Feb 2019 11:12:00 +0000 (11:12 +0000)
Although it actually does not do sparse read, enabling it makes
possible to link the same test code with both librados_test_stub
and real librados.

Signed-off-by: Mykola Golub <mgolub@suse.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/TestMemIoCtxImpl.cc

index f3cb4f864bc5a797e97ddb33cf7276475f1a89b7..cad42a318816794a30c903425329c5511720f4a1 100644 (file)
@@ -655,6 +655,13 @@ void IoCtx::snap_set_read(snap_t seq) {
   ctx->set_snap_read(seq);
 }
 
+int IoCtx::sparse_read(const std::string& oid, std::map<uint64_t,uint64_t>& m,
+                       bufferlist& bl, size_t len, uint64_t off) {
+  TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+  return ctx->execute_operation(
+    oid, boost::bind(&TestIoCtxImpl::sparse_read, _1, _2, off, len, &m, &bl));
+}
+
 int IoCtx::stat(const std::string& oid, uint64_t *psize, time_t *pmtime) {
   TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
   return ctx->execute_operation(
index 9e160015ff066833b67e54a324f9704b7b734406..4d6426293d783c421105456865a97a4e34ce9aeb 100644 (file)
@@ -468,6 +468,7 @@ int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off,
 
   RWLock::RLocker l(file->lock);
   len = clip_io(off, len, file->data.length());
+  // TODO support sparse read
   if (m != NULL) {
     m->clear();
     if (len > 0) {
@@ -479,7 +480,7 @@ int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off,
     bit.substr_of(file->data, off, len);
     append_clone(bit, data_bl);
   }
-  return 0;
+  return len > 0 ? 1 : 0;
 }
 
 int TestMemIoCtxImpl::stat(const std::string& oid, uint64_t *psize,