From: Jianpeng Ma Date: Tue, 7 Apr 2020 01:15:29 +0000 (+0800) Subject: os/bluestore: don't foreget invalidate cache of FileReaderBuffer. X-Git-Tag: v16.1.0~2623^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c0674a1de19058dbcd79776bad61092213453399;p=ceph.git os/bluestore: don't foreget invalidate cache of FileReaderBuffer. For BlueRocksSequentialFile & BlueRocksRandomAccessFile, except kernel page cache they still use FileReaderBuffer to cache data. So if invalidate cache, it should check cache of FileRaderBuffer. Signed-off-by: Jianpeng Ma --- diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 4de478bb9a8..638c4a76f8e 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -236,6 +236,15 @@ public: void skip(size_t n) { pos += n; } + + // For the sake of simplicity, we invalidate completed rather than + // for the provided extent + void invalidate_cache(uint64_t offset, uint64_t length) { + if (offset >= bl_off && offset < get_buf_end()) { + bl.clear(); + bl_off = 0; + } + } }; struct FileReader { diff --git a/src/os/bluestore/BlueRocksEnv.cc b/src/os/bluestore/BlueRocksEnv.cc index 7f2f8991b9e..c7215caa175 100644 --- a/src/os/bluestore/BlueRocksEnv.cc +++ b/src/os/bluestore/BlueRocksEnv.cc @@ -69,6 +69,7 @@ class BlueRocksSequentialFile : public rocksdb::SequentialFile { // of this file. If the length is 0, then it refers to the end of file. // If the system is not caching the file contents, then this is a noop. rocksdb::Status InvalidateCache(size_t offset, size_t length) override { + h->buf.invalidate_cache(offset, length); fs->invalidate_cache(h->file, offset, length); return rocksdb::Status::OK(); } @@ -140,6 +141,7 @@ class BlueRocksRandomAccessFile : public rocksdb::RandomAccessFile { // of this file. If the length is 0, then it refers to the end of file. // If the system is not caching the file contents, then this is a noop. rocksdb::Status InvalidateCache(size_t offset, size_t length) override { + h->buf.invalidate_cache(offset, length); fs->invalidate_cache(h->file, offset, length); return rocksdb::Status::OK(); }