]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: unify nonce type
authorYan, Zheng <zheng.z.yan@intel.com>
Wed, 6 Nov 2013 01:28:51 +0000 (09:28 +0800)
committerYan, Zheng <zheng.z.yan@intel.com>
Mon, 16 Dec 2013 04:15:23 +0000 (12:15 +0800)
MDSCacheObject::replica_nonce is defined as __s16, but nonce type
in MDSCacheObject::replica_map is int. This mismatch may confuse
MDCache::handle_cache_expire().

this patch unifies the nonce type as uint32

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.h
src/mds/Locker.cc
src/mds/MDCache.cc
src/mds/Migrator.cc
src/mds/SimpleLock.h
src/mds/mdstypes.h
src/messages/MCacheExpire.h
src/messages/MMDSCacheRejoin.h

index e40854adfaa951f855de74948feb5db2abc19a6b..39a4c55380bdbd8a3bd4580a08ae3ed1767b57e8 100644 (file)
@@ -97,7 +97,7 @@ public:
 
   void add_waiter(uint64_t tag, Context *c);
 
-  static const int EXPORT_NONCE = 1;
+  static const unsigned EXPORT_NONCE = 1;
 
   bool is_lt(const MDSCacheObject *r) const {
     return *this < *static_cast<const CDentry*>(r);
index 596d717f6b6c05b253876e78b4737d0f78ef76a6..a02e7e7e5645f227d33e2dfb6889c40a60384add 100644 (file)
@@ -964,10 +964,10 @@ void CDir::merge(list<CDir*>& subs, list<Context*>& waiters, bool replay)
       steal_dentry(dir->items.begin()->second);
     
     // merge replica map
-    for (map<int,int>::iterator p = dir->replica_map.begin();
+    for (map<int,unsigned>::iterator p = dir->replicas_begin();
         p != dir->replica_map.end();
         ++p) {
-      int cur = replica_map[p->first];
+      unsigned cur = replica_map[p->first];
       if (p->second > cur)
        replica_map[p->first] = p->second;
     }
index f131d834ca0f058ef8e5c1181e93543d6add2e33..0aa13d70b5099ecf30bc9b9c20b87f8c913591ea 100644 (file)
@@ -140,7 +140,7 @@ public:
   static const int REP_LIST =     2;
 
 
-  static const int NONCE_EXPORT  = 1;
+  static const unsigned EXPORT_NONCE  = 1;
 
 
   // -- wait masks --
@@ -415,7 +415,7 @@ private:
   // for giving to clients
   void get_dist_spec(set<int>& ls, int auth) {
     if (is_rep()) {
-      for (map<int,int>::iterator p = replicas_begin();
+      for (map<int,unsigned>::iterator p = replicas_begin();
           p != replicas_end(); 
           ++p)
        ls.insert(p->first);
index 1c2a9339c1cdd8f17a0060ff561a293cc9523326..3762e9da897af41d4053949834c76ba17969b7e8 100644 (file)
@@ -175,7 +175,7 @@ public:
   static const uint64_t WAIT_ANY_MASK  = (uint64_t)(-1);
 
   // misc
-  static const int EXPORT_NONCE = 1; // nonce given to replicas created by export
+  static const unsigned EXPORT_NONCE = 1; // nonce given to replicas created by export
 
   ostream& print_db_line_prefix(ostream& out);
 
index 63e0e084033ffe463242bfbdb9dc0d5967f3b0ac..cded965bcb513ec4f206d898d7e0a3d3fcf6358a 100644 (file)
@@ -105,7 +105,7 @@ void Locker::dispatch(Message *m)
 
 void Locker::send_lock_message(SimpleLock *lock, int msg)
 {
-  for (map<int,int>::iterator it = lock->get_parent()->replicas_begin(); 
+  for (map<int,unsigned>::iterator it = lock->get_parent()->replicas_begin();
        it != lock->get_parent()->replicas_end(); 
        ++it) {
     if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN) 
@@ -117,7 +117,7 @@ void Locker::send_lock_message(SimpleLock *lock, int msg)
 
 void Locker::send_lock_message(SimpleLock *lock, int msg, const bufferlist &data)
 {
-  for (map<int,int>::iterator it = lock->get_parent()->replicas_begin(); 
+  for (map<int,unsigned>::iterator it = lock->get_parent()->replicas_begin();
        it != lock->get_parent()->replicas_end(); 
        ++it) {
     if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN) 
index 04ed1d2a31b2c534f0547b9c794c75393ff45c2a..fd129fd531950867f93ad846ca4c3655243d73ba 100644 (file)
@@ -3949,7 +3949,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
       dout(10) << " already have " << p->frag << " -> " << fg << " " << *dir << dendl;
     } else {
       dirs_to_share.insert(dir);
-      int nonce = dir->add_replica(from);
+      unsigned nonce = dir->add_replica(from);
       dout(10) << " have " << p->frag << " -> " << fg << " " << *dir << dendl;
       if (ack)
        ack->add_strong_dirfrag(dir->dirfrag(), nonce, dir->dir_rep);
@@ -3988,7 +3988,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
       
       if (survivor && dn->is_replica(from)) 
        dentry_remove_replica(dn, from, gather_locks);
-      int dnonce = dn->add_replica(from);
+      unsigned dnonce = dn->add_replica(from);
       dout(10) << " have " << *dn << dendl;
       if (ack) 
        ack->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last,
@@ -4001,7 +4001,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
 
       if (survivor && in->is_replica(from)) 
        inode_remove_replica(in, from, gather_locks);
-      int inonce = in->add_replica(from);
+      unsigned inonce = in->add_replica(from);
       dout(10) << " have " << *in << dendl;
 
       // scatter the dirlock, just in case?
@@ -4024,7 +4024,7 @@ void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
     assert(in);   // hmm fixme wrt stray?
     if (survivor && in->is_replica(from)) 
       inode_remove_replica(in, from, gather_locks);
-    int inonce = in->add_replica(from);
+    unsigned inonce = in->add_replica(from);
     dout(10) << " have base " << *in << dendl;
     
     if (ack) {
@@ -5510,7 +5510,7 @@ void MDCache::rejoin_send_acks()
       dq.pop_front();
       
       // dir
-      for (map<int,int>::iterator r = dir->replicas_begin();
+      for (map<int,unsigned>::iterator r = dir->replicas_begin();
           r != dir->replicas_end();
           ++r) {
        ack[r->first]->add_strong_dirfrag(dir->dirfrag(), ++r->second, dir->dir_rep);
@@ -5529,7 +5529,7 @@ void MDCache::rejoin_send_acks()
          in = dnl->get_inode();
 
        // dentry
-       for (map<int,int>::iterator r = dn->replicas_begin();
+       for (map<int,unsigned>::iterator r = dn->replicas_begin();
             r != dn->replicas_end();
             ++r) {
          ack[r->first]->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last,
@@ -5546,7 +5546,7 @@ void MDCache::rejoin_send_acks()
        if (!in)
          continue;
 
-       for (map<int,int>::iterator r = in->replicas_begin();
+       for (map<int,unsigned>::iterator r = in->replicas_begin();
             r != in->replicas_end();
             ++r) {
          ack[r->first]->add_inode_base(in);
@@ -5561,14 +5561,14 @@ void MDCache::rejoin_send_acks()
 
   // base inodes too
   if (root && root->is_auth()) 
-    for (map<int,int>::iterator r = root->replicas_begin();
+    for (map<int,unsigned>::iterator r = root->replicas_begin();
         r != root->replicas_end();
         ++r) {
       ack[r->first]->add_inode_base(root);
       ack[r->first]->add_inode_locks(root, ++r->second);
     }
   if (myin)
-    for (map<int,int>::iterator r = myin->replicas_begin();
+    for (map<int,unsigned>::iterator r = myin->replicas_begin();
         r != myin->replicas_end();
         ++r) {
       ack[r->first]->add_inode_base(myin);
@@ -5580,7 +5580,7 @@ void MDCache::rejoin_send_acks()
        p != rejoin_potential_updated_scatterlocks.end();
        ++p) {
     CInode *in = *p;
-    for (map<int,int>::iterator r = in->replicas_begin();
+    for (map<int,unsigned>::iterator r = in->replicas_begin();
         r != in->replicas_end();
         ++r)
       ack[r->first]->add_inode_base(in);
@@ -6596,11 +6596,11 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
     }
 
     // INODES
-    for (map<vinodeno_t,int>::iterator it = p->second.inodes.begin();
+    for (map<vinodeno_t,uint32_t>::iterator it = p->second.inodes.begin();
         it != p->second.inodes.end();
         ++it) {
       CInode *in = get_inode(it->first);
-      int nonce = it->second;
+      unsigned nonce = it->second;
       
       if (!in) {
        dout(0) << " inode expire on " << it->first << " from " << from 
@@ -6626,11 +6626,11 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
     }
     
     // DIRS
-    for (map<dirfrag_t,int>::iterator it = p->second.dirs.begin();
+    for (map<dirfrag_t,uint32_t>::iterator it = p->second.dirs.begin();
         it != p->second.dirs.end();
         ++it) {
       CDir *dir = get_dirfrag(it->first);
-      int nonce = it->second;
+      unsigned nonce = it->second;
       
       if (!dir) {
        dout(0) << " dir expire on " << it->first << " from " << from 
@@ -6655,7 +6655,7 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
     }
     
     // DENTRIES
-    for (map<dirfrag_t, map<pair<string,snapid_t>,int> >::iterator pd = p->second.dentries.begin();
+    for (map<dirfrag_t, map<pair<string,snapid_t>,uint32_t> >::iterator pd = p->second.dentries.begin();
         pd != p->second.dentries.end();
         ++pd) {
       dout(10) << " dn expires in dir " << pd->first << dendl;
@@ -6670,10 +6670,10 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
        assert(dir->is_auth());
       }
       
-      for (map<pair<string,snapid_t>,int>::iterator p = pd->second.begin();
+      for (map<pair<string,snapid_t>,uint32_t>::iterator p = pd->second.begin();
           p != pd->second.end();
           ++p) {
-       int nonce = p->second;
+       unsigned nonce = p->second;
        CDentry *dn;
        
        if (dir) {
@@ -10418,7 +10418,7 @@ int MDCache::send_dir_updates(CDir *dir, bool bcast)
   if (bcast) {
     mds->get_mds_map()->get_active_mds_set(who);
   } else {
-    for (map<int,int>::iterator p = dir->replicas_begin();
+    for (map<int,unsigned>::iterator p = dir->replicas_begin();
         p != dir->replicas_end();
         ++p)
       who.insert(p->first);
@@ -10498,7 +10498,7 @@ void MDCache::send_dentry_link(CDentry *dn)
   dout(7) << "send_dentry_link " << *dn << dendl;
 
   CDir *subtree = get_subtree_root(dn->get_dir());
-  for (map<int,int>::iterator p = dn->replicas_begin(); 
+  for (map<int,unsigned>::iterator p = dn->replicas_begin();
        p != dn->replicas_end(); 
        ++p) {
     if (mds->mdsmap->get_state(p->first) < MDSMap::STATE_REJOIN ||
@@ -10584,7 +10584,7 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequest *mdr)
 {
   dout(10) << "send_dentry_unlink " << *dn << dendl;
   // share unlink news with replicas
-  for (map<int,int>::iterator it = dn->replicas_begin();
+  for (map<int,unsigned>::iterator it = dn->replicas_begin();
        it != dn->replicas_end();
        ++it) {
     // don't tell (rmdir) witnesses; they already know
@@ -11254,7 +11254,7 @@ void MDCache::_fragment_stored(MDRequest *mdr)
 
   // tell peers
   CDir *first = *info.resultfrags.begin();
-  for (map<int,int>::iterator p = first->replica_map.begin();
+  for (map<int,unsigned>::iterator p = first->replicas_begin();
        p != first->replica_map.end();
        ++p) {
     if (mds->mdsmap->get_state(p->first) <= MDSMap::STATE_REJOIN)
index f87f9605de37fc3d4dc103be7ed229eb8900ccb3..c57f0ca28ec8b37b6f8beda995189858d70c418d 100644 (file)
@@ -822,7 +822,7 @@ void Migrator::export_frozen(CDir *dir)
   MExportDirPrep *prep = new MExportDirPrep(dir->dirfrag(), it->second.tid);
 
   // include list of bystanders
-  for (map<int,int>::iterator p = dir->replicas_begin();
+  for (map<int,unsigned>::iterator p = dir->replicas_begin();
        p != dir->replicas_end();
        ++p) {
     if (p->first != it->second.peer) {
@@ -939,7 +939,7 @@ void Migrator::handle_export_prep_ack(MExportDirPrepAck *m)
   assert(it->second.warning_ack_waiting.empty());
   assert(it->second.notify_ack_waiting.empty());
 
-  for (map<int,int>::iterator p = dir->replicas_begin();
+  for (map<int,unsigned>::iterator p = dir->replicas_begin();
        p != dir->replicas_end();
        ++p) {
     if (p->first == it->second.peer) continue;
@@ -1277,7 +1277,7 @@ void Migrator::finish_export_dir(CDir *dir, list<Context*>& finished, utime_t no
   assert(dir->is_auth());
   dir->state_clear(CDir::STATE_AUTH);
   dir->remove_bloom();
-  dir->replica_nonce = CDir::NONCE_EXPORT;
+  dir->replica_nonce = CDir::EXPORT_NONCE;
 
   if (dir->is_dirty())
     dir->mark_clean();
index 7684e9a128e405714af35ba39317f791a6a66487..37c823593ecc9fbe5ac08c84c68c6a2ca0ba0871 100644 (file)
@@ -368,7 +368,7 @@ public:
   }
 
   void init_gather() {
-    for (map<int,int>::const_iterator p = parent->replicas_begin(); 
+    for (map<int,unsigned>::const_iterator p = parent->replicas_begin();
         p != parent->replicas_end(); 
         ++p)
       more()->gather_set.insert(p->first);
index bd53c85b48d2a5c6cfebd8461c8fd3adfc31e9fe..d68e147dcbca5f16a569bd345735e4e3f2a8a06e 100644 (file)
@@ -1294,26 +1294,26 @@ protected:
   // --------------------------------------------
   // replication (across mds cluster)
  protected:
-  __s16        replica_nonce; // [replica] defined on replica
-  map<int,int> replica_map;   // [auth] mds -> nonce
+  unsigned             replica_nonce; // [replica] defined on replica
+  map<int,unsigned>    replica_map;   // [auth] mds -> nonce
 
  public:
   bool is_replicated() { return !replica_map.empty(); }
   bool is_replica(int mds) { return replica_map.count(mds); }
   int num_replicas() { return replica_map.size(); }
-  int add_replica(int mds) {
+  unsigned add_replica(int mds) {
     if (replica_map.count(mds)) 
       return ++replica_map[mds];  // inc nonce
     if (replica_map.empty()) 
       get(PIN_REPLICATED);
     return replica_map[mds] = 1;
   }
-  void add_replica(int mds, int nonce) {
+  void add_replica(int mds, unsigned nonce) {
     if (replica_map.empty()) 
       get(PIN_REPLICATED);
     replica_map[mds] = nonce;
   }
-  int get_replica_nonce(int mds) {
+  unsigned get_replica_nonce(int mds) {
     assert(replica_map.count(mds));
     return replica_map[mds];
   }
@@ -1328,18 +1328,18 @@ protected:
       put(PIN_REPLICATED);
     replica_map.clear();
   }
-  map<int,int>::iterator replicas_begin() { return replica_map.begin(); }
-  map<int,int>::iterator replicas_end() { return replica_map.end(); }
-  const map<int,int>& get_replicas() { return replica_map; }
+  map<int,unsigned>::iterator replicas_begin() { return replica_map.begin(); }
+  map<int,unsigned>::iterator replicas_end() { return replica_map.end(); }
+  const map<int,unsigned>& get_replicas() { return replica_map; }
   void list_replicas(set<int>& ls) {
-    for (map<int,int>::const_iterator p = replica_map.begin();
+    for (map<int,unsigned>::const_iterator p = replica_map.begin();
         p != replica_map.end();
         ++p) 
       ls.insert(p->first);
   }
 
-  int get_replica_nonce() { return replica_nonce;}
-  void set_replica_nonce(int n) { replica_nonce = n; }
+  unsigned get_replica_nonce() { return replica_nonce; }
+  void set_replica_nonce(unsigned n) { replica_nonce = n; }
 
 
   // ---------------------------------------------
index aa40407d063cea950fc9d0bdfbf9e1fbbcefc979..df71404a29ba7d7c387274e579eb53a33e055c5c 100644 (file)
@@ -26,9 +26,9 @@ public:
     that makes it less work to process when exports are in progress.
   */
   struct realm {
-    map<vinodeno_t, __s32> inodes;
-    map<dirfrag_t, __s32> dirs;
-    map<dirfrag_t, map<pair<string,snapid_t>,__s32> > dentries;
+    map<vinodeno_t, uint32_t> inodes;
+    map<dirfrag_t, uint32_t> dirs;
+    map<dirfrag_t, map<pair<string,snapid_t>,uint32_t> > dentries;
 
     void encode(bufferlist &bl) const {
       ::encode(inodes, bl);
@@ -57,13 +57,13 @@ private:
 public:
   virtual const char *get_type_name() const { return "cache_expire";}
   
-  void add_inode(dirfrag_t r, vinodeno_t vino, int nonce) {
+  void add_inode(dirfrag_t r, vinodeno_t vino, unsigned nonce) {
     realms[r].inodes[vino] = nonce;
   }
-  void add_dir(dirfrag_t r, dirfrag_t df, int nonce) {
+  void add_dir(dirfrag_t r, dirfrag_t df, unsigned nonce) {
     realms[r].dirs[df] = nonce;
   }
-  void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, int nonce) {
+  void add_dentry(dirfrag_t r, dirfrag_t df, const string& dn, snapid_t last, unsigned nonce) {
     realms[r].dentries[df][pair<string,snapid_t>(dn,last)] = nonce;
   }
 
index 3ae83553dad528f13b02f5b214f3df17cee05888..4f079a91126e800e47c9b6569feb9eef16286c4d 100644 (file)
@@ -48,7 +48,7 @@ class MMDSCacheRejoin : public Message {
 
   // -- types --
   struct inode_strong { 
-    int32_t nonce;
+    uint32_t nonce;
     int32_t caps_wanted;
     int32_t filelock, nestlock, dftlock;
     inode_strong() {}
@@ -73,7 +73,7 @@ class MMDSCacheRejoin : public Message {
   WRITE_CLASS_ENCODER(inode_strong)
 
   struct dirfrag_strong {
-    int32_t nonce;
+    uint32_t nonce;
     int8_t  dir_rep;
     dirfrag_strong() {}
     dirfrag_strong(int n, int dr) : nonce(n), dir_rep(dr) {}
@@ -93,7 +93,7 @@ class MMDSCacheRejoin : public Message {
     inodeno_t ino;
     inodeno_t remote_ino;
     unsigned char remote_d_type;
-    int32_t nonce;
+    uint32_t nonce;
     int32_t lock;
     dn_strong() : 
       ino(0), remote_ino(0), remote_d_type(0), nonce(0), lock(0) {}