]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common/buffer: For bufferlist add func is_aligned_size_and_memory.
authorJianpeng Ma <jianpeng.ma@intel.com>
Wed, 27 Apr 2016 23:31:14 +0000 (07:31 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Sat, 7 May 2016 23:17:26 +0000 (07:17 +0800)
For directIO requirement, we need check bufferpt whether size aligned
and the address aligned. To do this, we should call is_aligned &&
is_n_align_sized. Every func also list all ptr of bufferlist.
To reduce one list, we add is_aligned_size_and_memroy(align_size,
align_memory) which only need list once.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/common/buffer.cc
src/include/buffer.h

index 651a3687fa97893b7af5a9249258f626d9618a13..3557b3775d4f81471e91596c079443b171dd58a8 100644 (file)
@@ -1422,6 +1422,18 @@ static simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZER;
     return true;
   }
 
+  bool buffer::list::is_aligned_size_and_memory(unsigned align_size,
+                                                 unsigned align_memory) const
+  {
+    for (std::list<ptr>::const_iterator it = _buffers.begin();
+        it != _buffers.end();
+        ++it) {
+      if (!it->is_aligned(align_memory) || !it->is_n_align_sized(align_size))
+       return false;
+    }
+    return true;
+  }
+
   bool buffer::list::is_zero() const {
     for (std::list<ptr>::const_iterator it = _buffers.begin();
         it != _buffers.end();
index 37c40423bd4b2cd05f2f71cbe5a54b5588fc589d..4c5de1d486beb2380b7e5e58cffd4e66d96e4983 100644 (file)
@@ -436,6 +436,8 @@ namespace buffer CEPH_BUFFER_API {
     bool is_page_aligned() const;
     bool is_n_align_sized(unsigned align) const;
     bool is_n_page_sized() const;
+    bool is_aligned_size_and_memory(unsigned align_size,
+                                   unsigned align_memory) const;
 
     bool is_zero() const;