_close_path();
}
-int BlueStore::open_db_environment(KeyValueDB **pdb, bool to_repair)
+int BlueStore::open_db_environment(KeyValueDB **pdb, bool read_only, bool to_repair)
{
_kv_only = true;
- int r = _open_db_and_around(false, to_repair);
+ int r = _open_db_and_around(read_only, to_repair);
if (r == 0) {
*pdb = db;
} else {
}
int umount() override;
- int open_db_environment(KeyValueDB **pdb, bool to_repair);
+ int open_db_environment(KeyValueDB **pdb, bool read_only, bool to_repair);
int close_db_environment();
BlueFS* get_bluefs();
}
BlueStore bluestore(cct, path);
KeyValueDB *db_ptr;
- r = bluestore.open_db_environment(&db_ptr, false);
+ r = bluestore.open_db_environment(&db_ptr, false, false);
if (r < 0) {
cerr << "error preparing db environment: " << cpp_strerror(r) << std::endl;
exit(EXIT_FAILURE);
exit(EXIT_FAILURE);
}
}
- int r = bluestore.open_db_environment(&db_ptr, true);
+ int r = bluestore.open_db_environment(&db_ptr, false, true);
if (r < 0) {
cerr << "error preparing db environment: " << cpp_strerror(r) << std::endl;
exit(EXIT_FAILURE);
} else if (action == "show-sharding") {
BlueStore bluestore(cct.get(), path);
KeyValueDB *db_ptr;
- int r = bluestore.open_db_environment(&db_ptr, false);
+ int r = bluestore.open_db_environment(&db_ptr, false, false);
if (r < 0) {
cerr << "error preparing db environment: " << cpp_strerror(r) << std::endl;
exit(EXIT_FAILURE);
return 1;
}
+ bool read_only =
+ cmd == "list" ||
+ cmd == "list-crc" ||
+ cmd == "dump" ||
+ cmd == "exists" ||
+ cmd == "get" ||
+ cmd == "crc" ||
+ cmd == "get-size" ||
+ cmd == "store-crc" ||
+ cmd == "stats" ||
+ cmd == "histogram";
bool to_repair = (cmd == "destructive-repair");
bool need_stats = (cmd == "stats");
- StoreTool st(type, path, to_repair, need_stats);
+ StoreTool st(type, path, read_only, to_repair, need_stats);
if (cmd == "destructive-repair") {
int ret = st.destructive_repair();
StoreTool::StoreTool(const string& type,
const string& path,
+ bool read_only,
bool to_repair,
bool need_stats)
: store_path(path)
if (type == "bluestore-kv") {
#ifdef WITH_BLUESTORE
- if (load_bluestore(path, to_repair) != 0)
+ if (load_bluestore(path, read_only, to_repair) != 0)
exit(1);
#else
cerr << "bluestore not compiled in" << std::endl;
} else {
auto db_ptr = KeyValueDB::create(g_ceph_context, type, path);
if (!to_repair) {
- if (int r = db_ptr->open(std::cerr); r < 0) {
+ int r = read_only ? db_ptr->open_read_only(std::cerr) : db_ptr->open(std::cerr);
+ if (r < 0) {
cerr << "failed to open type " << type << " path " << path << ": "
<< cpp_strerror(r) << std::endl;
exit(1);
}
}
-int StoreTool::load_bluestore(const string& path, bool to_repair)
+int StoreTool::load_bluestore(const string& path, bool read_only, bool to_repair)
{
auto bluestore = new BlueStore(g_ceph_context, path);
KeyValueDB *db_ptr;
- int r = bluestore->open_db_environment(&db_ptr, to_repair);
+ int r = bluestore->open_db_environment(&db_ptr, read_only, to_repair);
if (r < 0) {
return -EINVAL;
}
public:
StoreTool(const std::string& type,
const std::string& path,
+ bool read_only,
bool need_open_db = true,
bool need_stats = false);
- int load_bluestore(const std::string& path, bool need_open_db);
+ int load_bluestore(const std::string& path, bool read_only, bool need_open_db);
uint32_t traverse(const std::string& prefix,
const bool do_crc,
const bool do_value_dump,