]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/ceph-bluestore-tool: Fix bluefs-import command 44317/head
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 15 Dec 2021 11:04:13 +0000 (11:04 +0000)
committerAdam Kupczyk <akupczyk@redhat.com>
Thu, 16 Dec 2021 09:08:45 +0000 (09:08 +0000)
Modify bluefs-import command so it can properly initialize allocators.
Without allocators initialized, importing file to bluefs did overwrite some random data,
including first block on device.

Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc

index fae749da817bd04dfca199618d0a35ace0f18be3..2b77891b6463163dd04bbdec5f9e2db5a4e73c71 100644 (file)
@@ -6370,6 +6370,11 @@ int BlueStore::close_db_environment()
   return 0;
 }
 
+/* gets access to bluefs supporting RocksDB */
+BlueFS* BlueStore::get_bluefs() {
+  return bluefs;
+}
+
 int BlueStore::_prepare_db_environment(bool create, bool read_only,
                                       std::string* _fn, std::string* _kv_backend)
 {
index 5416244e4131dd9574abed2a6b235b7351df4d86..2d15d3e2fa62ed1c152d3f4ac062a1366836d033 100644 (file)
@@ -2681,6 +2681,7 @@ public:
 
   int open_db_environment(KeyValueDB **pdb, bool to_repair);
   int close_db_environment();
+  BlueFS* get_bluefs();
 
   int write_meta(const std::string& key, const std::string& value) override;
   int read_meta(const std::string& key, std::string *value) override;
index b215d3e9ed17d97539165fdfc4e2c57693443434..6cf5d3dd1a44e32f0fa3c6ea04856b8a764f925f 100644 (file)
@@ -240,8 +240,14 @@ static void bluefs_import(
     cerr << "open " << input_file.c_str() << " failed: " << cpp_strerror(r) << std::endl;
     exit(EXIT_FAILURE);
   }
-
-  std::unique_ptr<BlueFS> bs{open_bluefs_readonly(cct, path, devs)};
+  BlueStore bluestore(cct, path);
+  KeyValueDB *db_ptr;
+  r = bluestore.open_db_environment(&db_ptr, false);
+  if (r < 0) {
+    cerr << "error preparing db environment: " << cpp_strerror(r) << std::endl;
+    exit(EXIT_FAILURE);
+  }
+  BlueFS* bs = bluestore.get_bluefs();
 
   BlueFS::FileWriter *h;
   fs::path file_path(dest_file);
@@ -261,7 +267,7 @@ static void bluefs_import(
   f.close();
   bs->fsync(h);
   bs->close_writer(h);
-  bs->umount();
+  bluestore.close_db_environment();
   return;
 }