]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
seastore/rbm: fix wrong statement
authormyoungwon oh <ohmyoungwon@gmail.com>
Thu, 10 Jun 2021 07:09:06 +0000 (16:09 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Tue, 15 Jun 2021 02:09:06 +0000 (11:09 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/randomblock_manager.cc
src/test/crimson/seastore/test_randomblock_manager.cc

index 1ccaa19024ffa2cd8da4ab9e182e75a7e60e9997..b2aec77bd3e6fc11e9e1ea24cceb53ce2bb8d748 100644 (file)
@@ -434,11 +434,7 @@ RandomBlockManager::write_ertr::future<> RandomBlockManager::complete_allocation
            }
          }
          logger().debug("complete_alloction: complete to allocate {} blocks", alloc_block_count);
-         if (alloc_block_count > 0) {
-           super.free_block_count -= alloc_block_count;
-         } else {
-           super.free_block_count += alloc_block_count;
-         }
+         super.free_block_count -= alloc_block_count;
          return write_ertr::now();
          });
   });
index 43ad88ef3a35177ab2891ed4ecbe4c4a740eec06..66339d22e3aee6c422229ba54d8b23a1c67722b9 100644 (file)
@@ -331,5 +331,20 @@ TEST_F(rbm_test_t, check_free_blocks)
    rbm_manager->rbm_sync_block_bitmap_by_range(10, 12, bitmap_op_types_t::ALL_SET).unsafe_get0();
    rbm_manager->check_bitmap_blocks().unsafe_get0();
    ASSERT_TRUE(rbm_manager->get_free_blocks() == DEFAULT_TEST_SIZE/DEFAULT_BLOCK_SIZE - 5);
+   auto free = rbm_manager->get_free_blocks();
+   interval_set<blk_id_t> alloc_ids;
+   auto t = tm->create_transaction();
+   alloc_extent(*t, DEFAULT_BLOCK_SIZE * 4);
+   alloc_ids = get_allocated_blk_ids(*t);
+   ASSERT_TRUE(submit_transaction(*t));
+   complete_allocation(*t);
+   ASSERT_TRUE(rbm_manager->get_free_blocks() == free - 4);
+
+   free = rbm_manager->get_free_blocks();
+   auto t2 = tm->create_transaction();
+   free_extent(*t2, alloc_ids);
+   ASSERT_TRUE(submit_transaction(*t2));
+   complete_allocation(*t2);
+   ASSERT_TRUE(rbm_manager->get_free_blocks() == free + 4);
  });
 }