From: Sage Weil Date: Tue, 29 Dec 2015 18:21:34 +0000 (-0500) Subject: os/bluestore/BlueFS: fix a few leaks X-Git-Tag: v10.0.3~154^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7cb901c2e8654e229791ba734f21fbffce8f635e;p=ceph.git os/bluestore/BlueFS: fix a few leaks Signed-off-by: Sage Weil --- diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 600784df47e..3b4ce730578 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -179,7 +179,7 @@ int BlueFS::mkfs(uuid_d osd_uuid) delete log_writer; log_writer = NULL; block_all.clear(); - alloc.clear(); + _stop_alloc(); dout(10) << __func__ << " success" << dendl; return 0; @@ -198,6 +198,15 @@ void BlueFS::_init_alloc() } } +void BlueFS::_stop_alloc() +{ + dout(20) << __func__ << dendl; + for (auto p : alloc) { + delete p; + } + alloc.clear(); +} + int BlueFS::mount() { dout(1) << __func__ << dendl; @@ -246,11 +255,8 @@ void BlueFS::umount() delete log_writer; log_writer = NULL; - for (auto p : alloc) { - delete p; - } - alloc.clear(); block_all.clear(); + _stop_alloc(); file_map.clear(); for (auto& p : dir_map) { delete p.second; diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index cbdefff3c00..9d3382f00a0 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -28,7 +28,7 @@ public: atomic_t num_reading; File() - : RefCountedObject(0), + : RefCountedObject(NULL, 0), refs(0), dirty(false), locked(false), @@ -38,6 +38,7 @@ public: assert(num_readers.read() == 0); assert(num_writers.read() == 0); assert(num_reading.read() == 0); + assert(!locked); } friend void intrusive_ptr_add_ref(File *f) { @@ -182,6 +183,7 @@ private: vector alloc; ///< allocators for bdevs void _init_alloc(); + void _stop_alloc(); void _pad_bl(bufferlist& bl); ///< pad bufferlist to block size w/ zeros