From: Jianpeng Ma Date: Fri, 29 Apr 2016 11:30:24 +0000 (+0800) Subject: common/buffer: Change rebuild_aligned_* & rebuild_page_aligned API. X-Git-Tag: v11.0.0~622^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c82e08692e3e73a9c0d3d4c5058da8160d2c0735;p=ceph.git common/buffer: Change rebuild_aligned_* & rebuild_page_aligned API. Make those func return value from void to bool. Using the return value we can know whether really rebuild content in order to optimize . Signed-off-by: Jianpeng Ma --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 2e6d0097c9d9..651a3687fa97 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -1519,14 +1519,15 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; last_p = begin(); } - void buffer::list::rebuild_aligned(unsigned align) + bool buffer::list::rebuild_aligned(unsigned align) { - rebuild_aligned_size_and_memory(align, align); + return rebuild_aligned_size_and_memory(align, align); } - void buffer::list::rebuild_aligned_size_and_memory(unsigned align_size, + bool buffer::list::rebuild_aligned_size_and_memory(unsigned align_size, unsigned align_memory) { + unsigned old_memcopy_count = _memcopy_count; std::list::iterator p = _buffers.begin(); while (p != _buffers.end()) { // keep anything that's already align and sized aligned @@ -1565,11 +1566,13 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER; _buffers.insert(p, unaligned._buffers.front()); } last_p = begin(); + + return (old_memcopy_count != _memcopy_count); } - void buffer::list::rebuild_page_aligned() + bool buffer::list::rebuild_page_aligned() { - rebuild_aligned(CEPH_PAGE_SIZE); + return rebuild_aligned(CEPH_PAGE_SIZE); } // sort-of-like-assignment-op diff --git a/src/include/buffer.h b/src/include/buffer.h index 363cf6354255..37c40423bd4b 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -483,10 +483,10 @@ namespace buffer CEPH_BUFFER_API { bool is_contiguous() const; void rebuild(); void rebuild(ptr& nb); - void rebuild_aligned(unsigned align); - void rebuild_aligned_size_and_memory(unsigned align_size, + bool rebuild_aligned(unsigned align); + bool rebuild_aligned_size_and_memory(unsigned align_size, unsigned align_memory); - void rebuild_page_aligned(); + bool rebuild_page_aligned(); // assignment-op with move semantics const static unsigned int CLAIM_DEFAULT = 0;