]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: replace m_max_alloc_size with m_max_blocks
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 28 Dec 2016 06:23:35 +0000 (14:23 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Fri, 13 Jan 2017 03:52:26 +0000 (11:52 +0800)
So we can get rid of the annoying transfer each time we
try to add an extent into an ExtentList.
Also simplify the add_extents() method a little.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/bluestore_types.cc
src/os/bluestore/bluestore_types.h

index 36bcedbfd7fb622e937d19bc2369ad50ced23c66..e98ba7682e5ebd2b4b8338b478c05bd4ea9abfcc 100644 (file)
@@ -23,12 +23,10 @@ void ExtentList::add_extents(int64_t start, int64_t count) {
 
   if (m_num_extents > 0) {
     last_extent = &((*m_extents)[m_num_extents - 1]);
-    uint64_t last_offset = (last_extent->offset + last_extent->length) / 
-                       m_block_size; 
-    uint32_t last_length = last_extent->length / m_block_size; 
-    int64_t max_blocks = m_max_alloc_size / m_block_size;
+    uint64_t last_offset = last_extent->end() / m_block_size;
+    uint32_t last_length = last_extent->length / m_block_size;
     if ((last_offset == (uint64_t) start) &&
-        (!max_blocks || (last_length + count) <= max_blocks)) {
+        (!m_max_blocks || (last_length + count) <= m_max_blocks)) {
       can_merge = true;
     }
   }
index 20cda85d052893a03f467bb0a0005f3503e4eb9d..92596baa7f482c7ff265ee067749f5d5420a62f8 100644 (file)
@@ -84,14 +84,14 @@ class ExtentList {
   AllocExtentVector *m_extents;
   int64_t m_num_extents;
   int64_t m_block_size;
-  uint64_t m_max_alloc_size;
+  int64_t m_max_blocks;
 
 public:
   void init(AllocExtentVector *extents, int64_t block_size, uint64_t max_alloc_size) {
     m_extents = extents;
     m_num_extents = 0;
     m_block_size = block_size;
-    m_max_alloc_size = max_alloc_size;
+    m_max_blocks = max_alloc_size / block_size;
   }
 
   ExtentList(AllocExtentVector *extents, int64_t block_size) {