summaryrefslogtreecommitdiffstats
path: root/src/messages/MLock.h
diff options
context:
space:
mode:
authorPatrick Donnelly <pdonnell@redhat.com>2018-07-29 03:16:02 +0200
committerPatrick Donnelly <pdonnell@redhat.com>2018-08-15 22:35:30 +0200
commitd2a202af39fda43b23504d9b53438879bc9c12dc (patch)
tree9df421aa29726fdf0554d793627aeb7e829cce6d /src/messages/MLock.h
parentcommon: add templated Context factory (diff)
downloadceph-d2a202af39fda43b23504d9b53438879bc9c12dc.tar.xz
ceph-d2a202af39fda43b23504d9b53438879bc9c12dc.zip
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 <pdonnell@redhat.com>
Diffstat (limited to 'src/messages/MLock.h')
-rw-r--r--src/messages/MLock.h22
1 files changed, 14 insertions, 8 deletions
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<MLock> ref;
+ typedef boost::intrusive_ptr<MLock const> 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);