Skip to content

Commit

Permalink
tool: ceph-kvstore-tool doesn't umount BlueStore properly
Browse files Browse the repository at this point in the history
Fixes: http://tracker.ceph.com/issues/21625

Signed-off-by: Chang Liu <liuchang0812@gmail.com>
  • Loading branch information
liuchang0812 committed Oct 2, 2017
1 parent 534c30a commit 3d6ce93
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions src/tools/ceph_kvstore_tool.cc
Expand Up @@ -36,7 +36,13 @@ using namespace std;

class StoreTool
{
boost::scoped_ptr<KeyValueDB> db;
boost::scoped_ptr<BlueStore> bluestore;

// TODO: make KeyValueDB enable_shared_from_this
// bluestore will hold *db* also, use unique_ptr/shared_ptr will
// double free.
KeyValueDB* db;

string store_path;

public:
Expand All @@ -46,7 +52,7 @@ class StoreTool
#ifdef HAVE_LIBAIO
// note: we'll leak this! the only user is ceph-kvstore-tool and
// we don't care.
BlueStore *bluestore = new BlueStore(g_ceph_context, path);
bluestore.reset(new BlueStore(g_ceph_context, path));
int r = bluestore->start_kv_only(&db_ptr);
if (r < 0) {
exit(1);
Expand All @@ -64,7 +70,18 @@ class StoreTool
exit(1);
}
}
db.reset(db_ptr);
db = db_ptr;
}

~StoreTool() {
if (bluestore) {
assert(0 == bluestore->umount());
}
else {
if (db) {
delete db;
}
}
}

uint32_t traverse(const string &prefix,
Expand Down

0 comments on commit 3d6ce93

Please sign in to comment.