From 9768120e9a60d8bf22cdd36eb2b92a943a466068 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Wed, 3 Nov 2021 18:13:49 +0000 Subject: [PATCH] blk, os/bluestore: introduce a cache bypassing to IOContext and BlueStore. Signed-off-by: Radoslaw Zarzynski --- src/blk/BlockDevice.h | 9 +++++++++ src/os/bluestore/BlueStore.cc | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/blk/BlockDevice.h b/src/blk/BlockDevice.h index 4eef1ef0df4cb..a82c4761c8bf1 100644 --- a/src/blk/BlockDevice.h +++ b/src/blk/BlockDevice.h @@ -73,6 +73,10 @@ std::ostream& operator<<(std::ostream& os, const blk_access_mode_t buffered); /// track in-flight io struct IOContext { + enum { + FLAG_DONT_CACHE = 1 + }; + private: ceph::mutex lock = ceph::make_mutex("IOContext::lock"); ceph::condition_variable cond; @@ -94,6 +98,7 @@ public: std::atomic_int num_pending = {0}; std::atomic_int num_running = {0}; bool allow_eio; + uint32_t flags = 0; // FLAG_* explicit IOContext(CephContext* cct, void *p, bool allow_eio = false) : cct(cct), priv(p), allow_eio(allow_eio) @@ -131,6 +136,10 @@ public: int get_return_value() const { return r; } + + bool skip_cache() const { + return flags & FLAG_DONT_CACHE; + } }; diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 89cc0713a44eb..ae4efa12b9a81 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -10812,7 +10812,8 @@ int BlueStore::_do_read( bool csum_error = false; r = _generate_read_result_bl(o, offset, length, ready_regions, compressed_blob_bls, blobs2read, - buffered, &csum_error, bl); + buffered && !ioc.skip_cache(), + &csum_error, bl); if (csum_error) { // Handles spurious read errors caused by a kernel bug. // We sometimes get all-zero pages as a result of the read under -- 2.39.5