]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Mutation: move self_ref into MutationImpl instead of MDRequestImpl
authorGreg Farnum <greg@inktank.com>
Wed, 12 Mar 2014 03:20:41 +0000 (20:20 -0700)
committerGreg Farnum <greg@inktank.com>
Fri, 4 Apr 2014 17:40:51 +0000 (10:40 -0700)
We keep an MDRequestImpl::set_self_ref(MDRequestRef&) function so
that we don't need to do the pointer conversion elsewhere.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/Mutation.h
src/mds/Server.cc

index 0f7ce236b90f5d1ca89cfaf5e35e7a759256e62c..53243df739b953d984258b842ec236b231a6a50e 100644 (file)
@@ -34,6 +34,7 @@ class MClientRequest;
 class MMDSSlaveRequest;
 
 struct MutationImpl {
+  ceph::weak_ptr<MutationImpl> self_ref;
   metareqid_t reqid;
   __u32 attempt;      // which attempt for this request
   LogSegment *ls;  // the log segment i'm committing to
@@ -79,14 +80,16 @@ struct MutationImpl {
   list<pair<CDentry*,version_t> > dirty_cow_dentries;
 
   MutationImpl()
-    : attempt(0),
+    : self_ref(),
+      attempt(0),
       ls(0),
       slave_to_mds(-1),
       locking(NULL),
       locking_target_mds(-1),
       done_locking(false), committing(false), aborted(false), killed(false) { }
   MutationImpl(metareqid_t ri, __u32 att=0, int slave_to=-1)
-    : reqid(ri), attempt(att),
+    : self_ref(),
+      reqid(ri), attempt(att),
       ls(0),
       slave_to_mds(slave_to), 
       locking(NULL),
@@ -138,6 +141,10 @@ struct MutationImpl {
   virtual void print(ostream &out) {
     out << "mutation(" << this << ")";
   }
+
+  void set_self_ref(ceph::shared_ptr<MutationImpl>& ref) {
+    self_ref = ref;
+  }
 };
 
 inline ostream& operator<<(ostream& out, MutationImpl &mut)
@@ -156,7 +163,6 @@ typedef ceph::shared_ptr<MutationImpl> MutationRef;
  * the request is finished or forwarded.  see request_*().
  */
 struct MDRequestImpl : public MutationImpl {
-  ceph::weak_ptr<MDRequestImpl> self_ref;
   Session *session;
   elist<MDRequestImpl*>::item item_session_request;  // if not on list, op is aborted.
 
@@ -252,7 +258,6 @@ struct MDRequestImpl : public MutationImpl {
 
   // ---------------------------------------------------
   MDRequestImpl() :
-    self_ref(),
     session(0), item_session_request(this),
     client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
     alloc_ino(0), used_prealloc_ino(0), snap_caps(0), did_early_reply(false),
@@ -266,7 +271,6 @@ struct MDRequestImpl : public MutationImpl {
     in[0] = in[1] = 0; 
   }
   MDRequestImpl(metareqid_t ri, __u32 attempt, MClientRequest *req) :
-    self_ref(),
     MutationImpl(ri, attempt),
     session(0), item_session_request(this),
     client_request(req), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
@@ -281,7 +285,6 @@ struct MDRequestImpl : public MutationImpl {
     in[0] = in[1] = 0; 
   }
   MDRequestImpl(metareqid_t ri, __u32 attempt, int by) :
-    self_ref(),
     MutationImpl(ri, attempt, by),
     session(0), item_session_request(this),
     client_request(0), straydn(NULL), snapid(CEPH_NOSNAP), tracei(0), tracedn(0),
@@ -312,7 +315,7 @@ struct MDRequestImpl : public MutationImpl {
 
   void print(ostream &out);
   void set_self_ref(ceph::shared_ptr<MDRequestImpl>& ref) {
-    self_ref = ref;
+    self_ref = ceph::static_pointer_cast<MutationImpl,MDRequestImpl>(ref);
   }
 };
 
index 2521b6004612583e33ec6288c944ad09e0db9dac..69f302b376726407f6e7a40f91f9b72f8c3fe768 100644 (file)
@@ -548,7 +548,7 @@ void Server::journal_close_session(Session *session, int state)
     session->requests.begin(member_offset(MDRequestImpl,
                                          item_session_request));
   while (!p.end()) {
-    MDRequestRef mdrp = (*p)->self_ref.lock();
+    MDRequestRef mdr = ceph::static_pointer_cast<MDRequestImpl,MutationImpl>((*p)->self_ref.lock());
     assert(mdr);
     ++p;
     mdcache->request_kill(mdr);