]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: match last snap exactly on replay, add_*_dentry
authorSage Weil <sage@newdream.net>
Fri, 7 Nov 2008 21:26:41 +0000 (13:26 -0800)
committerSage Weil <sage@newdream.net>
Fri, 7 Nov 2008 21:26:41 +0000 (13:26 -0800)
In general, we add new snapped dentries and THEN the new live dentry
to the metablob.  That means that during replay, we see [2,2] followed
by [3,head], replacing [2,head].  The [2,2] dentry should be added
anew, without paying heed to [2,head], and then the [3,head] should
replace/update [2,head].

It was mainly just the assertions in add_*_dentry that were getting
in the way.. but the lookup_exact_snap is also slightly faster.

src/mds/CDir.cc
src/mds/CDir.h
src/mds/journal.cc

index e0f17f7c4b8733065225100f7df81d68f54ddd6a..093de51c22060a07a84ea04be4cf078b05067ec0 100644 (file)
@@ -211,7 +211,7 @@ CDentry* CDir::add_null_dentry(const nstring& dname,
                               snapid_t first, snapid_t last)
 {
   // foreign
-  assert(lookup(dname, last) == 0);
+  assert(lookup_exact_snap(dname, last) == 0);
    
   // create dentry
   CDentry* dn = new CDentry(dname, first, last);
@@ -247,7 +247,7 @@ CDentry* CDir::add_primary_dentry(const nstring& dname, CInode *in,
                                  snapid_t first, snapid_t last) 
 {
   // primary
-  assert(lookup(dname, last) == 0);
+  assert(lookup_exact_snap(dname, last) == 0);
   
   // create dentry
   CDentry* dn = new CDentry(dname, first, last);
@@ -278,7 +278,7 @@ CDentry* CDir::add_remote_dentry(const nstring& dname, inodeno_t ino, unsigned c
                                 snapid_t first, snapid_t last) 
 {
   // foreign
-  assert(lookup(dname, last) == 0);
+  assert(lookup_exact_snap(dname, last) == 0);
   
   // create dentry
   CDentry* dn = new CDentry(dname, ino, d_type, first, last);
index 91616506c8f6a467c88598a51704c082beb6a575..58d66e083d6df7f0cd24463e726322d2a5eed8a2 100644 (file)
@@ -286,6 +286,12 @@ protected:
 
   // -- dentries and inodes --
  public:
+  CDentry* lookup_exact_snap(const nstring& dname, snapid_t last) {
+    map_t::iterator p = items.find(dentry_key_t(last, dname.c_str()));
+    if (p == items.end())
+      return NULL;
+    return p->second;
+  }
   CDentry* lookup(const string& n, snapid_t snap=CEPH_NOSNAP) {
     return lookup(n.c_str(), snap);
   }
index 87e3c37eac6cef61508419c2d563288d5dad6a9c..01658a0125aad0be863b5616b75cc7495d760a7c 100644 (file)
@@ -358,8 +358,8 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
     for (list<fullbit>::iterator p = lump.get_dfull().begin();
         p != lump.get_dfull().end();
         p++) {
-      CDentry *dn = dir->lookup(p->dn, p->dnlast);
-      if (!dn || dn->last != p->dnlast) {
+      CDentry *dn = dir->lookup_exact_snap(p->dn, p->dnlast);
+      if (!dn) {
        dn = dir->add_null_dentry(p->dn, p->dnfirst, p->dnlast);
        dn->set_version(p->dnv);
        if (p->dirty) dn->_mark_dirty(logseg);
@@ -431,8 +431,8 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
     for (list<remotebit>::iterator p = lump.get_dremote().begin();
         p != lump.get_dremote().end();
         p++) {
-      CDentry *dn = dir->lookup(p->dn, p->dnlast);
-      if (!dn || dn->last != p->dnlast) {
+      CDentry *dn = dir->lookup_exact_snap(p->dn, p->dnlast);
+      if (!dn) {
        dn = dir->add_remote_dentry(p->dn, p->ino, p->d_type, p->dnfirst, p->dnlast);
        dn->set_version(p->dnv);
        if (p->dirty) dn->_mark_dirty(logseg);
@@ -455,8 +455,8 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
     for (list<nullbit>::iterator p = lump.get_dnull().begin();
         p != lump.get_dnull().end();
         p++) {
-      CDentry *dn = dir->lookup(p->dn, p->dnfirst);
-      if (!dn || dn->last != p->dnlast) {
+      CDentry *dn = dir->lookup_exact_snap(p->dn, p->dnfirst);
+      if (!dn) {
        dn = dir->add_null_dentry(p->dn, p->dnfirst, p->dnlast);
        dn->set_version(p->dnv);
        if (p->dirty) dn->_mark_dirty(logseg);