From 91e986f21a8451ddb419b4f605a960c70efe44c6 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 octopus 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 871cd0e55e4cc..f984a7318ea08 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1946,8 +1946,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; } @@ -2059,8 +2060,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