From: Sage Weil Date: Mon, 23 Jan 2017 16:48:10 +0000 (-0500) Subject: os/bluestore/NVMEDevice: implement aio_read X-Git-Tag: v12.0.0~52^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=dbaa2b056ed4858f3443ddcb0bc91b6839ce3690;p=ceph.git os/bluestore/NVMEDevice: implement aio_read Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index fff462cd2c98..2f7731422312 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -942,6 +942,45 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, return r; } +int NVMEDevice::aio_read( + uint64_t off, + uint64_t len, + bufferlist *pbl, + IOContext *ioc) +{ + uint64_t len = bl.length(); + dout(20) << __func__ << " " << off << "~" << len << " ioc " << ioc << dendl; + assert(off % block_size == 0); + assert(len % block_size == 0); + assert(len > 0); + assert(off < size); + assert(off + len <= size); + + Task *t = new Task(this, IOCommand::READ_COMMAND, off, len); + + bufferptr p = buffer::create_page_aligned(len); + pbl->append(p); + int r = 0; + t->ctx = ioc; + char *buf = p.c_str(); + t->fill_cb = [buf, t]() { + t->copy_to_buf(buf, 0, t->len); + }; + + Task *first = static_cast(ioc->nvme_task_first); + Task *last = static_cast(ioc->nvme_task_last); + if (last) + last->next = t; + if (!first) + ioc->nvme_task_first = t; + ioc->nvme_task_last = t; + ++ioc->num_pending; + + return 0; +} + + + int NVMEDevice::read_random(uint64_t off, uint64_t len, char *buf, bool buffered) { assert(len > 0); diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 9593dd2343d5..10e3bb2d721e 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -225,9 +225,7 @@ class NVMEDevice : public BlockDevice { uint64_t off, uint64_t len, bufferlist *pbl, - IOContext *ioc) override { - assert(0 == "implement me"); - } + IOContext *ioc) override; int aio_write(uint64_t off, bufferlist& bl, IOContext *ioc, bool buffered) override;