]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: snaprealm replay, reconnect fixes
authorSage Weil <sage@newdream.net>
Mon, 4 Aug 2008 21:32:27 +0000 (14:32 -0700)
committerSage Weil <sage@newdream.net>
Mon, 4 Aug 2008 21:32:27 +0000 (14:32 -0700)
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/Server.cc
src/mds/journal.cc
src/mds/snap.cc
src/mds/snap.h

index 837e4eab454fcd699a5568f9ce2bfffd8f9aa112..113e0a4515ad142837f1c476633d835cdbc37cf1 100644 (file)
@@ -3504,7 +3504,7 @@ void MDCache::process_reconnected_caps()
 
     SnapRealm *realm = in->find_snaprealm();
 
-    // is this realm's parents fully open?
+    // are this realm's parents fully open?
     if (realm->have_past_parents_open()) {
       dout(10) << " have past snap parents for realm " << *realm 
               << " on " << *realm->inode << dendl;
@@ -6180,9 +6180,11 @@ void MDCache::_snaprealm_create_finish(MDRequest *mdr, Mutation *mut, CInode *in
   
   send_realm_splits(updates);
 
+  /*
   static int count = 5;
   if (--count == 0)
     assert(0);  // hack test test **********
+  */
 
   // done.
   mdr->more()->stid = 0;  // caller will likely need to reuse this
index da852d47d4dd4e80f76de92d2af7bf31ad39f156..6007f3be9d546f61f8ff267c5dd41a40f038a506 100644 (file)
@@ -654,7 +654,7 @@ public:
 
   // [reconnect/rejoin caps]
   map<CInode*,map<int, inodeno_t> >  reconnected_caps;   // inode -> client -> realmino
-  map<inodeno_t,map<int, snapid_t> > reconnected_snaprealms;
+  map<inodeno_t,map<int, snapid_t> > reconnected_snaprealms;  // realmino -> client -> realmseq
 
   void add_reconnected_cap(CInode *in, int client, inodeno_t realm) {
     reconnected_caps[in][client] = realm;
index 482d2a3d794d6bfaf8a8bbc0dd219a10148f5319..696675ec7de4cff17f680e69a99ba8decc25eb9d 100644 (file)
@@ -382,11 +382,16 @@ void Server::handle_client_reconnect(MClientReconnect *m)
       CInode *in = mdcache->get_inode(p->first);
       if (in) {
        assert(in->snaprealm);
-       if (in->snaprealm->have_past_parents_open())
+       if (in->snaprealm->have_past_parents_open()) {
+         dout(15) << "open snaprealm (w/ past parents) on " << *in << dendl;
          mdcache->finish_snaprealm_reconnect(from, in->snaprealm, snapid_t(p->second.seq));
-       else
+       } else {
+         dout(15) << "open snaprealm (w/o past parents) on " << *in << dendl;
          mdcache->add_reconnected_snaprealm(from, p->first, snapid_t(p->second.seq));
+       }
       } else {
+       dout(15) << "open snaprealm (w/o inode) on " << p->first
+                << " seq " << p->second.seq << dendl;
        mdcache->add_reconnected_snaprealm(from, p->first, snapid_t(p->second.seq));
       }
     }
@@ -398,7 +403,8 @@ void Server::handle_client_reconnect(MClientReconnect *m)
       CInode *in = mdcache->get_inode(p->first);
       if (in && in->is_auth()) {
        // we recovered it, and it's ours.  take note.
-       dout(15) << "open caps on " << *in << dendl;
+       dout(15) << "open cap realm " << inodeno_t(p->second.capinfo.snaprealm)
+                << " on " << *in << dendl;
        Capability *cap = in->reconnect_cap(from, p->second.capinfo);
        session->touch_cap(cap);
        mds->mdcache->add_reconnected_cap(in, from, inodeno_t(p->second.capinfo.snaprealm));
index 63327fab688bdd3c735ba7236e0e75943bcecefd..d0778d8c0f151025a440cc756f849f252f2873fd 100644 (file)
@@ -371,6 +371,7 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        assert(dn->last == p->dnlast);
       }
 
+      bool do_snap_split = false;
       CInode *in = mds->mdcache->get_inode(p->inode.ino, p->dnlast);
       if (!in) {
        in = new CInode(mds->mdcache, true, p->dnfirst, p->dnlast);
@@ -379,6 +380,8 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        if (in->inode.is_dir()) {
          in->dirfragtree = p->dirfragtree;
          in->decode_snap_blob(p->snapbl);
+         if (in->snaprealm)
+           do_snap_split = true;
        }
        if (in->inode.is_symlink()) in->symlink = p->symlink;
        mds->mdcache->add_inode(in);
@@ -405,7 +408,10 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
        in->xattrs = p->xattrs;
        if (in->inode.is_dir()) {
          in->dirfragtree = p->dirfragtree;
+         bool had = in->snaprealm ? true:false;
          in->decode_snap_blob(p->snapbl);
+         if (!had && in->snaprealm)
+           do_snap_split = true;
        }
        if (in->inode.is_symlink()) in->symlink = p->symlink;
        if (p->dirty) in->_mark_dirty(logseg);
@@ -418,16 +424,22 @@ void EMetaBlob::replay(MDS *mds, LogSegment *logseg)
          dout(10) << "EMetaBlob.replay for [" << p->dnfirst << "," << p->dnlast << "] had " << *in << dendl;
        }
        in->first = p->dnfirst;
-      }
 
-      // verify open snaprealm parents
-      if (in->snaprealm) {
-       SnapRealm *actual = in->get_parent_dn()->get_dir()->inode->find_snaprealm();
-       if (actual != in->snaprealm->parent) {
-         dout(10) << "EMetaBlob.replay fixing snaprealm open_parent" << dendl;
-         in->snaprealm->change_open_parent_to(actual);
+       // verify open snaprealm parent
+       if (in->snaprealm) {
+         SnapRealm *actual = in->get_parent_dn()->get_dir()->inode->find_snaprealm();
+         if (actual != in->snaprealm->parent) {
+           dout(10) << "EMetaBlob.replay  fixing snaprealm open parent" << dendl;
+           in->snaprealm->change_open_parent_to(actual);
+         }
        }
       }
+
+      if (do_snap_split && in->snaprealm) {
+       dout(10) << "EMetaBlob.reply  splitting snaprealm" << dendl;
+       in->snaprealm->parent->split_at(in->snaprealm);
+      }
+
     }
 
     // remote dentries
index cfd08bfaf5291171f90e34a68d7734428e1c1e3b..83f0301138e16179ebf8818a904349a221e72c5c 100644 (file)
                                                  << ".cache.snaprealm(" << inode->ino() \
                                                  << " seq " << seq << " " << this << ") "
 
+ostream& operator<<(ostream& out, const SnapRealm& realm) 
+{
+  out << "snaprealm(" << realm.inode->ino()
+      << " seq " << realm.seq
+      << " lc " << realm.last_created
+      << " snaps=" << realm.snaps;
+  if (realm.past_parents.size()) {
+    out << " past_parents=(";
+    for (map<snapid_t, snaplink_t>::const_iterator p = realm.past_parents.begin(); 
+        p != realm.past_parents.end(); 
+        p++) {
+      if (p != realm.past_parents.begin()) out << ",";
+      out << p->second.first << "-" << p->first
+         << "=" << p->second.ino;
+    }
+    out << ")";
+  }
+  out << " " << &realm << ")";
+  return out;
+}
+
+
+
+
 void SnapRealm::add_open_past_parent(SnapRealm *parent)
 {
   open_past_parents[parent->inode->ino()] = parent;
index 928905181ff43a0f8822bb2667a04064fe0d3a6a..3f5d63c23357e4f579d13108f7a3e0cf6b871c5a 100644 (file)
@@ -211,26 +211,7 @@ struct SnapRealm {
 };
 WRITE_CLASS_ENCODER(SnapRealm)
 
-inline ostream& operator<<(ostream& out, const SnapRealm &realm) {
-  out << "snaprealm(seq " << realm.seq
-      << " lc " << realm.last_created
-      << " snaps=" << realm.snaps;
-  if (realm.past_parents.size()) {
-    out << " past_parents=(";
-    for (map<snapid_t, snaplink_t>::const_iterator p = realm.past_parents.begin(); 
-        p != realm.past_parents.end(); 
-        p++) {
-      if (p != realm.past_parents.begin()) out << ",";
-      out << p->second.first << "-" << p->first
-         << "=" << p->second.ino;
-    }
-    out << ")";
-  }
-  out << " " << &realm << ")";
-  return out;
-}
-
-
+ostream& operator<<(ostream& out, const SnapRealm &realm);