]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mds/Mutation: make Mutation a TrackedOp
authorSage Weil <sage@redhat.com>
Thu, 15 Dec 2016 04:06:36 +0000 (23:06 -0500)
committerSage Weil <sage@redhat.com>
Fri, 27 Jan 2017 15:30:43 +0000 (10:30 -0500)
This seems silly now, but is needed in order to switch from shared_ptr to
intrusive_ptr.  The TrackOp is the refcounted thing, and we want to be
able to cast beween MutationRefs and MDRequestRefs, so... we need to make
sure the refcounting is done via a common parent, TrackedOp.

Signed-off-by: Sage Weil <sage@redhat.com>
src/mds/CInode.cc
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Migrator.cc
src/mds/Mutation.cc
src/mds/Mutation.h
src/mds/Server.cc

index 54f21b035205bba23ae8141a3b1cb65f69045469..cdc9832d44813e255dad9d0960bb87ab33aacf26 100644 (file)
@@ -1890,7 +1890,7 @@ void CInode::finish_scatter_update(ScatterLock *lock, CDir *dir,
       dout(10) << "finish_scatter_update " << fg << " journaling accounted scatterstat update v" << inode_version << dendl;
 
       MDLog *mdlog = mdcache->mds->mdlog;
-      auto mut(std::make_shared<MutationImpl>());
+      MutationRef mut(new MutationImpl());
       mut->ls = mdlog->get_current_segment();
 
       inode_t *pi = get_projected_inode();
index f776d536ed4f34ff440825732d1283d43217ee61..95a1f24d08ce3426754447bd4fe72a0a6450d886 100644 (file)
@@ -2279,7 +2279,7 @@ bool Locker::check_inode_max_size(CInode *in, bool force_wrlock,
     }
   }
 
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
   mut->ls = mds->mdlog->get_current_segment();
     
   inode_t *pi = in->project_inode();
@@ -2955,7 +2955,7 @@ void Locker::_do_snap_update(CInode *in, snapid_t snap, int dirty, snapid_t foll
 
   EUpdate *le = new EUpdate(mds->mdlog, "snap flush");
   mds->mdlog->start_entry(le);
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut = new MutationImpl();
   mut->ls = mds->mdlog->get_current_segment();
 
   // normal metadata updates that we can apply to the head as well.
@@ -3250,7 +3250,7 @@ bool Locker::_do_cap_update(CInode *in, Capability *cap,
   inode_t *pi = in->project_inode(px);
   pi->version = in->pre_dirty();
 
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
   mut->ls = mds->mdlog->get_current_segment();
 
   _update_cap_fields(in, dirty, m, pi);
@@ -4255,7 +4255,7 @@ void Locker::scatter_writebehind(ScatterLock *lock)
   dout(10) << "scatter_writebehind " << in->inode.mtime << " on " << *lock << " on " << *in << dendl;
 
   // journal
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
   mut->ls = mds->mdlog->get_current_segment();
 
   // forcefully take a wrlock
index 136c72c1e147b1274be0431bad80f1c1c1ecfab8..6717adb9ed12e54111bfb4789eb9ea0d36c573c8 100644 (file)
@@ -513,7 +513,7 @@ void MDCache::_create_system_file(CDir *dir, const char *name, CInode *in, MDSIn
   SnapRealm *realm = dir->get_inode()->find_snaprealm();
   dn->first = in->first = realm->get_newest_seq() + 1;
 
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
 
   // force some locks.  hacky.
   mds->locker->wrlock_force(&dir->inode->filelock, mut);
@@ -6256,7 +6256,7 @@ void MDCache::truncate_inode_finish(CInode *in, LogSegment *ls)
   pi->truncate_from = 0;
   pi->truncate_pending--;
 
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
   mut->ls = mds->mdlog->get_current_segment();
   mut->add_projected_inode(in);
 
@@ -9198,7 +9198,7 @@ void MDCache::snaprealm_create(MDRequestRef& mdr, CInode *in)
     return;
   }
 
-  auto mut(std::make_shared<MutationImpl>());
+  MutationRef mut(new MutationImpl());
   mut->ls = mds->mdlog->get_current_segment();
   EUpdate *le = new EUpdate(mds->mdlog, "snaprealm_create");
   mds->mdlog->start_entry(le);
index d08dd47c4aee788bcd880c9a819d62f4e26aace9..e57bffdec08a41d425b9d178269d68b0f39bded3 100644 (file)
@@ -958,7 +958,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid)
     return;
   }
 
-  it->second.mut = std::make_shared<MutationImpl>();
+  it->second.mut = new MutationImpl();
   if (diri->is_auth())
     it->second.mut->auth_pin(diri);
   mds->locker->rdlock_take_set(rdlocks, it->second.mut);
@@ -2192,7 +2192,7 @@ void Migrator::handle_export_prep(MExportDirPrep *m)
   if (!mds->mdcache->is_readonly() &&
       dir->get_inode()->filelock.can_wrlock(-1) &&
       dir->get_inode()->nestlock.can_wrlock(-1)) {
-    it->second.mut = std::make_shared<MutationImpl>();
+    it->second.mut = new MutationImpl();
     // force some locks.  hacky.
     mds->locker->wrlock_force(&dir->inode->filelock, it->second.mut);
     mds->locker->wrlock_force(&dir->inode->nestlock, it->second.mut);
index e307920bd8bd83103fa2c9a400f6d6b6b370c50b..812d1a7a05aaaf4762ee587318910fe3476bab33 100644 (file)
@@ -173,6 +173,10 @@ void MutationImpl::cleanup()
   drop_pins();
 }
 
+void MutationImpl::_dump_op_descriptor_unlocked(ostream& stream) const
+{
+  stream << "Mutation";
+}
 
 // MDRequestImpl
 
index 515bda8b29e75106e153e855a3bfc039aa24e005..dcb2ed40dce58071af68ab3e1d499d58e33ee9aa 100644 (file)
@@ -36,7 +36,7 @@ class ScatterLock;
 class MClientRequest;
 class MMDSSlaveRequest;
 
-struct MutationImpl {
+struct MutationImpl : public TrackedOp {
   metareqid_t reqid;
   __u32 attempt = 0;      // which attempt for this request
   LogSegment *ls = nullptr;  // the log segment i'm committing to
@@ -86,9 +86,11 @@ public:
   list<pair<CDentry*,version_t> > dirty_cow_dentries;
 
   // keep our default values synced with MDRequestParam's
-  MutationImpl() = default;
-  MutationImpl(metareqid_t ri, __u32 att=0, mds_rank_t slave_to=MDS_RANK_NONE)
-    : reqid(ri), attempt(att),
+  MutationImpl() : TrackedOp(nullptr, utime_t()) {}
+  MutationImpl(OpTracker *tracker, utime_t initiated,
+              metareqid_t ri, __u32 att=0, mds_rank_t slave_to=MDS_RANK_NONE)
+    : TrackedOp(tracker, initiated),
+      reqid(ri), attempt(att),
       slave_to_mds(slave_to) { }
   virtual ~MutationImpl() {
     assert(locking == NULL);
@@ -153,6 +155,7 @@ public:
   }
 
   virtual void dump(Formatter *f) const {}
+  void _dump_op_descriptor_unlocked(ostream& stream) const override;
 };
 
 inline ostream& operator<<(ostream &out, const MutationImpl &mut)
@@ -170,7 +173,7 @@ typedef ceph::shared_ptr<MutationImpl> MutationRef;
  * mostly information about locks held, so that we can drop them all
  * the request is finished or forwarded.  see request_*().
  */
-struct MDRequestImpl : public MutationImpl, public TrackedOp {
+struct MDRequestImpl : public MutationImpl {
   Session *session;
   elist<MDRequestImpl*>::item item_session_request;  // if not on list, op is aborted.
 
@@ -289,8 +292,8 @@ struct MDRequestImpl : public MutationImpl, public TrackedOp {
         triggering_slave_req(NULL), slave_to(MDS_RANK_NONE), internal_op(-1) {}
   };
   MDRequestImpl(const Params& params, OpTracker *tracker) :
-    MutationImpl(params.reqid, params.attempt, params.slave_to),
-    TrackedOp(tracker, params.initiated),
+    MutationImpl(tracker, params.initiated,
+                params.reqid, params.attempt, params.slave_to),
     session(NULL), item_session_request(this),
     client_request(params.client_req), straydn(NULL), snapid(CEPH_NOSNAP),
     tracei(NULL), tracedn(NULL), alloc_ino(0), used_prealloc_ino(0),
index 5bdf3a41b085dcbf6cd5c8e3893289419a5fbac9..dff75670230a56dbb928b553b00995eaa7e97c02 100644 (file)
@@ -5365,7 +5365,7 @@ void Server::do_link_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef&
   mdcache->add_rollback(rollback.reqid, master); // need to finish this update before resolve finishes
   assert(mdr || mds->is_resolve());
 
-  auto mut(std::make_shared<MutationImpl>(rollback.reqid));
+  MutationRef mut(new MutationImpl(nullptr, utime_t(), rollback.reqid));
   mut->ls = mds->mdlog->get_current_segment();
 
   CInode *in = mdcache->get_inode(rollback.ino);
@@ -7618,7 +7618,7 @@ void Server::do_rename_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef
   // need to finish this update before sending resolve to claim the subtree
   mdcache->add_rollback(rollback.reqid, master);
 
-  auto mut(std::make_shared<MutationImpl>(rollback.reqid));
+  MutationRef mut(new MutationImpl(nullptr, utime_t(), rollback.reqid));
   mut->ls = mds->mdlog->get_current_segment();
 
   CDentry *srcdn = NULL;