From: Sage Weil Date: Wed, 6 Jan 2016 17:57:12 +0000 (-0500) Subject: os/bluestore/BlockDevice: make pread() safe X-Git-Tag: v10.0.3~88^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b98ed828162ce00f334e6afc9e9a0801c0ab23d7;p=ceph.git os/bluestore/BlockDevice: make pread() safe Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlockDevice.cc b/src/os/bluestore/BlockDevice.cc index 13607ad2b84c4..33370bf495052 100644 --- a/src/os/bluestore/BlockDevice.cc +++ b/src/os/bluestore/BlockDevice.cc @@ -496,14 +496,21 @@ int BlockDevice::read_buffered(uint64_t off, uint64_t len, char *buf) assert(off < size); assert(off + len <= size); - int r = ::pread(fd_buffered, buf, len, off); - if (r < 0) { - r = -errno; - goto out; + int r = 0; + char *t = buf; + uint64_t left = len; + while (left > 0) { + r = ::pread(fd_buffered, t, left, off); + if (r < 0) { + r = -errno; + goto out; + } + off += r; + t += r; + left -= r; } - assert(r == len); - dout(40) << "data: "; + dout(40) << __func__ << " data: "; bufferlist bl; bl.append(buf, len); bl.hexdump(*_dout);