]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: explicitly disable readahead for writearound cache 38602/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 15 Dec 2020 19:56:02 +0000 (14:56 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 15 Dec 2020 20:26:45 +0000 (15:26 -0500)
The readahead IOs would be wasted effort since the writearound
cache does not service reads.

Fixes: https://tracker.ceph.com/issues/48486
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/image/OpenRequest.cc

index c1856a0bf87b1921e022b41326d032aa36064e3f..99e00644b6d1a98fb28d7fedf6301db40889f65b 100644 (file)
@@ -769,8 +769,6 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) {
     ASSIGN_OPTION(non_blocking_aio, bool);
     ASSIGN_OPTION(cache, bool);
     ASSIGN_OPTION(sparse_read_threshold_bytes, Option::size_t);
-    ASSIGN_OPTION(readahead_max_bytes, Option::size_t);
-    ASSIGN_OPTION(readahead_disable_after_bytes, Option::size_t);
     ASSIGN_OPTION(clone_copy_on_read, bool);
     ASSIGN_OPTION(enable_alloc_hint, bool);
     ASSIGN_OPTION(mirroring_replay_delay, uint64_t);
@@ -780,6 +778,12 @@ librados::IoCtx duplicate_io_ctx(librados::IoCtx& io_ctx) {
     ASSIGN_OPTION(discard_granularity_bytes, uint64_t);
     ASSIGN_OPTION(blkin_trace_all, bool);
 
+    auto cache_policy = config.get_val<std::string>("rbd_cache_policy");
+    if (cache_policy == "writethrough" || cache_policy == "writeback") {
+      ASSIGN_OPTION(readahead_max_bytes, Option::size_t);
+      ASSIGN_OPTION(readahead_disable_after_bytes, Option::size_t);
+    }
+
 #undef ASSIGN_OPTION
 
     if (sparse_read_threshold_bytes == 0) {
index 99bce5961aee0890369e4f1c643801c424965104..cc7a914a0e78e55d7d56fb3ae6c08ef3b4b54f5a 100644 (file)
@@ -214,8 +214,8 @@ namespace librbd {
     bool non_blocking_aio;
     bool cache;
     uint64_t sparse_read_threshold_bytes;
-    uint64_t readahead_max_bytes;
-    uint64_t readahead_disable_after_bytes;
+    uint64_t readahead_max_bytes = 0;
+    uint64_t readahead_disable_after_bytes = 0;
     bool clone_copy_on_read;
     bool enable_alloc_hint;
     uint32_t alloc_hint_flags = 0U;
index 9b8e098108339cd0fda8402e694ed555fbd242e6..d34dd9ec89793ffaea1b2976565a2d488b68211f 100644 (file)
@@ -576,6 +576,8 @@ Context *OpenRequest<I>::send_init_cache(int *result) {
     auto cache = cache::WriteAroundObjectDispatch<I>::create(
       m_image_ctx, max_dirty, writethrough_until_flush);
     cache->init();
+
+    m_image_ctx->readahead.set_max_readahead_size(0);
   } else if (cache_policy == "writethrough" || cache_policy == "writeback") {
     if (cache_policy == "writethrough") {
       max_dirty = 0;