]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/cache: add read clean extents to cache
authorSamuel Just <sjust@redhat.com>
Mon, 1 Jun 2020 19:01:40 +0000 (12:01 -0700)
committerSamuel Just <sjust@redhat.com>
Tue, 2 Jun 2020 23:56:41 +0000 (16:56 -0700)
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/cache.h
src/test/crimson/seastore/test_seastore_cache.cc

index 043f9ae091234dff9cade639066977039bfda4dd..7f511217d10d9989708a1ac5df245491d003ed86 100644 (file)
@@ -195,9 +195,10 @@ public:
        offset,
        length,
        ref->get_bptr()).safe_then(
-         [ref=std::move(ref)]() mutable {
+         [this, ref=std::move(ref)]() mutable {
            ref->on_clean_read();
            ref->complete_io();
+           add_extent(ref);
            return get_extent_ertr::make_ready_future<TCachedExtentRef<T>>(
              std::move(ref));
          },
index d6ecd83435e1271c4bb8f09c4a64f6310e9ceef8..797d080e194f5e7e07a047a462a26da94a4288ef 100644 (file)
@@ -189,6 +189,20 @@ TEST_F(cache_test_t, test_dirty_extent)
       ASSERT_TRUE(ret);
       addr = extent->get_paddr();
     }
+    {
+      // test that consecutive reads on the same extent get the same ref
+      auto t = get_transaction();
+      auto extent = cache.get_extent<CacheTestBlock>(
+       *t,
+       addr,
+       CacheTestBlock::SIZE).unsafe_get0();
+      auto t2 = get_transaction();
+      auto extent2 = cache.get_extent<CacheTestBlock>(
+       *t2,
+       addr,
+       CacheTestBlock::SIZE).unsafe_get0();
+      ASSERT_EQ(&*extent, &*extent2);
+    }
     {
       // read back test block
       auto t = get_transaction();