]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: refactor cache rejoin, encoding/decoding
authorSage Weil <sage@newdream.net>
Sun, 27 Jul 2008 21:02:01 +0000 (14:02 -0700)
committerSage Weil <sage@newdream.net>
Sun, 27 Jul 2008 21:02:01 +0000 (14:02 -0700)
src/TODO
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/Locker.h
src/mds/MDCache.cc
src/mds/SimpleLock.h
src/messages/MMDSCacheRejoin.h
src/vstartnew.sh

index b24c7e7bed0e183f82f11615447da8a040933a3f..f0328ce37219ae4d60f48c88793af021ecbf12b2 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -27,7 +27,6 @@ snapshots
 
 mds
 - migrator import/export of versioned dentries, inodes... drop them on export...
-- purge snap during readdir
 /- call open_parents() where needed.
   - what about during recovery?  e.g. client reconnected caps...
 - resolve/rejoin vs snapshots!
index 03b5d15914299e89746978066c810815ec612abb..b9e4bcae42d829d24e218b69b63f6cfdcfbffdbb 100644 (file)
@@ -1283,23 +1283,30 @@ void CInode::encode_inodestat(bufferlist& bl, snapid_t snapid)
 
 
 
-// IMPORT/EXPORT
 
-void CInode::encode_export(bufferlist& bl)
+void CInode::_encode_base(bufferlist& bl)
 {
-  ::encode(inode, bl);
+   ::encode(inode, bl);
   ::encode(symlink, bl);
   ::encode(dirfragtree, bl);
   ::encode(xattrs, bl);
   encode_snap(bl);
-  
-  bool dirty = is_dirty();
-  ::encode(dirty, bl);
+}
+void CInode::_decode_base(bufferlist::iterator& p)
+{
+  bool was_anchored = inode.anchored;
+  ::decode(inode, p);
+  if (parent && was_anchored != inode.anchored)
+    parent->adjust_nested_anchors((int)inode.anchored - (int)was_anchored);
 
-  ::encode(pop, bl);
-  ::encode(replica_map, bl);
+  ::decode(symlink, p);
+  ::decode(dirfragtree, p);
+  ::decode(xattrs, p);
+  decode_snap(p);
+}
 
+void CInode::_encode_locks_full(bufferlist& bl)
+{
   ::encode(authlock, bl);
   ::encode(linklock, bl);
   ::encode(dirfragtreelock, bl);
@@ -1308,7 +1315,68 @@ void CInode::encode_export(bufferlist& bl)
   ::encode(xattrlock, bl);
   ::encode(snaplock, bl);
   ::encode(nestlock, bl);
+}
+void CInode::_decode_locks_full(bufferlist::iterator& p)
+{
+  ::decode(authlock, p);
+  ::decode(linklock, p);
+  ::decode(dirfragtreelock, p);
+  ::decode(filelock, p);
+  ::decode(dirlock, p);
+  ::decode(xattrlock, p);
+  ::decode(snaplock, p);
+  ::decode(nestlock, p);
+}
 
+void CInode::_encode_locks_state(bufferlist& bl)
+{
+  authlock.encode_state(bl);
+  linklock.encode_state(bl);
+  dirfragtreelock.encode_state(bl);
+  filelock.encode_state(bl);
+  dirlock.encode_state(bl);
+  nestlock.encode_state(bl);
+  xattrlock.encode_state(bl);
+  snaplock.encode_state(bl);
+}
+void CInode::_decode_locks_state(bufferlist::iterator& p)
+{
+  authlock.decode_state(p);
+  linklock.decode_state(p);
+  dirfragtreelock.decode_state(p);
+  filelock.decode_state(p);
+  dirlock.decode_state(p);
+  nestlock.decode_state(p);
+  xattrlock.decode_state(p);
+  snaplock.decode_state(p);
+}
+void CInode::_decode_locks_rejoin(bufferlist::iterator& p, list<Context*>& waiters)
+{
+  authlock.decode_state_rejoin(p, waiters);
+  linklock.decode_state_rejoin(p, waiters);
+  dirfragtreelock.decode_state_rejoin(p, waiters);
+  filelock.decode_state_rejoin(p, waiters);
+  dirlock.decode_state_rejoin(p, waiters);
+  nestlock.decode_state_rejoin(p, waiters);
+  xattrlock.decode_state_rejoin(p, waiters);
+  snaplock.decode_state_rejoin(p, waiters);
+}
+
+
+// IMPORT/EXPORT
+
+void CInode::encode_export(bufferlist& bl)
+{
+  _encode_base(bl);
+
+  bool dirty = is_dirty();
+  ::encode(dirty, bl);
+
+  ::encode(pop, bl);
+
+  ::encode(replica_map, bl);
+
+  _encode_locks_full(bl);
   get(PIN_TEMPEXPORTING);
 }
 
@@ -1325,15 +1393,7 @@ void CInode::finish_export(utime_t now)
 void CInode::decode_import(bufferlist::iterator& p,
                           LogSegment *ls)
 {
-  bool was_anchored = inode.anchored;
-  ::decode(inode, p);
-  if (parent && was_anchored != inode.anchored)
-    parent->adjust_nested_anchors((int)inode.anchored - (int)was_anchored);
-
-  ::decode(symlink, p);
-  ::decode(dirfragtree, p);
-  ::decode(xattrs, p);
-  decode_snap(p);
+  _decode_base(p);
 
   bool dirty;
   ::decode(dirty, p);
@@ -1345,12 +1405,5 @@ void CInode::decode_import(bufferlist::iterator& p,
   ::decode(replica_map, p);
   if (!replica_map.empty()) get(PIN_REPLICATED);
 
-  ::decode(authlock, p);
-  ::decode(linklock, p);
-  ::decode(dirfragtreelock, p);
-  ::decode(filelock, p);
-  ::decode(dirlock, p);
-  ::decode(xattrlock, p);
-  ::decode(snaplock, p);
-  ::decode(nestlock, p);
+  _decode_locks_full(p);
 }
index e35ca0abbba954c75b5a0fc3dbc786420d3c6c8d..8f43328ae00610072f99760dc7d14e0a583180ce 100644 (file)
@@ -374,6 +374,16 @@ private:
   void add_waiter(int tag, Context *c);
 
 
+  // -- encode/decode helpers --
+  void _encode_base(bufferlist& bl);
+  void _decode_base(bufferlist::iterator& p);
+  void _encode_locks_full(bufferlist& bl);
+  void _decode_locks_full(bufferlist::iterator& p);
+  void _encode_locks_state(bufferlist& bl);
+  void _decode_locks_state(bufferlist::iterator& p);
+  void _decode_locks_rejoin(bufferlist::iterator& p, list<Context*>& waiters);
+
+
   // -- import/export --
   void encode_export(bufferlist& bl);
   void finish_export(utime_t now);
@@ -684,98 +694,48 @@ public:
 // discover
 
 class CInodeDiscover {
-  
-  inode_t    inode;
-  string     symlink;
-  fragtree_t dirfragtree;
-  map<string, bufferptr> xattrs;
+  inodeno_t ino;
+  bufferlist base;
+  bufferlist locks;
   __s32        replica_nonce;
   
-  __u32      authlock_state;
-  __u32      linklock_state;
-  __u32      dirfragtreelock_state;
-  __u32      filelock_state;
-  __u32      dirlock_state;
-  __u32      xattrlock_state;
-  __u32      snaplock_state;
-  __u32      nestlock_state;
-
  public:
   CInodeDiscover() {}
   CInodeDiscover(CInode *in, int nonce) {
-    inode = in->inode;
-    symlink = in->symlink;
-    dirfragtree = in->dirfragtree;
-    xattrs = in->xattrs;
-
+    ino = in->ino();
+    in->_encode_base(base);
+    in->_encode_locks_state(locks);
     replica_nonce = nonce;
-
-    authlock_state = in->authlock.get_replica_state();
-    linklock_state = in->linklock.get_replica_state();
-    dirfragtreelock_state = in->dirfragtreelock.get_replica_state();
-    filelock_state = in->filelock.get_replica_state();
-    dirlock_state = in->dirlock.get_replica_state();
-    xattrlock_state = in->xattrlock.get_replica_state();
-    snaplock_state = in->snaplock.get_replica_state();
-    nestlock_state = in->nestlock.get_replica_state();
   }
   CInodeDiscover(bufferlist::iterator &p) {
     decode(p);
   }
 
-  inodeno_t get_ino() { return inode.ino; }
+  inodeno_t get_ino() { return ino; }
   int get_replica_nonce() { return replica_nonce; }
 
   void update_inode(CInode *in) {
-    if (in->parent && inode.anchored != in->inode.anchored)
-      in->parent->adjust_nested_anchors((int)inode.anchored - (int)in->inode.anchored);
-    in->inode = inode;
-    in->symlink = symlink;
-    in->dirfragtree = dirfragtree;
-    in->xattrs = xattrs;
+    bufferlist::iterator p = base.begin();
+    in->_decode_base(p);
     in->replica_nonce = replica_nonce;
   }
   void init_inode_locks(CInode *in) {
-    in->authlock.set_state(authlock_state);
-    in->linklock.set_state(linklock_state);
-    in->dirfragtreelock.set_state(dirfragtreelock_state);
-    in->filelock.set_state(filelock_state);
-    in->dirlock.set_state(dirlock_state);
-    in->xattrlock.set_state(xattrlock_state);
-    in->snaplock.set_state(snaplock_state);
-    in->nestlock.set_state(nestlock_state);
+    bufferlist::iterator p = base.begin();
+    in->_decode_locks_state(p);
   }
   
   void encode(bufferlist &bl) const {
-    ::encode(inode, bl);
-    ::encode(symlink, bl);
-    ::encode(dirfragtree, bl);
-    ::encode(xattrs, bl);
+    ::encode(ino, bl);
+    ::encode(base, bl);
+    ::encode(locks, bl);
     ::encode(replica_nonce, bl);
-    ::encode(authlock_state, bl);
-    ::encode(linklock_state, bl);
-    ::encode(dirfragtreelock_state, bl);
-    ::encode(filelock_state, bl);
-    ::encode(dirlock_state, bl);
-    ::encode(xattrlock_state, bl);
-    ::encode(snaplock_state, bl);
-    ::encode(nestlock_state, bl);
   }
 
   void decode(bufferlist::iterator &p) {
-    ::decode(inode, p);
-    ::decode(symlink, p);
-    ::decode(dirfragtree, p);
-    ::decode(xattrs, p);
+    ::decode(ino, p);
+    ::decode(base, p);
+    ::decode(locks, p);
     ::decode(replica_nonce, p);
-    ::decode(authlock_state, p);
-    ::decode(linklock_state, p);
-    ::decode(dirfragtreelock_state, p);
-    ::decode(filelock_state, p);
-    ::decode(dirlock_state, p);
-    ::decode(xattrlock_state, p);
-    ::decode(snaplock_state, p);
-    ::decode(nestlock_state, p);
   }  
 
 };
index aedb4674fbf3a38008b7d25962bdb1047569b80c..1fc8e0adb656b6ca6e0aa20d90315d66f4ffbe8a 100644 (file)
@@ -459,25 +459,6 @@ void Locker::xlock_finish(SimpleLock *lock, Mutation *mut)
 
 
 
-/** rejoin_set_state
- * @lock the lock 
- * @s the new state
- * @waiters list for anybody waiting on this lock
- */
-void Locker::rejoin_set_state(SimpleLock *lock, int s, list<Context*>& waiters)
-{
-  if (!lock->is_stable()) {
-    lock->set_state(s);
-    lock->get_parent()->auth_unpin(lock);
-  } else {
-    lock->set_state(s);
-  }
-  lock->take_waiting(SimpleLock::WAIT_ALL, waiters);
-}
-
-
-
-
 // file i/o -----------------------------------------
 
 version_t Locker::issue_file_data_version(CInode *in)
index b0c0c481049865db724ec3ea291350c684768fbe..52f17177e244bef379652493d80bf1bc343f5720 100644 (file)
@@ -94,9 +94,6 @@ protected:
   bool wrlock_start(SimpleLock *lock, MDRequest *mut);
   void wrlock_finish(SimpleLock *lock, Mutation *mut);
 
-public:
-  void rejoin_set_state(SimpleLock *lock, int s, list<Context*>& waiters);
-
   // simple
 public:
   void try_simple_eval(SimpleLock *lock);
index 8bd428352fe1473b91b5628e9b94915bdaba2226..29bb436b062ad8726d3daf4cede47f1aca1a6a92 100644 (file)
@@ -2409,29 +2409,17 @@ void MDCache::rejoin_send_rejoins()
       // strong
       if (p->first == 0 && root) {
        p->second->add_weak_inode(root->ino());
-       p->second->add_strong_inode(root->ino(), root->get_replica_nonce(),
+       p->second->add_strong_inode(root->ino(),
                                    root->get_caps_wanted(),
-                                   root->authlock.get_state(),
-                                   root->linklock.get_state(),
-                                   root->dirfragtreelock.get_state(),
-                                   root->filelock.get_state(),
                                    root->dirlock.get_state(),
-                                   root->nestlock.get_state(),
-                                   root->snaplock.get_state(),
-                                   root->xattrlock.get_state());
+                                   root->nestlock.get_state());
       }
       if (CInode *in = get_inode(MDS_INO_STRAY(p->first))) {
        p->second->add_weak_inode(in->ino());
-       p->second->add_strong_inode(in->ino(), in->get_replica_nonce(),
+       p->second->add_strong_inode(in->ino(),
                                    in->get_caps_wanted(),
-                                   in->authlock.get_state(),
-                                   in->linklock.get_state(),
-                                   in->dirfragtreelock.get_state(),
-                                   in->filelock.get_state(),
                                    in->dirlock.get_state(),
-                                   in->nestlock.get_state(),
-                                   in->snaplock.get_state(),
-                                   in->xattrlock.get_state());
+                                   in->nestlock.get_state());
       }
     }
   }  
@@ -2555,16 +2543,10 @@ void MDCache::rejoin_walk(CDir *dir, MMDSCacheRejoin *rejoin)
       if (dn->is_primary()) {
        CInode *in = dn->get_inode();
        dout(15) << " add_strong_inode " << *in << dendl;
-       rejoin->add_strong_inode(in->ino(), in->get_replica_nonce(),
+       rejoin->add_strong_inode(in->ino(),
                                 in->get_caps_wanted(),
-                                in->authlock.get_state(),
-                                in->linklock.get_state(),
-                                in->dirfragtreelock.get_state(),
-                                in->filelock.get_state(),
                                 in->dirlock.get_state(),
-                                in->nestlock.get_state(),
-                                in->snaplock.get_state(),
-                                in->xattrlock.get_state());
+                                in->nestlock.get_state());
        in->get_nested_dirfrags(nested);
       }
     }
@@ -2749,18 +2731,8 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
        in->dirlock.set_state(LOCK_SCATTER);
 
       if (ack) {
-       ack->add_full_inode(in->inode, in->symlink, in->dirfragtree);
-       ack->add_strong_inode(in->ino(), 
-                             inonce,
-                             0,
-                             in->authlock.get_replica_state(), 
-                             in->linklock.get_replica_state(), 
-                             in->dirfragtreelock.get_replica_state(), 
-                             in->filelock.get_replica_state(),
-                             in->dirlock.get_replica_state(),
-                             in->nestlock.get_replica_state(),
-                             in->snaplock.get_replica_state(),
-                             in->xattrlock.get_replica_state());
+       ack->add_inode_base(in);
+       ack->add_inode_locks(in, inonce);
       }
     }
   }
@@ -2777,17 +2749,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
     dout(10) << " have base " << *in << dendl;
     
     if (ack) 
-      ack->add_strong_inode(in->ino(), 
-                           inonce,
-                           0,
-                           in->authlock.get_replica_state(), 
-                           in->linklock.get_replica_state(), 
-                           in->dirfragtreelock.get_replica_state(), 
-                           in->filelock.get_replica_state(),
-                           in->dirlock.get_replica_state(),
-                           in->nestlock.get_replica_state(),
-                           in->snaplock.get_replica_state(),
-                           in->xattrlock.get_replica_state());
+      ack->add_inode_locks(in, inonce);
   }
 
   if (survivor) {
@@ -3150,38 +3112,34 @@ void MDCache::handle_cache_rejoin_ack(MMDSCacheRejoin *ack)
        assert(0);  // uh oh.   
       }
       dn->set_replica_nonce(q->second.nonce);
-      mds->locker->rejoin_set_state(&dn->lock, q->second.lock, waiters);
+      dn->lock.set_state_rejoin(q->second.lock, waiters);
       dn->state_clear(CDentry::STATE_REJOINING);
       dout(10) << " got " << *dn << dendl;
     }
   }
 
   // full inodes
-  for (list<MMDSCacheRejoin::inode_full>::iterator p = ack->full_inodes.begin();
-       p != ack->full_inodes.end();
-       ++p) {
-    CInode *in = get_inode(p->inode.ino);
+  bufferlist::iterator p = ack->inode_base.begin();
+  while (!p.end()) {
+    inodeno_t ino;
+    ::decode(ino, p);
+    CInode *in = get_inode(ino);
     if (!in) continue;
-    if (in->parent && in->inode.anchored != p->inode.anchored)
-      in->parent->adjust_nested_anchors( (int)p->inode.anchored - (int)in->inode.anchored );
-    in->inode = p->inode;
-    in->symlink = p->symlink;
-    in->dirfragtree = p->dirfragtree;
+    in->_decode_base(p);
     dout(10) << " got inode content " << *in << dendl;
   }
 
   // inodes
-  for (map<inodeno_t, MMDSCacheRejoin::inode_strong>::iterator p = ack->strong_inodes.begin();
-       p != ack->strong_inodes.end();
-       ++p) {
-    CInode *in = get_inode(p->first);
+  p = ack->inode_locks.begin();
+  while (!p.end()) {
+    inodeno_t ino;
+    ::decode(ino, p);
+    int32_t nonce;
+    ::decode(nonce, p);
+    CInode *in = get_inode(ino);
     if (!in) continue;
-    in->set_replica_nonce(p->second.nonce);
-    mds->locker->rejoin_set_state(&in->authlock, p->second.authlock, waiters);
-    mds->locker->rejoin_set_state(&in->linklock, p->second.linklock, waiters);
-    mds->locker->rejoin_set_state(&in->dirfragtreelock, p->second.dirfragtreelock, waiters);
-    mds->locker->rejoin_set_state(&in->filelock, p->second.filelock, waiters);
-    mds->locker->rejoin_set_state(&in->dirlock, p->second.dirlock, waiters);
+    in->set_replica_nonce(nonce);
+    in->_decode_locks_rejoin(p, waiters);
     in->state_clear(CInode::STATE_REJOINING);
     dout(10) << " got " << *in << dendl;
   }
@@ -3219,7 +3177,7 @@ void MDCache::handle_cache_rejoin_missing(MMDSCacheRejoin *missing)
     }
     
     dout(10) << " sending " << *in << dendl;
-    full->add_full_inode(in->inode, in->symlink, in->dirfragtree);
+    full->add_inode_base(in);
   }
 
   mds->send_message_mds(full, missing->get_source().num());
@@ -3231,20 +3189,17 @@ void MDCache::handle_cache_rejoin_full(MMDSCacheRejoin *full)
   int from = full->get_source().num();
   
   // integrate full inodes
-  for (list<MMDSCacheRejoin::inode_full>::iterator p = full->full_inodes.begin();
-       p != full->full_inodes.end();
-       ++p) {
-    CInode *in = get_inode(p->inode.ino);
+  bufferlist::iterator p = full->inode_base.begin();
+  while (!p.end()) {
+    inodeno_t ino;
+    ::decode(ino, p);
+    CInode *in = get_inode(ino);
     assert(in);
+    in->_decode_base(p);
 
     set<CInode*>::iterator q = rejoin_undef_inodes.find(in);
     if (q != rejoin_undef_inodes.end()) {
       CInode *in = *q;
-      if (in->parent && in->inode.anchored != p->inode.anchored)
-       in->parent->adjust_nested_anchors( (int)p->inode.anchored - (int)in->inode.anchored );
-      in->inode = p->inode;
-      in->symlink = p->symlink;
-      in->dirfragtree = p->dirfragtree;
       in->state_clear(CInode::STATE_REJOINUNDEF);
       dout(10) << " got full " << *in << dendl;
       rejoin_undef_inodes.erase(q);
@@ -3461,16 +3416,8 @@ void MDCache::rejoin_send_acks()
        for (map<int,int>::iterator r = in->replicas_begin();
             r != in->replicas_end();
             ++r) {
-         ack[r->first]->add_full_inode(in->inode, in->symlink, in->dirfragtree);
-         ack[r->first]->add_strong_inode(in->ino(), r->second, 0,
-                                         in->authlock.get_replica_state(),
-                                         in->linklock.get_replica_state(),
-                                         in->dirfragtreelock.get_replica_state(),
-                                         in->filelock.get_replica_state(),
-                                         in->dirlock.get_replica_state(),
-                                         in->nestlock.get_replica_state(),
-                                         in->snaplock.get_replica_state(),
-                                         in->xattrlock.get_replica_state());
+         ack[r->first]->add_inode_base(in);
+         ack[r->first]->add_inode_locks(in, r->second);
        }
        
        // subdirs in this subtree?
@@ -3479,36 +3426,20 @@ void MDCache::rejoin_send_acks()
     }
   }
 
-  // root inodes too
-  if (root) 
+  // base inodes too
+  if (root && root->is_auth()
     for (map<int,int>::iterator r = root->replicas_begin();
         r != root->replicas_end();
         ++r) {
-      ack[r->first]->add_full_inode(root->inode, root->symlink, root->dirfragtree);
-      ack[r->first]->add_strong_inode(root->ino(), r->second, 0,
-                                     root->authlock.get_replica_state(),
-                                     root->linklock.get_replica_state(),
-                                     root->dirfragtreelock.get_replica_state(),
-                                     root->filelock.get_replica_state(),
-                                     root->dirlock.get_replica_state(),
-                                     root->nestlock.get_replica_state(),
-                                     root->snaplock.get_replica_state(),
-                                     root->xattrlock.get_replica_state());
+      ack[r->first]->add_inode_base(root);
+      ack[r->first]->add_inode_locks(root, r->second);
     }
   if (stray)
     for (map<int,int>::iterator r = stray->replicas_begin();
         r != stray->replicas_end();
         ++r) {
-      ack[r->first]->add_full_inode(stray->inode, stray->symlink, stray->dirfragtree);
-      ack[r->first]->add_strong_inode(stray->ino(), r->second, 0,
-                                     stray->authlock.get_replica_state(),
-                                     stray->linklock.get_replica_state(),
-                                     stray->dirfragtreelock.get_replica_state(),
-                                     stray->filelock.get_replica_state(),
-                                     stray->dirlock.get_replica_state(),
-                                     stray->nestlock.get_replica_state(),
-                                     stray->snaplock.get_replica_state(),
-                                     stray->xattrlock.get_replica_state());
+      ack[r->first]->add_inode_base(stray);
+      ack[r->first]->add_inode_locks(stray, r->second);
     }
 
   // send acks
@@ -4045,7 +3976,7 @@ void MDCache::trim_non_auth()
     if (dn->is_auth()) {
       // add back into lru (at the top)
       lru.lru_insert_top(dn);
-      
+
       if (!first_auth) {
        first_auth = dn;
       } else {
index f412e4e303e53c730cbb8f3d447364b077f540ae..0be17e0d4c86261df492a21edec6736a761de573 100644 (file)
@@ -156,7 +156,17 @@ public:
     state = s; 
     assert(!is_stable() || gather_set.size() == 0);  // gather should be empty in stable states.
     return s;
-  };
+  }
+  void set_state_rejoin(int s, list<Context*>& waiters) {
+    if (!is_stable()) {
+      state = s;
+      get_parent()->auth_unpin(this);
+    } else {
+      state = s;
+    }
+    take_waiting(SimpleLock::WAIT_ALL, waiters);
+  }
+
   bool is_stable() {
     return state >= 0;
   }
@@ -235,6 +245,18 @@ public:
     ::decode(state, p);
     ::decode(gather_set, p);
   }
+  void encode_state(bufferlist& bl) const {
+    ::encode(state, bl);
+  }
+  void decode_state(bufferlist::iterator& p) {
+    ::decode(state, p);
+  }
+  void decode_state_rejoin(bufferlist::iterator& p, list<Context*>& waiters) {
+    __s32 s;
+    ::decode(s, p);
+    set_state_rejoin(s, waiters);
+  }
+
 
   
   // simplelock specifics
index 1e364f2d7c7f77e87830369cc19b6be653f581be..ded498da77d2ff2acc39c3921bf058ae355aa62e 100644 (file)
@@ -19,6 +19,8 @@
 
 #include "include/types.h"
 
+#include "mds/CInode.h"
+
 // sent from replica to auth
 
 class MMDSCacheRejoin : public Message {
@@ -43,65 +45,24 @@ class MMDSCacheRejoin : public Message {
   // -- types --
   struct inode_strong { 
     int32_t caps_wanted;
-    int32_t nonce;
-    int32_t authlock;
-    int32_t linklock;
-    int32_t dirfragtreelock;
-    int32_t filelock;
-    int32_t dirlock, nestlock, snaplock, xattrlock;
+    int32_t dirlock, nestlock;
     inode_strong() {}
-    inode_strong(int n, int cw=0, int a=0, int l=0, int dft=0, int f=0, int dl=0, int nl=0, int snl=0, int xal=0) : 
+    inode_strong(int cw, int dl, int nl) : 
       caps_wanted(cw),
-      nonce(n),
-      authlock(a), linklock(l), dirfragtreelock(dft), filelock(f), dirlock(dl), nestlock(nl), snaplock(snl), xattrlock(xal) { }
+      dirlock(dl), nestlock(nl) { }
     void encode(bufferlist &bl) const {
       ::encode(caps_wanted, bl);
-      ::encode(nonce, bl);
-      ::encode(authlock, bl);
-      ::encode(linklock, bl);
-      ::encode(dirfragtreelock, bl);
-      ::encode(filelock, bl);
       ::encode(dirlock, bl);
       ::encode(nestlock, bl);
-      ::encode(snaplock, bl);
-      ::encode(xattrlock, bl);
     }
     void decode(bufferlist::iterator &bl) {
       ::decode(caps_wanted, bl);
-      ::decode(nonce, bl);
-      ::decode(authlock, bl);
-      ::decode(linklock, bl);
-      ::decode(dirfragtreelock, bl);
-      ::decode(filelock, bl);
       ::decode(dirlock, bl);
       ::decode(nestlock, bl);
-      ::decode(snaplock, bl);
-      ::decode(xattrlock, bl);
     }
   };
   WRITE_CLASS_ENCODER(inode_strong)
 
-  struct inode_full {
-    inode_t inode;
-    string symlink;
-    fragtree_t dirfragtree;
-    inode_full() {}
-    inode_full(const inode_t& i, const string& s, const fragtree_t& f) :
-      inode(i), symlink(s), dirfragtree(f) {}
-
-    void decode(bufferlist::iterator& p) {
-      ::decode(inode, p);
-      ::decode(symlink, p);
-      ::decode(dirfragtree, p);
-    }
-    void encode(bufferlist& bl) const {
-      ::encode(inode, bl);
-      ::encode(symlink, bl);
-      ::encode(dirfragtree, bl);
-    }
-  };
-  WRITE_CLASS_ENCODER(inode_full)
-
   struct dirfrag_strong {
     int32_t nonce;
     int8_t  dir_rep;
@@ -180,7 +141,8 @@ class MMDSCacheRejoin : public Message {
   map<inodeno_t,string> cap_export_paths;
 
   // full
-  list<inode_full> full_inodes;
+  bufferlist inode_base;
+  bufferlist inode_locks;
 
   // authpins, xlocks
   map<inodeno_t, metareqid_t> authpinned_inodes;
@@ -203,11 +165,16 @@ class MMDSCacheRejoin : public Message {
   void add_weak_inode(inodeno_t i) {
     weak_inodes.insert(i);
   }
-  void add_strong_inode(inodeno_t i, int n, int cw, int a, int l, int dft, int f, int dl, int nl, int snl, int xl) {
-    strong_inodes[i] = inode_strong(n, cw, a, l, dft, f, dl, nl, snl, xl);
+  void add_strong_inode(inodeno_t i, int cw, int dl, int nl) {
+    strong_inodes[i] = inode_strong(cw, dl, nl);
+  }
+  void add_inode_locks(CInode *in, int nonce) {
+    ::encode(in->inode.ino, inode_locks);
+    in->_encode_locks_state(inode_locks);
   }
-  void add_full_inode(inode_t &i, const string& s, const fragtree_t &f) {
-    full_inodes.push_back(inode_full(i, s, f));
+  void add_inode_base(CInode *in) {
+    ::encode(in->inode.ino, inode_base);
+    in->_encode_base(inode_base);
   }
   void add_inode_authpin(inodeno_t ino, const metareqid_t& ri) {
     authpinned_inodes[ino] = ri;
@@ -256,7 +223,8 @@ class MMDSCacheRejoin : public Message {
   void encode_payload() {
     ::encode(op, payload);
     ::encode(strong_inodes, payload);
-    ::encode(full_inodes, payload);
+    ::encode(inode_base, payload);
+    ::encode(inode_locks, payload);
     ::encode(authpinned_inodes, payload);
     ::encode(xlocked_inodes, payload);
     ::encode(cap_export_bl, payload);
@@ -272,7 +240,8 @@ class MMDSCacheRejoin : public Message {
     bufferlist::iterator p = payload.begin();
     ::decode(op, p);
     ::decode(strong_inodes, p);
-    ::decode(full_inodes, p);
+    ::decode(inode_base, p);
+    ::decode(inode_locks, p);
     ::decode(authpinned_inodes, p);
     ::decode(xlocked_inodes, p);
     ::decode(cap_export_bl, p);
@@ -293,7 +262,6 @@ class MMDSCacheRejoin : public Message {
 };
 
 WRITE_CLASS_ENCODER(MMDSCacheRejoin::inode_strong)
-WRITE_CLASS_ENCODER(MMDSCacheRejoin::inode_full)
 WRITE_CLASS_ENCODER(MMDSCacheRejoin::dirfrag_strong)
 WRITE_CLASS_ENCODER(MMDSCacheRejoin::dn_strong)
 WRITE_CLASS_ENCODER(MMDSCacheRejoin::dn_weak)
index 8a3af6fa0a8e3e8cb537be70e0c12957dffa0b13..c8a8a4f3d1b7f16683aed184f4fd6ec1e00a4259 100755 (executable)
@@ -43,8 +43,8 @@ done
 
 # mds
 $CEPH_BIN/cmds -d --debug_ms 1 --debug_mds 20 --mds_log_max_segments 10 --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20
-#$CEPH_BIN/cmds -d --debug_ms 1 --debug_mds 20 --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20
-#./cmonctl mds set_max_mds 2
+$CEPH_BIN/cmds -d --debug_ms 1 --debug_mds 20 --mds_thrash_fragments 0 --mds_thrash_exports 0 #--debug_ms 20
+./cmonctl mds set_max_mds 2
 
 echo "started.  stop.sh to stop.  see out/* (e.g. 'tail -f out/????') for debug output."