From d2a202af39fda43b23504d9b53438879bc9c12dc Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Sat, 28 Jul 2018 18:16:02 -0700 Subject: mds: manage Message lifetime with intrusive_ptr This change turned out to be far more extensive than I hoped but the end result should prevent all Message-related memory leaks. I believe I fixed several incidentally. Fixes: http://tracker.ceph.com/issues/24306 Signed-off-by: Patrick Donnelly --- src/messages/MLock.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/messages/MLock.h') diff --git a/src/messages/MLock.h b/src/messages/MLock.h index 45086214d4e..4b992ff1bc8 100644 --- a/src/messages/MLock.h +++ b/src/messages/MLock.h @@ -18,10 +18,11 @@ #include "msg/Message.h" #include "mds/locks.h" +#include "mds/SimpleLock.h" class MLock : public Message { int32_t action = 0; // action type - int32_t asker = 0; // who is initiating this request + mds_rank_t asker = 0; // who is initiating this request metareqid_t reqid; // for remote lock requests __u16 lock_type = 0; // lock object type @@ -30,26 +31,31 @@ class MLock : public Message { bufferlist lockdata; // and possibly some data public: + typedef boost::intrusive_ptr ref; + typedef boost::intrusive_ptr const_ref; + bufferlist& get_data() { return lockdata; } - int get_asker() { return asker; } - int get_action() { return action; } - metareqid_t get_reqid() { return reqid; } + const bufferlist& get_data() const { return lockdata; } + int get_asker() const { return asker; } + int get_action() const { return action; } + metareqid_t get_reqid() const { return reqid; } - int get_lock_type() { return lock_type; } + int get_lock_type() const { return lock_type; } + const MDSCacheObjectInfo &get_object_info() const { return object_info; } MDSCacheObjectInfo &get_object_info() { return object_info; } MLock() : Message(MSG_MDS_LOCK) {} - MLock(int ac, int as) : + MLock(int ac, mds_rank_t as) : Message(MSG_MDS_LOCK), action(ac), asker(as), lock_type(0) { } - MLock(SimpleLock *lock, int ac, int as) : + MLock(SimpleLock *lock, int ac, mds_rank_t as) : Message(MSG_MDS_LOCK), action(ac), asker(as), lock_type(lock->get_type()) { lock->get_parent()->set_object_info(object_info); } - MLock(SimpleLock *lock, int ac, int as, bufferlist& bl) : + MLock(SimpleLock *lock, int ac, mds_rank_t as, bufferlist& bl) : Message(MSG_MDS_LOCK), action(ac), asker(as), lock_type(lock->get_type()) { lock->get_parent()->set_object_info(object_info); -- cgit v1.2.3