From: Jianpeng Ma Date: Mon, 26 Jan 2015 02:01:22 +0000 (+0800) Subject: bufferlist: Refactor func get_contiguous. X-Git-Tag: v9.0.1~36^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b14e7d35d3879426897d74534c5e6466879c6358;p=ceph.git bufferlist: Refactor func get_contiguous. Now it can rebuild the related prt not all prt Signed-off-by: Jianpeng Ma --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 88656e836bd..b62856f4540 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -1483,9 +1483,24 @@ void buffer::list::rebuild_page_aligned() } if (off + len > curbuf->length()) { - // FIXME we'll just rebuild the whole list for now. - rebuild(); - return c_str() + orig_off; + bufferlist tmp; + unsigned l = off + len; + + do { + if (l >= curbuf->length()) + l -= curbuf->length(); + else + l = 0; + tmp.append(*curbuf); + curbuf = _buffers.erase(curbuf); + + } while (curbuf != _buffers.end() && l > 0); + + assert(l == 0); + + tmp.rebuild(); + _buffers.insert(curbuf, tmp._buffers.front()); + return tmp.c_str() + off; } return curbuf->c_str() + off;