Skip to content

Commit

Permalink
Merge pull request #44317 from aclamk/aclamk-fix-bluefs-import
Browse files Browse the repository at this point in the history
Fix ceph-bluestore-tool bluefs-import command

Reviewed-by: Igor Fedotov <igor.fedotov@croit.io>
  • Loading branch information
neha-ojha committed Dec 21, 2021
2 parents e1e2070 + b00a475 commit eb5290f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/os/bluestore/BlueStore.cc
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/os/bluestore/BlueStore.h
Expand Up @@ -2688,6 +2688,7 @@ class BlueStore : public ObjectStore,

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;
Expand Down
12 changes: 9 additions & 3 deletions src/os/bluestore/bluestore_tool.cc
Expand Up @@ -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);
Expand All @@ -261,7 +267,7 @@ static void bluefs_import(
f.close();
bs->fsync(h);
bs->close_writer(h);
bs->umount();
bluestore.close_db_environment();
return;
}

Expand Down

0 comments on commit eb5290f

Please sign in to comment.