]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd: explicitly disable readahead for writearound cache 39962/head
authorJason Dillaman <dillaman@redhat.com>
Tue, 15 Dec 2020 19:56:02 +0000 (14:56 -0500)
committerJason Dillaman <dillaman@redhat.com>
Tue, 9 Mar 2021 21:15:48 +0000 (16:15 -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>
(cherry picked from commit b65f6b865044bffc4db07551caff9e81d6fa8f28)

src/librbd/ImageCtx.cc
src/librbd/ImageCtx.h
src/librbd/image/OpenRequest.cc

index 23beddedb88ff4b272166ddc1abc087e5643604f..10480560747a7f7bd2b07ec58d418e2c15466a73 100644 (file)
@@ -776,8 +776,6 @@ public:
     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);
@@ -787,6 +785,12 @@ public:
     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 1218f8380a6bb444560db255eb4d7b416325b5e0..c726ae75c2bd5188f7c0f8087c05a40c0a6fdce3 100644 (file)
@@ -203,8 +203,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 2edf2b14fe13566946952a56ace041debe1dd18a..bf83b65cde4292b7a1cf5651583a5bdf799386f4 100644 (file)
@@ -582,6 +582,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;