]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: improve error handling for migrate ops in
authorIgor Fedotov <ifedotov@suse.com>
Mon, 29 Oct 2018 15:18:18 +0000 (18:18 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 29 Oct 2018 15:18:18 +0000 (18:18 +0300)
ceph_bluestore-tool.

Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/bluestore_tool.cc

index 320f12ed577dbc7910ef6480f9da193e59eec313..6268a0822eb4e80893dd5399c34f909ff4561b2a 100644 (file)
@@ -660,6 +660,8 @@ int main(int argc, char **argv)
 
     bool has_wal = false;
     bool has_db = false;
+    char target_path[PATH_MAX] = "";
+
     parse_devices(cct.get(), devs, &cur_devs_map, &has_db, &has_wal);
 
     if (has_db && has_wal) {
@@ -674,36 +676,44 @@ int main(int argc, char **argv)
       cerr << "can't allocate new WAL device, already exists"
            << std::endl;
       exit(EXIT_FAILURE);
+    } else if(!dev_target.empty() &&
+             realpath(dev_target.c_str(), target_path) == nullptr) {
+      cerr << "failed to retrieve absolute path for " << dev_target
+           << ": " << cpp_strerror(errno)
+           << std::endl;
+      exit(EXIT_FAILURE);
+    }
+
+    // Create either DB or WAL volume
+    int r = EXIT_FAILURE;
+    if (need_db && cct->_conf->bluestore_block_db_size == 0) {
+      cerr << "DB size isn't specified, "
+              "please set Ceph bluestore-block-db-size config parameter "
+           << std::endl;
+    } else if (!need_db && cct->_conf->bluestore_block_wal_size == 0) {
+      cerr << "WAL size isn't specified, "
+              "please set Ceph bluestore-block-wal-size config parameter "
+           << std::endl;
     } else {
-      // Create either DB or WAL volume
       BlueStore bluestore(cct.get(), path);
-
-      char target_path[PATH_MAX] = "";
-      if(!dev_target.empty()) {
-       if (realpath(dev_target.c_str(), target_path) == nullptr) {
-         cerr << "failed to retrieve absolute path for " << dev_target
-              << ": " << cpp_strerror(errno)
-              << std::endl;
-       }
-      }
-      int r = bluestore.add_new_bluefs_device(
-       need_db ? BlueFS::BDEV_NEWDB : BlueFS::BDEV_NEWWAL,
-       target_path);
+      r = bluestore.add_new_bluefs_device(
+        need_db ? BlueFS::BDEV_NEWDB : BlueFS::BDEV_NEWWAL,
+        target_path);
       if (r == 0) {
-       cout << (need_db ? "DB" : "WAL") << " device added " << target_path
-            << std::endl;
+        cout << (need_db ? "DB" : "WAL") << " device added " << target_path
+             << std::endl;
       } else {
-       cerr << "failed to add " << (need_db ? "DB" : "WAL") << " device:"
-            << cpp_strerror(r)
-            << std::endl;
+        cerr << "failed to add " << (need_db ? "DB" : "WAL") << " device:"
+             << cpp_strerror(r)
+             << std::endl;
       }
+      return r;
     }
   } else if (action == "bluefs-bdev-migrate") {
     map<string, int> cur_devs_map;
     set<int> src_dev_ids;
     map<string, int> src_devs;
 
-
     parse_devices(cct.get(), devs, &cur_devs_map, nullptr, nullptr);
     for (auto& s :  devs_source) {
       auto i = cur_devs_map.find(s);
@@ -754,6 +764,7 @@ int main(int argc, char **argv)
     } else {
       // Migrate to a new BlueFS volume
       // via creating either DB or WAL volume
+      char target_path[PATH_MAX] = "";
       int dev_target_id;
       if (src_dev_ids.count(BlueFS::BDEV_DB)) {
        // if we have DB device in the source list - we create DB device
@@ -768,17 +779,16 @@ int main(int argc, char **argv)
             << std::endl;
        exit(EXIT_FAILURE);
       }
+      if(!dev_target.empty() &&
+               realpath(dev_target.c_str(), target_path) == nullptr) {
+       cerr << "failed to retrieve absolute path for " << dev_target
+            << ": " << cpp_strerror(errno)
+            << std::endl;
+       exit(EXIT_FAILURE);
+      }
 
       BlueStore bluestore(cct.get(), path);
 
-      char target_path[PATH_MAX] = "";
-      if(!dev_target.empty()) {
-       if (realpath(dev_target.c_str(), target_path) == nullptr) {
-         cerr << "failed to retrieve absolute path for " << dev_target
-              << ": " << cpp_strerror(errno)
-              << std::endl;
-       }
-      }
       bool need_db = dev_target_id == BlueFS::BDEV_NEWDB;
       int r = bluestore.migrate_to_new_bluefs_device(
        src_dev_ids,
@@ -802,8 +812,7 @@ int main(int argc, char **argv)
             << cpp_strerror(r)
             << std::endl;
       }
-
-      ceph_assert(r == 0);
+      return r;
     }
   } else {
     cerr << "unrecognized action " << action << std::endl;