]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: errorate the FuturizedStore::mount() paths. 43592/head
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 19 Oct 2021 20:02:57 +0000 (20:02 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 19 Oct 2021 20:11:55 +0000 (20:11 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/os/alienstore/alien_store.cc
src/crimson/os/alienstore/alien_store.h
src/crimson/os/cyanstore/cyan_store.cc
src/crimson/os/cyanstore/cyan_store.h
src/crimson/os/futurized_store.h
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h
src/crimson/osd/osd.cc
src/test/crimson/seastore/transaction_manager_test_state.h

index 43ff8d354154edb6a65249714189472c38256b74..09df2e6f7045066d3013878e20c816b8e70b6b2e 100644 (file)
@@ -126,15 +126,19 @@ seastar::future<> AlienStore::stop()
 
 AlienStore::~AlienStore() = default;
 
-seastar::future<> AlienStore::mount()
+AlienStore::mount_ertr::future<> AlienStore::mount()
 {
   logger().debug("{}", __func__);
   assert(tp);
   return tp->submit([this] {
     return store->mount();
-  }).then([] (int r) {
-    assert(r == 0);
-    return seastar::now();
+  }).then([] (const int r) -> mount_ertr::future<> {
+    if (r != 0) {
+      return crimson::stateful_ec{
+        std::error_code(-r, std::generic_category()) };
+    } else {
+      return mount_ertr::now();
+    }
   });
 }
 
index b0ab87e254e689551ebe075000978330716d5482..0557dae77c28dcc3cce72163c99d815471902acb 100644 (file)
@@ -46,7 +46,7 @@ public:
 
   seastar::future<> start() final;
   seastar::future<> stop() final;
-  seastar::future<> mount() final;
+  mount_ertr::future<> mount() final;
   seastar::future<> umount() final;
 
   mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final;
index f26136675949189165bcf8bea7f34fb4c9ddce5c..9122a56c0b005f75c9d7e61f1ba09de34b57cb6a 100644 (file)
@@ -53,13 +53,14 @@ private:
   };
 };
 
-seastar::future<> CyanStore::mount()
+CyanStore::mount_ertr::future<> CyanStore::mount()
 {
+  static const char read_file_errmsg[]{"read_file"};
   ceph::bufferlist bl;
   std::string fn = path + "/collections";
   std::string err;
   if (int r = bl.read_file(fn.c_str(), &err); r < 0) {
-    throw std::runtime_error("read_file");
+    return crimson::stateful_ec{ singleton_ec<read_file_errmsg>() };
   }
 
   std::set<coll_t> collections;
@@ -70,7 +71,7 @@ seastar::future<> CyanStore::mount()
     std::string fn = fmt::format("{}/{}", path, coll);
     ceph::bufferlist cbl;
     if (int r = cbl.read_file(fn.c_str(), &err); r < 0) {
-      throw std::runtime_error("read_file");
+      return crimson::stateful_ec{ singleton_ec<read_file_errmsg>() };
     }
     boost::intrusive_ptr<Collection> c{new Collection{coll}};
     auto p = cbl.cbegin();
@@ -78,7 +79,7 @@ seastar::future<> CyanStore::mount()
     coll_map[coll] = c;
     used_bytes += c->used_bytes();
   }
-  return seastar::now();
+  return mount_ertr::now();
 }
 
 seastar::future<> CyanStore::umount()
index d4881202c600ba7708b9aad0faa4109d0cf5daa4..492801e5a13beaf05414929bf8ce660cff051156 100644 (file)
@@ -68,7 +68,7 @@ public:
   seastar::future<> stop() final {
     return seastar::now();
   }
-  seastar::future<> mount() final;
+  mount_ertr::future<> mount() final;
   seastar::future<> umount() final;
 
   mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final;
index b4dced9dc87cdb154373f9ece0379e2c44b7792b..02e891254ac03964d1a82ba3b85e1a1e41296e57 100644 (file)
@@ -65,7 +65,9 @@ public:
     return seastar::now();
   }
   virtual seastar::future<> stop() = 0;
-  virtual seastar::future<> mount() = 0;
+
+  using mount_ertr = crimson::errorator<crimson::stateful_ec>;
+  virtual mount_ertr::future<> mount() = 0;
   virtual seastar::future<> umount() = 0;
 
   using mkfs_ertr = crimson::errorator<crimson::stateful_ec>;
index 0a81fd63daf42dc8149ee1cce71fc77a6c41678c..3ccf0e099a5a77eaaf7b1d860c02d69405018b98 100644 (file)
@@ -88,7 +88,7 @@ seastar::future<> SeaStore::stop()
   return seastar::now();
 }
 
-seastar::future<> SeaStore::mount()
+SeaStore::mount_ertr::future<> SeaStore::mount()
 {
   return segment_manager->mount(
   ).safe_then([this] {
index f21e2832fab417fa9534fcdb51eaa7108d69ea9e..f5dce812351477a5caf165f12d0db7d8da82c2bb 100644 (file)
@@ -50,7 +50,7 @@ public:
   ~SeaStore();
     
   seastar::future<> stop() final;
-  seastar::future<> mount() final;
+  mount_ertr::future<> mount() final;
   seastar::future<> umount() final;
 
   mkfs_ertr::future<> mkfs(uuid_d new_osd_fsid) final;
index 02ef518bb3197620a4ff5f1798136ffb391f14bb..b5a263eeea16177e0979afb3310ba6208b413456 100644 (file)
@@ -161,7 +161,13 @@ seastar::future<> OSD::mkfs(uuid_d osd_uuid, uuid_d cluster_fsid)
         std::exit(EXIT_FAILURE);
       }));
   }).then([this] {
-    return store.mount();
+    return store.mount().handle_error(
+      crimson::stateful_ec::handle([] (const auto& ec) {
+        logger().error("error mounting object store in {}: ({}) {}",
+                       local_conf().get_val<std::string>("osd_data"),
+                       ec.value(), ec.message());
+        std::exit(EXIT_FAILURE);
+      }));
   }).then([cluster_fsid, this] {
     superblock.cluster_fsid = cluster_fsid;
     superblock.osd_fsid = store.get_fsid();
@@ -295,7 +301,13 @@ seastar::future<> OSD::start()
   startup_time = ceph::mono_clock::now();
 
   return store.start().then([this] {
-    return store.mount();
+    return store.mount().handle_error(
+      crimson::stateful_ec::handle([] (const auto& ec) {
+        logger().error("error mounting object store in {}: ({}) {}",
+                       local_conf().get_val<std::string>("osd_data"),
+                       ec.value(), ec.message());
+        std::exit(EXIT_FAILURE);
+      }));
   }).then([this] {
     return store.open_collection(coll_t::meta());
   }).then([this](auto ch) {
index 00e77b68b784108d33f6e221ae4bd7b99891445c..4e868e173b7e36d2bd734a74349415f6334c0d2e 100644 (file)
@@ -37,14 +37,14 @@ protected:
 
   virtual seastar::future<> _teardown() = 0;
   virtual FuturizedStore::mkfs_ertr::future<> _mkfs() = 0;
-  virtual seastar::future<> _mount() = 0;
+  virtual FuturizedStore::mount_ertr::future<> _mount() = 0;
 
   void restart() {
     _teardown().get0();
     destroy();
     static_cast<segment_manager::EphemeralSegmentManager*>(&*segment_manager)->remount();
     init();
-    _mount().get0();
+    _mount().handle_error(crimson::ct_error::assert_all{}).get0();
   }
 
   seastar::future<> tm_setup() {
@@ -145,7 +145,7 @@ protected:
     );
   }
 
-  virtual seastar::future<> _mount() {
+  virtual FuturizedStore::mount_ertr::future<> _mount() {
     return tm->mount(
     ).handle_error(
       crimson::ct_error::assert_all{"Error in mount"}
@@ -276,7 +276,7 @@ protected:
     });
   }
 
-  virtual seastar::future<> _mount() final {
+  virtual FuturizedStore::mount_ertr::future<> _mount() final {
     return seastore->mount();
   }