From 225d3cdb272ef452351e9193a24b3f9625a964fc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 22 Dec 2015 16:11:32 -0500 Subject: [PATCH] os/bluestore/BlockDevice: add invalidate_cache Signed-off-by: Sage Weil --- src/os/bluestore/BlockDevice.cc | 14 ++++++++++++++ src/os/bluestore/BlockDevice.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index 2a74463c4fa18..9af3bec3c34a5 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -455,3 +455,17 @@ int BlockDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, } return r < 0 ? r : 0; } + +int BlockDevice::invalidate_cache(uint64_t off, uint64_t len) +{ + dout(5) << __func__ << " " << off << "~" << len << dendl; + assert(off % block_size == 0); + assert(len % block_size == 0); + int r = posix_fadvise(fd_buffered, off, len, POSIX_FADV_DONTNEED); + if (r < 0) { + r = -errno; + derr << __func__ << " " << off << "~" << len << " error: " + << cpp_strerror(r) << dendl; + } + return r; +} diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 7bfb65e3c0167..83c55b50bee01 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -101,6 +101,8 @@ public: IOContext *ioc); int flush(); + // for managing buffered readers/writers + int invalidate_cache(uint64_t off, uint64_t len); int open(string path); void close(); }; -- 2.39.5