Merge pull request #44317 from aclamk/aclamk-fix-bluefs-import

Fix ceph-bluestore-tool bluefs-import command

Reviewed-by: Igor Fedotov <igor.fedotov@croit.io>
This commit is contained in:
Neha Ojha 2021-12-21 11:57:01 -08:00 committed by GitHub
commit eb5290f690
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -6373,6 +6373,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)
{

View File

@ -2688,6 +2688,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;

View 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;
}