]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: track snapshot count in rstat
authorYan, Zheng <zyan@redhat.com>
Thu, 14 Jun 2018 09:36:19 +0000 (17:36 +0800)
committerYan, Zheng <zyan@redhat.com>
Tue, 19 Jun 2018 09:10:03 +0000 (17:10 +0800)
Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
src/mds/CDir.cc
src/mds/CInode.cc
src/mds/MDCache.cc
src/mds/Server.cc
src/mds/mdstypes.cc
src/mds/mdstypes.h

index fc16586675a4d807cc212ccce76a1fa41c881ec4..cd53470c5cdf70ad229b380daf670914174ec3bf 100644 (file)
@@ -862,7 +862,7 @@ void CDir::steal_dentry(CDentry *dn)
       fnode.rstat.rbytes += pi->accounted_rstat.rbytes;
       fnode.rstat.rfiles += pi->accounted_rstat.rfiles;
       fnode.rstat.rsubdirs += pi->accounted_rstat.rsubdirs;
-      fnode.rstat.rsnaprealms += pi->accounted_rstat.rsnaprealms;
+      fnode.rstat.rsnaps += pi->accounted_rstat.rsnaps;
       if (pi->accounted_rstat.rctime > fnode.rstat.rctime)
        fnode.rstat.rctime = pi->accounted_rstat.rctime;
 
index cd76392773801089b3b1699139ea237f3d98198a..75fad43d33f648e4a1a536ff4bfc599c3f3bb76f 100644 (file)
@@ -2237,13 +2237,17 @@ void CInode::finish_scatter_gather_update(int type)
 
   case CEPH_LOCK_INEST:
     {
+      // adjust summation
+      assert(is_auth());
+
       fragtree_t tmpdft = dirfragtree;
       nest_info_t rstat;
-      rstat.rsubdirs = 1;
       bool rstat_valid = true;
 
-      // adjust summation
-      assert(is_auth());
+      rstat.rsubdirs = 1;
+      if (const sr_t *srnode = get_projected_srnode(); srnode)
+       rstat.rsnaps = srnode->snaps.size();
+
       mempool_inode *pi = get_projected_inode();
       dout(20) << "  orig rstat " << pi->rstat << dendl;
       pi->rstat.version++;
@@ -4282,6 +4286,9 @@ next:
        }
       }
       nest_info.rsubdirs++; // it gets one to account for self
+      if (const sr_t *srnode = in->get_projected_srnode(); srnode)
+       nest_info.rsnaps += srnode->snaps.size();
+
       // ...and that their sum matches our inode settings
       if (!dir_info.same_sums(in->inode.dirstat) ||
          !nest_info.same_sums(in->inode.rstat)) {
index 43628c36655eefe9db747f59780c0fa869a27f8b..b9f26074461070dc2883ae0eab8cde1e16117fe6 100644 (file)
@@ -12608,7 +12608,9 @@ do_rdlocks:
 
   frag_info_t dir_info;
   nest_info_t nest_info;
-  nest_info.rsubdirs++; // it gets one to account for self
+  nest_info.rsubdirs = 1; // it gets one to account for self
+  if (const sr_t *srnode = diri->get_projected_srnode(); srnode)
+    nest_info.rsnaps = srnode->snaps.size();
 
   diri->dirfragtree.get_leaves(frags);
   for (list<frag_t>::iterator p = frags.begin(); p != frags.end(); ++p) {
index 770a465199d07b463d009fc1f8e755119a5ea6df..d7a37220c8ff52df2cf2f9b8f16af53dd0fce7cb 100644 (file)
@@ -8445,7 +8445,7 @@ void _rollback_repair_dir(MutationRef& mut, CDir *dir, rename_rollback::drec &r,
     pf->rstat.rbytes += linkunlink * rstat.rbytes;
     pf->rstat.rfiles += linkunlink * rstat.rfiles;
     pf->rstat.rsubdirs += linkunlink * rstat.rsubdirs;
-    pf->rstat.rsnaprealms += linkunlink * rstat.rsnaprealms;
+    pf->rstat.rsnaps += linkunlink * rstat.rsnaps;
   }
   if (pf->fragstat.mtime == ctime) {
     pf->fragstat.mtime = r.dirfrag_old_mtime;
@@ -9158,6 +9158,7 @@ void Server::handle_client_mksnap(MDRequestRef& mdr)
 
   auto &pi = diri->project_inode(false, true);
   pi.inode.ctime = pi.inode.rstat.rctime = info.stamp;
+  pi.inode.rstat.rsnaps++;
   pi.inode.version = diri->pre_dirty();
 
   // project the snaprealm
@@ -9295,6 +9296,7 @@ void Server::handle_client_rmsnap(MDRequestRef& mdr)
   auto &pi = diri->project_inode(false, true);
   pi.inode.version = diri->pre_dirty();
   pi.inode.ctime = pi.inode.rstat.rctime = mdr->get_op_stamp();
+  pi.inode.rstat.rsnaps--;
   
   mdr->ls = mdlog->get_current_segment();
   EUpdate *le = new EUpdate(mdlog, "rmsnap");
index 492a845b415f2f318655470a68c727b1dad2ab37..65e8ac0f7d4a1c8966ca88eb5b18d776f99f4866 100644 (file)
@@ -86,7 +86,7 @@ void nest_info_t::encode(bufferlist &bl) const
     int64_t ranchors = 0;
     encode(ranchors, bl);
   }
-  encode(rsnaprealms, bl);
+  encode(rsnaps, bl);
   encode(rctime, bl);
   ENCODE_FINISH(bl);
 }
@@ -102,7 +102,7 @@ void nest_info_t::decode(bufferlist::const_iterator &bl)
     int64_t ranchors;
     decode(ranchors, bl);
   }
-  decode(rsnaprealms, bl);
+  decode(rsnaps, bl);
   decode(rctime, bl);
   DECODE_FINISH(bl);
 }
@@ -113,7 +113,7 @@ void nest_info_t::dump(Formatter *f) const
   f->dump_unsigned("rbytes", rbytes);
   f->dump_unsigned("rfiles", rfiles);
   f->dump_unsigned("rsubdirs", rsubdirs);
-  f->dump_unsigned("rsnaprealms", rsnaprealms);
+  f->dump_unsigned("rsnaps", rsnaps);
   f->dump_stream("rctime") << rctime;
 }
 
@@ -125,7 +125,7 @@ void nest_info_t::generate_test_instances(list<nest_info_t*>& ls)
   ls.back()->rbytes = 2;
   ls.back()->rfiles = 3;
   ls.back()->rsubdirs = 4;
-  ls.back()->rsnaprealms = 6;
+  ls.back()->rsnaps = 6;
   ls.back()->rctime = utime_t(7, 8);
 }
 
@@ -138,8 +138,8 @@ ostream& operator<<(ostream &out, const nest_info_t &n)
     out << " rc" << n.rctime;
   if (n.rbytes)
     out << " b" << n.rbytes;
-  if (n.rsnaprealms)
-    out << " sr" << n.rsnaprealms;
+  if (n.rsnaps)
+    out << " rs" << n.rsnaps;
   if (n.rfiles || n.rsubdirs)
     out << " " << n.rsize() << "=" << n.rfiles << "+" << n.rsubdirs;
   out << ")";    
index f4da16430355231996fdcc8085e26f6a1576878b..f56aafe60f95d65505fb6e1339e5b8bf8dba8cb5 100644 (file)
@@ -230,7 +230,7 @@ struct nest_info_t : public scatter_info_t {
   int64_t rsubdirs = 0;
   int64_t rsize() const { return rfiles + rsubdirs; }
 
-  int64_t rsnaprealms = 0;
+  int64_t rsnaps = 0;
 
   nest_info_t() {}
 
@@ -247,7 +247,7 @@ struct nest_info_t : public scatter_info_t {
     rbytes += fac*other.rbytes;
     rfiles += fac*other.rfiles;
     rsubdirs += fac*other.rsubdirs;
-    rsnaprealms += fac*other.rsnaprealms;
+    rsnaps += fac*other.rsnaps;
   }
 
   // *this += cur - acc;
@@ -257,7 +257,7 @@ struct nest_info_t : public scatter_info_t {
     rbytes += cur.rbytes - acc.rbytes;
     rfiles += cur.rfiles - acc.rfiles;
     rsubdirs += cur.rsubdirs - acc.rsubdirs;
-    rsnaprealms += cur.rsnaprealms - acc.rsnaprealms;
+    rsnaps += cur.rsnaps - acc.rsnaps;
   }
 
   bool same_sums(const nest_info_t &o) const {
@@ -265,7 +265,7 @@ struct nest_info_t : public scatter_info_t {
         rbytes == o.rbytes &&
         rfiles == o.rfiles &&
         rsubdirs == o.rsubdirs &&
-        rsnaprealms == o.rsnaprealms;
+        rsnaps == o.rsnaps;
   }
 
   void encode(bufferlist &bl) const;