]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tool: ceph-kvstore-tool doesn't umount BlueStore properly 18083/head
authorChang Liu <liuchang0812@gmail.com>
Mon, 2 Oct 2017 16:12:43 +0000 (00:12 +0800)
committerChang Liu <liuchang0812@gmail.com>
Tue, 3 Oct 2017 05:00:02 +0000 (13:00 +0800)
Fixes: http://tracker.ceph.com/issues/21625
Signed-off-by: Chang Liu <liuchang0812@gmail.com>
src/tools/ceph_kvstore_tool.cc

index 6d7ef7313ff2831ac703f7ae007c3e7debd4e2b9..e9f31091c1c9d5837e8389cea64f99a694075a6e 100644 (file)
@@ -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:
@@ -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,