summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Donnelly <pdonnell@redhat.com>2017-02-06 19:51:11 +0100
committerPatrick Donnelly <pdonnell@redhat.com>2017-10-01 02:30:04 +0200
commit21564d264ccb56f8edcccf56aee580695bc6bce8 (patch)
treee0c4416af44adba7425a0a48cd91a24c6e0fcc5d
parentMerge pull request #15199 from xiexingguo/wip-object-logic-size (diff)
downloadceph-21564d264ccb56f8edcccf56aee580695bc6bce8.tar.xz
ceph-21564d264ccb56f8edcccf56aee580695bc6bce8.zip
client: simplify release context ref mgmt
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
-rw-r--r--src/client/Client.cc9
-rw-r--r--src/client/Client.h1
-rw-r--r--src/client/MetaSession.cc8
-rw-r--r--src/client/MetaSession.h9
-rw-r--r--src/msg/Connection.h6
5 files changed, 12 insertions, 21 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc
index 8b449042a43..66183654e28 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -56,7 +56,6 @@
#include "messages/MCommandReply.h"
#include "messages/MOSDMap.h"
#include "messages/MClientQuota.h"
-#include "messages/MClientCapRelease.h"
#include "messages/MMDSMap.h"
#include "messages/MFSMap.h"
#include "messages/MFSMapUser.h"
@@ -2689,10 +2688,7 @@ void Client::send_reconnect(MetaSession *session)
session->readonly = false;
- if (session->release) {
- session->release->put();
- session->release = NULL;
- }
+ session->release.reset();
// reset my cap seq number
session->seq = 0;
@@ -5961,11 +5957,10 @@ void Client::flush_cap_releases()
p->first)) {
if (cct->_conf->client_inject_release_failure) {
ldout(cct, 20) << __func__ << " injecting failure to send cap release message" << dendl;
- p->second->release->put();
} else {
p->second->con->send_message(p->second->release);
}
- p->second->release = 0;
+ p->second->release.reset();
}
}
}
diff --git a/src/client/Client.h b/src/client/Client.h
index 7828c3b217c..312d6f9d5d9 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -62,7 +62,6 @@ class MClientRequest;
class MClientRequestForward;
struct MClientLease;
class MClientCaps;
-class MClientCapRelease;
struct DirStat;
struct LeaseStat;
diff --git a/src/client/MetaSession.cc b/src/client/MetaSession.cc
index 03752d246ae..9f7aefc5bc0 100644
--- a/src/client/MetaSession.cc
+++ b/src/client/MetaSession.cc
@@ -34,17 +34,11 @@ void MetaSession::dump(Formatter *f) const
f->dump_string("state", get_state_name());
}
-MetaSession::~MetaSession()
-{
- if (release)
- release->put();
-}
-
void MetaSession::enqueue_cap_release(inodeno_t ino, uint64_t cap_id, ceph_seq_t iseq,
ceph_seq_t mseq, epoch_t osd_barrier)
{
if (!release) {
- release = new MClientCapRelease;
+ release.reset(new MClientCapRelease, false);
}
if (osd_barrier > release->osd_epoch_barrier) {
diff --git a/src/client/MetaSession.h b/src/client/MetaSession.h
index af84615fc1d..0bffb5a0c51 100644
--- a/src/client/MetaSession.h
+++ b/src/client/MetaSession.h
@@ -6,15 +6,14 @@
#include "include/types.h"
#include "include/utime.h"
-#include "msg/Message.h"
#include "include/xlist.h"
#include "mds/mdstypes.h"
+#include "messages/MClientCapRelease.h"
struct Cap;
struct Inode;
struct CapSnap;
struct MetaRequest;
-class MClientCapRelease;
struct MetaSession {
mds_rank_t mds_num;
@@ -47,15 +46,13 @@ struct MetaSession {
std::set<ceph_tid_t> flushing_caps_tids;
std::set<Inode*> early_flushing_caps;
- MClientCapRelease *release;
+ boost::intrusive_ptr<MClientCapRelease> release;
MetaSession()
: mds_num(-1), con(NULL),
seq(0), cap_gen(0), cap_renew_seq(0), num_caps(0),
- state(STATE_NEW), mds_state(0), readonly(false),
- release(NULL)
+ state(STATE_NEW), mds_state(0), readonly(false)
{}
- ~MetaSession();
const char *get_state_name() const;
diff --git a/src/msg/Connection.h b/src/msg/Connection.h
index 94e934c55f1..b8ffbbf9b30 100644
--- a/src/msg/Connection.h
+++ b/src/msg/Connection.h
@@ -117,6 +117,12 @@ public:
* @return 0 on success, or -errno on failure.
*/
virtual int send_message(Message *m) = 0;
+
+ int send_message(boost::intrusive_ptr<Message> m)
+ {
+ return send_message(m.detach()); /* send_message(Message *m) consumes a reference */
+ }
+
/**
* Send a "keepalive" ping along the given Connection, if it's working.
* If the underlying connection has broken, this function does nothing.