From 5a902a0e5d3beb919cf27f21aef52a4d0fa9f0f4 Mon Sep 17 00:00:00 2001 From: "Yan, Zheng" Date: Wed, 6 Nov 2013 09:28:51 +0800 Subject: [PATCH] mds: unify nonce type 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 --- src/mds/CDentry.h | 2 +- src/mds/CDir.cc | 4 ++-- src/mds/CDir.h | 4 ++-- src/mds/CInode.h | 2 +- src/mds/Locker.cc | 4 ++-- src/mds/MDCache.cc | 42 +++++++++++++++++----------------- src/mds/Migrator.cc | 6 ++--- src/mds/SimpleLock.h | 2 +- src/mds/mdstypes.h | 22 +++++++++--------- src/messages/MCacheExpire.h | 12 +++++----- src/messages/MMDSCacheRejoin.h | 6 ++--- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index e40854adfaa95..39a4c55380bdb 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -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(r); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 596d717f6b6c0..a02e7e7e5645f 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -964,10 +964,10 @@ void CDir::merge(list& subs, list& waiters, bool replay) steal_dentry(dir->items.begin()->second); // merge replica map - for (map::iterator p = dir->replica_map.begin(); + for (map::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; } diff --git a/src/mds/CDir.h b/src/mds/CDir.h index f131d834ca0f0..0aa13d70b5099 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -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& ls, int auth) { if (is_rep()) { - for (map::iterator p = replicas_begin(); + for (map::iterator p = replicas_begin(); p != replicas_end(); ++p) ls.insert(p->first); diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 1c2a9339c1cdd..3762e9da897af 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -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); diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 63e0e084033ff..cded965bcb513 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -105,7 +105,7 @@ void Locker::dispatch(Message *m) void Locker::send_lock_message(SimpleLock *lock, int msg) { - for (map::iterator it = lock->get_parent()->replicas_begin(); + for (map::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::iterator it = lock->get_parent()->replicas_begin(); + for (map::iterator it = lock->get_parent()->replicas_begin(); it != lock->get_parent()->replicas_end(); ++it) { if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN) diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 04ed1d2a31b2c..fd129fd531950 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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::iterator r = dir->replicas_begin(); + for (map::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::iterator r = dn->replicas_begin(); + for (map::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::iterator r = in->replicas_begin(); + for (map::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::iterator r = root->replicas_begin(); + for (map::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::iterator r = myin->replicas_begin(); + for (map::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::iterator r = in->replicas_begin(); + for (map::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::iterator it = p->second.inodes.begin(); + for (map::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::iterator it = p->second.dirs.begin(); + for (map::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,int> >::iterator pd = p->second.dentries.begin(); + for (map,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,int>::iterator p = pd->second.begin(); + for (map,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::iterator p = dir->replicas_begin(); + for (map::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::iterator p = dn->replicas_begin(); + for (map::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::iterator it = dn->replicas_begin(); + for (map::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::iterator p = first->replica_map.begin(); + for (map::iterator p = first->replicas_begin(); p != first->replica_map.end(); ++p) { if (mds->mdsmap->get_state(p->first) <= MDSMap::STATE_REJOIN) diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index f87f9605de37f..c57f0ca28ec8b 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -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::iterator p = dir->replicas_begin(); + for (map::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::iterator p = dir->replicas_begin(); + for (map::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& 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(); diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index 7684e9a128e40..37c823593ecc9 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -368,7 +368,7 @@ public: } void init_gather() { - for (map::const_iterator p = parent->replicas_begin(); + for (map::const_iterator p = parent->replicas_begin(); p != parent->replicas_end(); ++p) more()->gather_set.insert(p->first); diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index bd53c85b48d2a..d68e147dcbca5 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -1294,26 +1294,26 @@ protected: // -------------------------------------------- // replication (across mds cluster) protected: - __s16 replica_nonce; // [replica] defined on replica - map replica_map; // [auth] mds -> nonce + unsigned replica_nonce; // [replica] defined on replica + map 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::iterator replicas_begin() { return replica_map.begin(); } - map::iterator replicas_end() { return replica_map.end(); } - const map& get_replicas() { return replica_map; } + map::iterator replicas_begin() { return replica_map.begin(); } + map::iterator replicas_end() { return replica_map.end(); } + const map& get_replicas() { return replica_map; } void list_replicas(set& ls) { - for (map::const_iterator p = replica_map.begin(); + for (map::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; } // --------------------------------------------- diff --git a/src/messages/MCacheExpire.h b/src/messages/MCacheExpire.h index aa40407d063ce..df71404a29ba7 100644 --- a/src/messages/MCacheExpire.h +++ b/src/messages/MCacheExpire.h @@ -26,9 +26,9 @@ public: that makes it less work to process when exports are in progress. */ struct realm { - map inodes; - map dirs; - map,__s32> > dentries; + map inodes; + map dirs; + map,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(dn,last)] = nonce; } diff --git a/src/messages/MMDSCacheRejoin.h b/src/messages/MMDSCacheRejoin.h index 3ae83553dad52..4f079a91126e8 100644 --- a/src/messages/MMDSCacheRejoin.h +++ b/src/messages/MMDSCacheRejoin.h @@ -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) {} -- 2.39.5