]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/rbm: add do_mount() and use it in derived classes
authormyoungwon oh <ohmyoungwon@gmail.com>
Fri, 24 Feb 2023 12:18:38 +0000 (21:18 +0900)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sat, 25 Feb 2023 04:19:04 +0000 (13:19 +0900)
Signed-off-by: Myoungwon Oh <myoungwon.oh@samsung.com>
src/crimson/os/seastore/random_block_manager/nvme_block_device.cc
src/crimson/os/seastore/random_block_manager/rbm_device.cc
src/crimson/os/seastore/random_block_manager/rbm_device.h

index 754377ba47e776a56a48c34af2ce5902375a4cf4..44a8c10416975f59a971038014cbb3ab708c71a0 100644 (file)
@@ -82,25 +82,7 @@ open_ertr::future<> NVMeBlockDevice::open_for_io(
 NVMeBlockDevice::mount_ret NVMeBlockDevice::mount()
 {
   logger().debug(" mount ");
-  return open(device_path, seastar::open_flags::rw | seastar::open_flags::dsync
-  ).safe_then([this] {
-    return stat_device(
-    ).handle_error(
-      mount_ertr::pass_further{},
-      crimson::ct_error::assert_all{
-      "Invalid error stat_device in RBMDevice::mount"}
-    ).safe_then([this](auto st) {
-      super.block_size = st.block_size;
-      return read_rbm_header(RBM_START_ADDRESS
-      ).safe_then([](auto s) {
-       return seastar::now();
-      });
-    });
-  }).handle_error(
-    mount_ertr::pass_further{},
-    crimson::ct_error::assert_all{
-    "Invalid error mount in NVMeBlockDevice::mount"}
-  );
+  return do_mount();
 }
 
 write_ertr::future<> NVMeBlockDevice::write(
index d5e8827f11225d5d828039938ad9f66b828657fc..13861143898b60f0bc27d045734b096dc5a97b9b 100644 (file)
@@ -129,6 +129,30 @@ read_ertr::future<rbm_metadata_header_t> RBMDevice::read_rbm_header(
   });
 }
 
+RBMDevice::mount_ret RBMDevice::do_mount()
+{
+  return open(get_device_path(),
+    seastar::open_flags::rw | seastar::open_flags::dsync
+  ).safe_then([this] {
+    return stat_device(
+    ).handle_error(
+      mount_ertr::pass_further{},
+      crimson::ct_error::assert_all{
+      "Invalid error stat_device in RBMDevice::mount"}
+    ).safe_then([this](auto st) {
+      super.block_size = st.block_size;
+      return read_rbm_header(RBM_START_ADDRESS
+      ).safe_then([](auto s) {
+       return seastar::now();
+      });
+    });
+  }).handle_error(
+    mount_ertr::pass_further{},
+    crimson::ct_error::assert_all{
+    "Invalid error mount in NVMeBlockDevice::mount"}
+  );
+}
+
 EphemeralRBMDeviceRef create_test_ephemeral(uint64_t journal_size, uint64_t data_size) {
   return EphemeralRBMDeviceRef(
     new EphemeralRBMDevice(journal_size + data_size + 
index 1076afe75cedc24afe6a60ed6d17efedabd94920..0122b2773bec467c8bb9121a53806f228fb3dc14 100644 (file)
@@ -152,6 +152,8 @@ public:
 
   mkfs_ret do_mkfs(device_config_t);
 
+  mount_ret do_mount();
+
   write_ertr::future<> write_rbm_header();
 
   read_ertr::future<rbm_metadata_header_t> read_rbm_header(rbm_abs_addr addr);
@@ -199,19 +201,7 @@ public:
   extent_len_t get_block_size() const final { return block_size; }
 
   mount_ret mount() final {
-    return open("", seastar::open_flags::rw
-    ).safe_then([this]() {
-      super.block_size = TEST_BLOCK_SIZE;
-      return read_rbm_header(RBM_START_ADDRESS
-      ).safe_then([](auto s) {
-       return seastar::now();
-      });
-    }).handle_error(
-      mount_ertr::pass_further{},
-      crimson::ct_error::assert_all{
-       "Invalid error mount"
-      }
-    );
+    return do_mount();
   }
 
   mkfs_ret mkfs(device_config_t config) final {