From: dongdong tao Date: Sun, 10 Jun 2018 23:09:35 +0000 (+0800) Subject: osdc: optimize the code doing the BufferHead mapping X-Git-Tag: v14.0.1~1075^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5a92c70a471489d9a0265d9c832a4d1a496c99a2;p=ceph.git osdc: optimize the code doing the BufferHead mapping get rid of the "newbl" Signed-off-by: dongdong tao --- diff --git a/src/osdc/ObjectCacher.cc b/src/osdc/ObjectCacher.cc index 50f9a8d6a6c07..8d524ca089879 100644 --- a/src/osdc/ObjectCacher.cc +++ b/src/osdc/ObjectCacher.cc @@ -1733,15 +1733,13 @@ int ObjectCacher::writex(OSDWrite *wr, ObjectSet *oset, Context *onfreespace, // get the frag we're mapping in bufferlist frag; - frag.substr_of(wr->bl, - f_it->first, f_it->second); + frag.substr_of(wr->bl, f_it->first, f_it->second); // keep anything left of bhoff - bufferlist newbl; - if (bhoff) - newbl.substr_of(bh->bl, 0, bhoff); - newbl.claim_append(frag); - bh->bl.swap(newbl); + if (!bhoff) + bh->bl.swap(frag); + else + bh->bl.claim_append(frag); opos += f_it->second; }