]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/ceph-bluestore-tool: Fix bluefs-import command 47875/head
authorAdam Kupczyk <akupczyk@redhat.com>
Wed, 15 Dec 2021 11:04:13 +0000 (11:04 +0000)
committerIgor Fedotov <ifedotov@suse.com>
Tue, 30 Aug 2022 14:15:06 +0000 (17:15 +0300)
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>
(cherry picked from commit b00a475fb9b1a3b911f362e428af5c63c25ef5af)

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/os/bluestore/bluestore_tool.cc

index 168cad20924d24e87147eb9a11346cec320bd32b..191d4a622783e46dbefd9ac54aeb5e066a76b710 100644 (file)
@@ -5968,6 +5968,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 90308186c8fc46dec80c38bb0bf195c8613b4521..58a718da89af1b6d96d9e98609b7837ef70c605a 100644 (file)
@@ -2654,6 +2654,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 43cef737b19211bdf8e329bc9539da2f5df1f050..1d0bdb391626c7fd6a34b8dc75d9e1eebaea38b0 100644 (file)
@@ -244,8 +244,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);
@@ -265,7 +271,7 @@ static void bluefs_import(
   f.close();
   bs->fsync(h);
   bs->close_writer(h);
-  bs->umount();
+  bluestore.close_db_environment();
   return;
 }