From 81e4560781c4e5a5a033bfd4a4fe4094fc27d964 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 3 Oct 2017 00:12:43 +0800 Subject: [PATCH] tool: ceph-kvstore-tool doesn't umount BlueStore properly Fixes: http://tracker.ceph.com/issues/21625 Signed-off-by: Chang Liu --- src/tools/ceph_kvstore_tool.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 6d7ef7313ff..e9f31091c1c 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -36,7 +36,13 @@ using namespace std; class StoreTool { - boost::scoped_ptr db; + boost::scoped_ptr 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: @@ -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); @@ -64,7 +70,18 @@ class StoreTool exit(1); } } - db.reset(db_ptr); + db = db_ptr; + } + + ~StoreTool() { + if (bluestore) { + bluestore->umount(); + } + else { + if (db) { + delete db; + } + } } uint32_t traverse(const string &prefix, -- 2.39.5