]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore/rbm: call device.open() before rbm.open() or rbm.mkfs()
authormyoungwon oh <ohmyoungwon@gmail.com>
Tue, 6 Sep 2022 02:47:41 +0000 (11:47 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Wed, 7 Sep 2022 05:58:33 +0000 (14:58 +0900)
This commit also deletes open_device() in rbn.open()

Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/random_block_manager.h
src/crimson/os/seastore/random_block_manager/block_rb_manager.cc
src/crimson/os/seastore/random_block_manager/block_rb_manager.h
src/test/crimson/seastore/test_randomblock_manager.cc

index 9cb7dbcbcb5700aaec3d15f162f42dfc3818a3c0..f9922f75458cccf211c9b0066e8a17e8a2bdde1c 100644 (file)
@@ -61,7 +61,7 @@ public:
     crimson::ct_error::input_output_error,
     crimson::ct_error::invarg,
     crimson::ct_error::enoent>;
-  virtual open_ertr::future<> open(const std::string &path, paddr_t start) = 0;
+  virtual open_ertr::future<> open() = 0;
 
   using close_ertr = crimson::errorator<
     crimson::ct_error::input_output_error,
index 0163e8668db33a94885cca4a4b43547fb139bfa4..f51fa08ca144ea6de1f09773e124c2593a0a488e 100644 (file)
@@ -121,14 +121,14 @@ BlockRBManager::mkfs_ertr::future<> BlockRBManager::mkfs(mkfs_config_t config)
 {
   LOG_PREFIX(BlockRBManager::mkfs);
   DEBUG("path {}", path);
-  return _open_device(path).safe_then([this, &config, FNAME]() {
+  return _open_device(path).safe_then([this, config, FNAME]() {
     rbm_abs_addr addr = convert_paddr_to_abs_addr(
       config.start);
     return read_rbm_header(addr).safe_then([FNAME](auto super) {
       DEBUG("already exists ");
       return mkfs_ertr::now();
     }).handle_error(
-      crimson::ct_error::enoent::handle([this, &config, FNAME](auto) {
+      crimson::ct_error::enoent::handle([this, config, FNAME](auto) {
        super.uuid = uuid_d(); // TODO
        super.magic = 0xFF; // TODO
        super.start = convert_paddr_to_abs_addr(
@@ -474,30 +474,24 @@ BlockRBManager::write_ertr::future<> BlockRBManager::sync_allocation(
   });
 }
 
-BlockRBManager::open_ertr::future<> BlockRBManager::open(
-    const std::string &path, paddr_t paddr)
+BlockRBManager::open_ertr::future<> BlockRBManager::open()
 {
-  LOG_PREFIX(BlockRBManager::open);
-  DEBUG("open: path{}", path);
-  rbm_abs_addr addr = convert_paddr_to_abs_addr(paddr);
-  return _open_device(path
-  ).safe_then([this, addr]() {
-    return read_rbm_header(addr).safe_then([&](auto s)
-      -> open_ertr::future<> {
-      if (s.magic != 0xFF) {
-       return crimson::ct_error::enoent::make();
-      }
-      super = s;
-      return check_bitmap_blocks().safe_then([]() {
-       return open_ertr::now();
-         });
-    }).handle_error(
-      open_ertr::pass_further{},
-      crimson::ct_error::assert_all{
-       "Invalid error read_rbm_header in BlockRBManager::open"
-      }
-    );
-  });
+  return read_rbm_header(RBM_START_ADDRESS
+  ).safe_then([&](auto s)
+    -> open_ertr::future<> {
+    if (s.magic != 0xFF) {
+      return crimson::ct_error::enoent::make();
+    }
+    super = s;
+    return check_bitmap_blocks().safe_then([]() {
+      return open_ertr::now();
+    });
+  }).handle_error(
+    open_ertr::pass_further{},
+    crimson::ct_error::assert_all{
+      "Invalid error read_rbm_header in BlockRBManager::open"
+    }
+  );
 }
 
 BlockRBManager::write_ertr::future<> BlockRBManager::write(
index d81685cb4d81780f277272dd160d635a239f5b5e..da575fc61f404362a5705f18ccf1169ed2b7565a 100644 (file)
@@ -24,6 +24,7 @@
 
 namespace crimson::os::seastore {
 
+constexpr rbm_abs_addr RBM_START_ADDRESS = 0;
 constexpr uint32_t RBM_SUPERBLOCK_SIZE = 4096;
 
 using RBMDevice = random_block_device::RBMDevice;
@@ -186,7 +187,7 @@ public:
   mkfs_ertr::future<> mkfs(mkfs_config_t) final;
   read_ertr::future<> read(paddr_t addr, bufferptr &buffer) final;
   write_ertr::future<> write(paddr_t addr, bufferptr &buf) final;
-  open_ertr::future<> open(const std::string &path, paddr_t start) final;
+  open_ertr::future<> open() final;
   close_ertr::future<> close() final;
 
   /*
index 539ea16ff499f68a709cabce1b34bb29abf06091..c57b4e6069858970fc01b1e7ff20263b1006eb6d 100644 (file)
@@ -53,17 +53,26 @@ struct rbm_test_t :
 
   seastar::future<> set_up_fut() final {
     device.reset(new random_block_device::TestMemory(DEFAULT_TEST_SIZE));
-    rbm_manager.reset(new BlockRBManager(device.get(), std::string()));
     device_id_t d_id = 1 << (std::numeric_limits<device_id_t>::digits - 1);
+    device->set_device_id(d_id);
+    rbm_manager.reset(new BlockRBManager(device.get(), std::string()));
     config.start = paddr_t::make_blk_paddr(d_id, 0);
     config.end = paddr_t::make_blk_paddr(d_id, DEFAULT_TEST_SIZE);
     config.block_size = DEFAULT_BLOCK_SIZE;
     config.total_size = DEFAULT_TEST_SIZE;
     config.device_id = d_id;
-    return seastar::now();
+    return device->mount().handle_error(crimson::ct_error::assert_all{}
+    ).then([this] {
+      return rbm_manager->mkfs(config).handle_error(crimson::ct_error::assert_all{}
+      ).then([this] {
+       return rbm_manager->open().handle_error(crimson::ct_error::assert_all{});
+      });
+    });
   }
 
   seastar::future<> tear_down_fut() final {
+    rbm_manager->close().unsafe_get0();
+    device->close().unsafe_get0();
     rbm_manager.reset();
     device.reset();
     return seastar::now();
@@ -79,7 +88,7 @@ struct rbm_test_t :
   }
 
   auto open() {
-    return rbm_manager->open("", config.start).unsafe_get0();
+    return rbm_manager->open().unsafe_get0();
   }
 
   auto write(uint64_t addr, bufferptr &ptr) {
@@ -196,8 +205,6 @@ struct rbm_test_t :
 TEST_F(rbm_test_t, mkfs_test)
 {
  run_async([this] {
-   mkfs();
-   open();
    auto super = read_rbm_header();
    ASSERT_TRUE(
        super.block_size == DEFAULT_BLOCK_SIZE &&
@@ -213,8 +220,6 @@ TEST_F(rbm_test_t, mkfs_test)
 TEST_F(rbm_test_t, open_test)
 {
  run_async([this] {
-   mkfs();
-   open();
    auto content = generate_extent(1);
    write(
        DEFAULT_BLOCK_SIZE,
@@ -239,8 +244,6 @@ TEST_F(rbm_test_t, open_test)
 TEST_F(rbm_test_t, block_alloc_test)
 {
  run_async([this] {
-   mkfs();
-   open();
    auto t = create_rbm_transaction();
    alloc_extent(*t, DEFAULT_BLOCK_SIZE);
    auto alloc_ids = get_allocated_blk_ids(*t);
@@ -258,8 +261,6 @@ TEST_F(rbm_test_t, block_alloc_test)
 TEST_F(rbm_test_t, block_alloc_free_test)
 {
  run_async([this] {
-   mkfs();
-   open();
    auto t = create_rbm_transaction();
    alloc_extent(*t, DEFAULT_BLOCK_SIZE);
    auto alloc_ids = get_allocated_blk_ids(*t);
@@ -295,6 +296,7 @@ TEST_F(rbm_test_t, many_block_alloc)
    config.end = paddr_t::make_blk_paddr(d_id, (DEFAULT_TEST_SIZE * 1024));
    config.block_size = DEFAULT_BLOCK_SIZE;
    config.total_size = DEFAULT_TEST_SIZE * 1024;
+   rbm_manager->close().unsafe_get0();
    mkfs();
    open();
    auto max = rbm_manager->max_block_by_bitmap_block();
@@ -347,8 +349,6 @@ TEST_F(rbm_test_t, many_block_alloc)
 TEST_F(rbm_test_t, check_free_blocks)
 {
  run_async([this] {
-   mkfs();
-   open();
    rbm_manager->rbm_sync_block_bitmap_by_range(10, 12, bitmap_op_types_t::ALL_SET).unsafe_get0();
    rbm_manager->close().unsafe_get0();
    open();