]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: don't foreget invalidate cache of FileReaderBuffer.
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 7 Apr 2020 01:15:29 +0000 (09:15 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 7 Apr 2020 01:15:29 +0000 (09:15 +0800)
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 <jianpeng.ma@intel.com>
src/os/bluestore/BlueFS.h
src/os/bluestore/BlueRocksEnv.cc

index 4de478bb9a8d0ce3149a6d76b4153e8748955534..638c4a76f8ef0bd16396e2636fa930555eeb6f88 100644 (file)
@@ -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 {
index 7f2f8991b9e12e141c5c4d5c62f6f66aae99ec56..c7215caa1751e7354961c1a49da9ee0a1bcbe0b5 100644 (file)
@@ -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();
   }