@@ -16,6 +16,7 @@ using namespace std;
1616
1717StoreTool::StoreTool (const string& type,
1818 const string& path,
19+ bool read_only,
1920 bool to_repair,
2021 bool need_stats)
2122 : store_path(path)
@@ -28,7 +29,7 @@ StoreTool::StoreTool(const string& type,
2829
2930 if (type == " bluestore-kv" ) {
3031#ifdef WITH_BLUESTORE
31- if (load_bluestore (path, to_repair) != 0 )
32+ if (load_bluestore (path, read_only, to_repair) != 0 )
3233 exit (1 );
3334#else
3435 cerr << " bluestore not compiled in" << std::endl;
@@ -37,7 +38,8 @@ StoreTool::StoreTool(const string& type,
3738 } else {
3839 auto db_ptr = KeyValueDB::create (g_ceph_context, type, path);
3940 if (!to_repair) {
40- if (int r = db_ptr->open (std::cerr); r < 0 ) {
41+ int r = read_only ? db_ptr->open_read_only (std::cerr) : db_ptr->open (std::cerr);
42+ if (r < 0 ) {
4143 cerr << " failed to open type " << type << " path " << path << " : "
4244 << cpp_strerror (r) << std::endl;
4345 exit (1 );
@@ -47,11 +49,11 @@ StoreTool::StoreTool(const string& type,
4749 }
4850}
4951
50- int StoreTool::load_bluestore (const string& path, bool to_repair)
52+ int StoreTool::load_bluestore (const string& path, bool read_only, bool to_repair)
5153{
5254 auto bluestore = new BlueStore (g_ceph_context, path);
5355 KeyValueDB *db_ptr;
54- int r = bluestore->open_db_environment (&db_ptr, to_repair);
56+ int r = bluestore->open_db_environment (&db_ptr, read_only, to_repair);
5557 if (r < 0 ) {
5658 return -EINVAL;
5759 }
0 commit comments