]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlockDevice: add invalidate_cache
authorSage Weil <sage@redhat.com>
Tue, 22 Dec 2015 21:11:32 +0000 (16:11 -0500)
committerSage Weil <sage@redhat.com>
Fri, 1 Jan 2016 18:07:26 +0000 (13:07 -0500)
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlockDevice.cc
src/os/bluestore/BlockDevice.h

index 2a74463c4fa18727d5f69c7774825d30c1ee06ab..9af3bec3c34a55ddb541bda0c9a2ef41a5c107f9 100644 (file)
@@ -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;
+}
index 7bfb65e3c0167756b2b08dee30283e9157ebcef2..83c55b50bee010c7850681db00e3825cf385a243 100644 (file)
@@ -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();
 };