From cfc8f4c2e70d26c64700b773f752bd8f9ea109ad Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 4 Jan 2016 13:42:06 -0500 Subject: [PATCH] os/bluestore/BlockDevice: read_buffered Signed-off-by: Sage Weil --- src/os/bluestore/BlockDevice.cc | 24 ++++++++++++++++++++++++ src/os/bluestore/BlockDevice.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index 1d7656b49ee12..a4975c1450ba9 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -474,6 +474,30 @@ int BlockDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, return r < 0 ? r : 0; } +int BlockDevice::read_buffered(uint64_t off, uint64_t len, char *buf) +{ + dout(5) << __func__ << " " << off << "~" << len << dendl; + assert(len > 0); + assert(off < size); + assert(off + len <= size); + + int r = ::pread(fd_buffered, buf, len, off); + if (r < 0) { + r = -errno; + goto out; + } + assert(r == len); + + dout(40) << "data: "; + bufferlist bl; + bl.append(buf, len); + bl.hexdump(*_dout); + *_dout << dendl; + + out: + return r < 0 ? r : 0; +} + int BlockDevice::invalidate_cache(uint64_t off, uint64_t len) { dout(5) << __func__ << " " << off << "~" << len << dendl; diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 187a7f57fe59e..f5acc1113d954 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -97,6 +97,7 @@ public: int read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, bool buffered); + int read_buffered(uint64_t off, uint64_t len, char *buf); int aio_write(uint64_t off, bufferlist& bl, IOContext *ioc, -- 2.39.5