]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add check_rstats function and a few users.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 15 Mar 2011 18:57:09 +0000 (11:57 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Tue, 22 Mar 2011 00:18:34 +0000 (17:18 -0700)
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/MDCache.cc

index f9689c974ee553dbd41fefe90ff7c24faa04f7cf..a0fa3fadaafb6d54357cd32656823ae2fc8df673 100644 (file)
@@ -197,7 +197,60 @@ CDir::CDir(CInode *in, frag_t fg, MDCache *mdcache, bool auth) :
   //dir_rep = REP_ALL;      // hack: to wring out some bugs! FIXME FIXME
 }
 
+/**
+ * Check the recursive statistics on size for consistency. For now,
+ * assert the correctness; later maybe we'll just return false
+ * if there's a problem.
+ */
+bool CDir::check_rstats()
+{
+  dout(20) << "check_rstats on " << this << dendl;
+  if (!is_complete()) {
+    dout(10) << "check_rstats bailing out -- incomplete dir!" << dendl;
+    return true;
+  }
+  // first, check basic counts
+  dout(20) << "get_num_head_items() = " << get_num_head_items()
+           << "; fnode.fragstat.nfiles=" << fnode.fragstat.nfiles
+           << " fnode.fragstat.nsubdirs=" << fnode.fragstat.nsubdirs << dendl;
+  if(!(get_num_head_items()==
+      (fnode.fragstat.nfiles + fnode.fragstat.nsubdirs))) {
+    dout(1) << "mismatch between head items and fnode.fragstat! printing dentries" << dendl;
+    for (map_t::iterator i = items.begin(); i != items.end(); ++i) {
+      //if (i->second->get_linkage()->is_primary())
+        dout(1) << *(i->second) << dendl;
+    }
+    assert(get_num_head_items() ==
+        (fnode.fragstat.nfiles + fnode.fragstat.nsubdirs));
+  }
 
+  nest_info_t sub_info;
+  for (map_t::iterator i = items.begin(); i != items.end(); ++i) {
+    if (i->second->get_linkage()->is_primary()) {
+      sub_info.add(i->second->get_linkage()->inode->inode.accounted_rstat);
+    }
+  }
+
+  dout(20) << "total of child dentrys: " << sub_info << dendl;
+  dout(20) << "my rstats:              " << fnode.rstat << dendl;
+  if ((!(sub_info.rbytes == fnode.rstat.rbytes)) ||
+      (!(sub_info.rfiles == fnode.rstat.rfiles)) ||
+      (!(sub_info.rsubdirs == fnode.rstat.rsubdirs))) {
+    dout(1) << "mismatch between child accounted_rstats and my rstats!" << dendl;
+    for (map_t::iterator i = items.begin(); i != items.end(); ++i) {
+      if (i->second->get_linkage()->is_primary()) {
+        dout(1) << *(i->second) << " "
+                << i->second->get_linkage()->inode->inode.accounted_rstat
+                << dendl;
+      }
+    }
+  }
+  assert(sub_info.rbytes == fnode.rstat.rbytes);
+  assert(sub_info.rfiles == fnode.rstat.rfiles);
+  assert(sub_info.rsubdirs == fnode.rstat.rsubdirs);
+  dout(0) << "check_rstats success on " << this << dendl;
+  return true;
+}
 
 
 CDentry *CDir::lookup(const char *name, snapid_t snap)
index 3d312dc46d14d33688ce747da49e88959f5888bd..2060e98473e661e96a1eb8e4bc4284e1fad84b6c 100644 (file)
@@ -308,6 +308,8 @@ protected:
   unsigned get_num_snap_null() { return num_snap_null; }
   unsigned get_num_any() { return num_head_items + num_head_null + num_snap_items + num_snap_null; }
   
+  bool check_rstats();
+
   void inc_num_dirty() { num_dirty++; }
   void dec_num_dirty() { 
     assert(num_dirty > 0);
index 49fe113762384670e6cb4ca364afa23c9fc32b15..694e837d8a3feb328fdec9d4244b21adf517129a 100644 (file)
@@ -1781,6 +1781,7 @@ void CInode::finish_scatter_gather_update(int type)
               q++)
            mdcache->project_rstat_frag_to_inode(q->second.rstat, q->second.accounted_rstat,
                                                 q->second.first, q->first, this, true);
+         dir->check_rstats();
        } else {
          dout(20) << fg << " skipping STALE accounted_rstat " << pf->accounted_rstat << dendl;
        }
@@ -1805,6 +1806,7 @@ void CInode::finish_scatter_gather_update(int type)
            assert(!"unmatched rstat rbytes" == g_conf.mds_verify_scatter);
          }
        }
+       dir->check_rstats();
       }
       dout(20) << " final rstat " << pi->rstat << dendl;
 
index c70c3b829f87aa23b85ac73c247383262487eef7..a7fe1e8987362baa581cbb505e04ead7c2b4114d 100644 (file)
@@ -2040,6 +2040,7 @@ void MDCache::predirty_journal_parents(Mutation *mut, EMetaBlob *blob,
       }
     }
 
+    parent->check_rstats();
     // next parent!
     cur = pin;
     curi = pi;
@@ -9563,6 +9564,7 @@ void MDCache::dump_cache(const char *fn)
        CDentry *dn = q->second;
        myfile << "  " << *dn << std::endl;
       }
+      dir->check_rstats();
     }
   }