From: weixinwei Date: Thu, 11 Feb 2021 02:31:11 +0000 (+0800) Subject: os/bluestore/BlueFS: use iterator_impl::copy instead of bufferlist::c_str() to avoid... X-Git-Tag: v16.2.0~118^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F39881%2Fhead;p=ceph.git os/bluestore/BlueFS: use iterator_impl::copy instead of bufferlist::c_str() to avoid bufferlist rebuild Signed-off-by: weixinwei (cherry picked from commit 8baa6ce567064a13b27e20b1a755bb2e5e871ebd) --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 8081b42e12b..f71e04da64c 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1772,8 +1772,9 @@ int64_t BlueFS::_read_random( << " 0x" << off << "~" << len << std::dec << dendl; - // NOTE: h->bl is normally a contiguous buffer so c_str() is free. - memcpy(out, buf->bl.c_str() + off - buf->bl_off, r); + auto p = buf->bl.begin(); + p.seek(off - buf->bl_off); + p.copy(r, out); out += r; dout(30) << __func__ << " result chunk (0x" @@ -1885,8 +1886,9 @@ int64_t BlueFS::_read( outbl->claim_append(t); } if (out) { - // NOTE: h->bl is normally a contiguous buffer so c_str() is free. - memcpy(out, buf->bl.c_str() + off - buf->bl_off, r); + auto p = buf->bl.begin(); + p.seek(off - buf->bl_off); + p.copy(r, out); out += r; }