From acda0fd88a4cdd94b973bb7dd88687d330278f6b Mon Sep 17 00:00:00 2001 From: weixinwei Date: Thu, 11 Feb 2021 10:31:11 +0800 Subject: [PATCH] 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) Conflicts: src/os/bluestore/BlueFS.cc the line is wrapped in "if (out) {}" in nautilus but is otherwise identical --- src/os/bluestore/BlueFS.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index f7bda939ae4ce..444138c753943 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1745,8 +1745,9 @@ int64_t BlueFS::_read_random( << dendl; 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; } @@ -1864,8 +1865,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; } -- 2.39.5