]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlockDevice: add aio_read API
authorSage Weil <sage@redhat.com>
Mon, 23 Jan 2017 15:14:39 +0000 (10:14 -0500)
committerSage Weil <sage@redhat.com>
Fri, 27 Jan 2017 15:26:15 +0000 (10:26 -0500)
NVMEDevice not implemented yet.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlockDevice.h
src/os/bluestore/KernelDevice.cc
src/os/bluestore/KernelDevice.h
src/os/bluestore/NVMEDevice.h

index 3f08cd49b5a1a0fe0bbb8365e05079a1f4beab37..603ab26d8c11e0a16550345f26652f2d0958b19c 100644 (file)
@@ -94,13 +94,28 @@ public:
   virtual uint64_t get_size() const = 0;
   virtual uint64_t get_block_size() const = 0;
 
-  virtual int read(uint64_t off, uint64_t len, bufferlist *pbl,
-          IOContext *ioc, bool buffered) = 0;
-  virtual int read_random(uint64_t off, uint64_t len, char *buf,
-           bool buffered) = 0;
-
-  virtual int aio_write(uint64_t off, bufferlist& bl,
-               IOContext *ioc, bool buffered) = 0;
+  virtual int read(
+    uint64_t off,
+    uint64_t len,
+    bufferlist *pbl,
+    IOContext *ioc,
+    bool buffered) = 0;
+  virtual int read_random(
+    uint64_t off,
+    uint64_t len,
+    char *buf,
+    bool buffered) = 0;
+
+  virtual int aio_read(
+    uint64_t off,
+    uint64_t len,
+    bufferlist *pbl,
+    IOContext *ioc) = 0;
+  virtual int aio_write(
+    uint64_t off,
+    bufferlist& bl,
+    IOContext *ioc,
+    bool buffered) = 0;
   virtual int flush() = 0;
 
   void queue_reap_ioc(IOContext *ioc);
index 950eada7c258e958ebc4a208256a790e4d1702cd..c9cde7868e305a49cea86b2f83a02a5f27765ced 100644 (file)
@@ -551,6 +551,39 @@ int KernelDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
   return r < 0 ? r : 0;
 }
 
+int KernelDevice::aio_read(
+  uint64_t off,
+  uint64_t len,
+  bufferlist *pbl,
+  IOContext *ioc)
+{
+  dout(5) << __func__ << " 0x" << std::hex << off << "~" << len << std::dec
+         << dendl;
+
+  int r = 0;
+#ifdef HAVE_LIBAIO
+  if (aio && dio) {
+    _aio_log_start(ioc, off, len);
+    ioc->pending_aios.push_back(FS::aio_t(ioc, fd_direct));
+    ++ioc->num_pending;
+    FS::aio_t& aio = ioc->pending_aios.back();
+    aio.pread(off, len);
+    for (unsigned i=0; i<aio.iov.size(); ++i) {
+      dout(30) << "aio " << i << " " << aio.iov[i].iov_base
+              << " " << aio.iov[i].iov_len << dendl;
+    }
+    pbl->append(aio.bl);
+    dout(5) << __func__ << " 0x" << std::hex << off << "~" << len
+           << std::dec << " aio " << &aio << dendl;
+  } else
+#endif
+  {
+    r = read(off, len, pbl, ioc, false);
+  }
+
+  return r;
+}
+
 int KernelDevice::direct_read_unaligned(uint64_t off, uint64_t len, char *buf)
 {
   uint64_t aligned_off = align_down(off, block_size);
index 8d587481598106e2be61c1d1c2450cce4f4efbaa..e418b16bc3d79f589ffb70bbab66cfc7a28a9531 100644 (file)
@@ -86,6 +86,8 @@ public:
   int read(uint64_t off, uint64_t len, bufferlist *pbl,
           IOContext *ioc,
           bool buffered) override;
+  int aio_read(uint64_t off, uint64_t len, bufferlist *pbl,
+              IOContext *ioc) override;
   int read_random(uint64_t off, uint64_t len, char *buf, bool buffered) override;
 
   int aio_write(uint64_t off, bufferlist& bl,
index 094de3f41de9a7dd512969bc8b6c6c4d24273f6f..9593dd2343d502b2e2a437e52d30bab613c34944 100644 (file)
@@ -221,7 +221,13 @@ class NVMEDevice : public BlockDevice {
   int read(uint64_t off, uint64_t len, bufferlist *pbl,
            IOContext *ioc,
            bool buffered) override;
-
+  int aio_read(
+    uint64_t off,
+    uint64_t len,
+    bufferlist *pbl,
+    IOContext *ioc) override {
+    assert(0 == "implement me");
+  }
   int aio_write(uint64_t off, bufferlist& bl,
                 IOContext *ioc,
                 bool buffered) override;