From: Sage Weil Date: Mon, 23 Jan 2017 15:14:39 +0000 (-0500) Subject: os/bluestore/BlockDevice: add aio_read API X-Git-Tag: v12.0.0~52^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4aeaaabb67674dfcb1bfba4436ae45677e820861;p=ceph.git os/bluestore/BlockDevice: add aio_read API NVMEDevice not implemented yet. Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 3f08cd49b5a1..603ab26d8c11 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -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); diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 950eada7c258..c9cde7868e30 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -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; iappend(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); diff --git a/src/os/bluestore/KernelDevice.h b/src/os/bluestore/KernelDevice.h index 8d5874815981..e418b16bc3d7 100644 --- a/src/os/bluestore/KernelDevice.h +++ b/src/os/bluestore/KernelDevice.h @@ -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, diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 094de3f41de9..9593dd2343d5 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -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;