]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/buffer: Change rebuild_aligned_* & rebuild_page_aligned API.
authorJianpeng Ma <jianpeng.ma@intel.com>
Fri, 29 Apr 2016 11:30:24 +0000 (19:30 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Sat, 7 May 2016 22:41:24 +0000 (06:41 +0800)
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 <jianpeng.ma@intel.com>
src/common/buffer.cc
src/include/buffer.h

index 2e6d0097c9d9555ab34bdf2852e9c92da8fecdd2..651a3687fa97893b7af5a9249258f626d9618a13 100644 (file)
@@ -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<ptr>::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
index 363cf635425562258d7bc25a48dfd1bfeae39dd9..37c40423bd4b2cd05f2f71cbe5a54b5588fc589d 100644 (file)
@@ -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;