]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librados_test_stub: simulate set_alloc_hint creating a non-existent file
authorJason Dillaman <dillaman@redhat.com>
Fri, 10 Nov 2017 21:26:19 +0000 (16:26 -0500)
committerJason Dillaman <dillaman@redhat.com>
Thu, 16 Nov 2017 12:31:59 +0000 (07:31 -0500)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/test/librados_test_stub/LibradosTestStub.cc
src/test/librados_test_stub/TestIoCtxImpl.cc
src/test/librados_test_stub/TestIoCtxImpl.h
src/test/librados_test_stub/TestMemIoCtxImpl.cc
src/test/librados_test_stub/TestMemIoCtxImpl.h

index d4ce8b20a6a2a2ce530813c56920b9392084011e..f4c7f8bef48f208e46a392f99b825ad9b7203527 100644 (file)
@@ -886,7 +886,7 @@ void ObjectWriteOperation::set_alloc_hint(uint64_t expected_object_size,
                                           uint64_t expected_write_size) {
   TestObjectOperationImpl *o = reinterpret_cast<TestObjectOperationImpl*>(impl);
   o->ops.push_back(boost::bind(&TestIoCtxImpl::set_alloc_hint, _1, _2,
-                              expected_object_size, expected_write_size));
+                              expected_object_size, expected_write_size, _4));
 }
 
 
index d5de8b54aa6c2588cdbea9611da3696253274dd7..56ce88690b4c46da9dabd6f25c8f4bc474013490 100644 (file)
@@ -248,7 +248,8 @@ int TestIoCtxImpl::selfmanaged_snap_set_write_ctx(snap_t seq,
 
 int TestIoCtxImpl::set_alloc_hint(const std::string& oid,
                                   uint64_t expected_object_size,
-                                  uint64_t expected_write_size) {
+                                  uint64_t expected_write_size,
+                                  const SnapContext &snapc) {
   return 0;
 }
 
index 7712e77307078471663d26d76fc266d67e5cd29d..87053085e9990d94a847f339b94a864f97cb3b2b 100644 (file)
@@ -135,7 +135,8 @@ public:
                                              std::vector<snap_t>& snaps);
   virtual int set_alloc_hint(const std::string& oid,
                              uint64_t expected_object_size,
-                             uint64_t expected_write_size);
+                             uint64_t expected_write_size,
+                             const SnapContext &snapc);
   virtual void set_snap_read(snap_t seq);
   virtual int sparse_read(const std::string& oid, uint64_t off, uint64_t len,
                           std::map<uint64_t,uint64_t> *m,
index 1ab891419facd9cb834a0f0e62c2d48215c7a153..cc99b1ee710cc7b002cbf4717395031aee224737 100644 (file)
@@ -411,6 +411,24 @@ int TestMemIoCtxImpl::selfmanaged_snap_rollback(const std::string& oid,
   return 0;
 }
 
+int TestMemIoCtxImpl::set_alloc_hint(const std::string& oid,
+                                     uint64_t expected_object_size,
+                                     uint64_t expected_write_size,
+                                     const SnapContext &snapc) {
+  if (get_snap_read() != CEPH_NOSNAP) {
+    return -EROFS;
+  } else if (m_client->is_blacklisted()) {
+    return -EBLACKLISTED;
+  }
+
+  {
+    RWLock::WLocker l(m_pool->file_lock);
+    get_file(oid, true, snapc);
+  }
+
+  return 0;
+}
+
 int TestMemIoCtxImpl::sparse_read(const std::string& oid, uint64_t off,
                                   uint64_t len,
                                   std::map<uint64_t,uint64_t> *m,
index e6082bbfa6935c451cca4db20d2be37c9e7bc728..e15eee5613556f217ff4080636a5e7cd21a73ce5 100644 (file)
@@ -52,6 +52,9 @@ public:
   int selfmanaged_snap_remove(uint64_t snapid) override;
   int selfmanaged_snap_rollback(const std::string& oid,
                                 uint64_t snapid) override;
+  int set_alloc_hint(const std::string& oid, uint64_t expected_object_size,
+                     uint64_t expected_write_size,
+                     const SnapContext &snapc) override;
   int sparse_read(const std::string& oid, uint64_t off, uint64_t len,
                   std::map<uint64_t,uint64_t> *m, bufferlist *data_bl) override;
   int stat(const std::string& oid, uint64_t *psize, time_t *pmtime) override;