]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: typedefs for rank and gid in MDSMap
authorJohn Spray <john.spray@redhat.com>
Thu, 18 Sep 2014 18:31:43 +0000 (19:31 +0100)
committerJohn Spray <john.spray@redhat.com>
Wed, 8 Oct 2014 10:58:18 +0000 (11:58 +0100)
Make it clearer what these numbers are where they appear.

Signed-off-by: John Spray <john.spray@redhat.com>
55 files changed:
src/client/Client.cc
src/client/Client.h
src/client/Dentry.h
src/client/Inode.cc
src/client/Inode.h
src/client/MetaRequest.h
src/client/MetaSession.h
src/mds/Beacon.cc
src/mds/Beacon.h
src/mds/CDentry.cc
src/mds/CDentry.h
src/mds/CDir.cc
src/mds/CDir.h
src/mds/CInode.cc
src/mds/CInode.h
src/mds/Locker.cc
src/mds/Locker.h
src/mds/MDBalancer.cc
src/mds/MDBalancer.h
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc
src/mds/MDS.h
src/mds/MDSMap.cc
src/mds/MDSMap.h
src/mds/MDSTable.cc
src/mds/MDSTableClient.cc
src/mds/MDSTableClient.h
src/mds/MDSTableServer.cc
src/mds/MDSTableServer.h
src/mds/Migrator.cc
src/mds/Migrator.h
src/mds/Mutation.h
src/mds/Server.cc
src/mds/Server.h
src/mds/SessionMap.cc
src/mds/SimpleLock.h
src/mds/SnapServer.cc
src/mds/SnapServer.h
src/mds/events/ESlaveUpdate.h
src/mds/events/ETableServer.h
src/mds/journal.cc
src/mds/mdstypes.cc
src/mds/mdstypes.h
src/messages/MDirUpdate.h
src/messages/MDiscoverReply.h
src/messages/MExportDirDiscover.h
src/messages/MExportDirPrep.h
src/messages/MHeartbeat.h
src/messages/MMDSBeacon.h
src/messages/MMDSLoadTargets.h
src/messages/MMDSOpenInoReply.h
src/messages/MMDSSlaveRequest.h
src/mon/MDSMonitor.cc
src/mon/MDSMonitor.h

index 94f6652307ea9bace966e871e8d9e0d47cbd6b47..b0092d8816eaf78202656baef1bbd86116d711ff 100644 (file)
@@ -508,7 +508,7 @@ void Client::trim_cache()
 
 void Client::trim_cache_for_reconnect(MetaSession *s)
 {
-  int mds = s->mds_num;
+  mds_rank_t mds = s->mds_num;
   ldout(cct, 20) << "trim_cache_for_reconnect mds." << mds << dendl;
 
   int trimmed = 0;
@@ -1127,9 +1127,9 @@ Inode* Client::insert_trace(MetaRequest *request, MetaSession *session)
 
 // -------
 
-int Client::choose_target_mds(MetaRequest *req) 
+mds_rank_t Client::choose_target_mds(MetaRequest *req) 
 {
-  int mds = -1;
+  mds_rank_t mds = MDS_RANK_NONE;
   __u32 hash = 0;
   bool is_hash = false;
 
@@ -1226,12 +1226,12 @@ out:
 }
 
 
-void Client::connect_mds_targets(int mds)
+void Client::connect_mds_targets(mds_rank_t mds)
 {
   ldout(cct, 10) << "connect_mds_targets for mds." << mds << dendl;
   assert(mds_sessions.count(mds));
   const MDSMap::mds_info_t& info = mdsmap->get_mds_info(mds);
-  for (set<int>::const_iterator q = info.export_targets.begin();
+  for (set<mds_rank_t>::const_iterator q = info.export_targets.begin();
        q != info.export_targets.end();
        ++q) {
     if (mds_sessions.count(*q) == 0 &&
@@ -1247,7 +1247,7 @@ void Client::dump_mds_sessions(Formatter *f)
 {
   f->dump_int("id", get_nodeid().v);
   f->open_array_section("sessions");
-  for (map<int,MetaSession*>::const_iterator p = mds_sessions.begin(); p != mds_sessions.end(); ++p) {
+  for (map<mds_rank_t,MetaSession*>::const_iterator p = mds_sessions.begin(); p != mds_sessions.end(); ++p) {
     f->open_object_section("session");
     p->second->dump(f);
     f->close_section();
@@ -1399,8 +1399,8 @@ int Client::make_request(MetaRequest *request,
     request->caller_cond = &caller_cond;
 
     // choose mds
-    int mds = choose_target_mds(request);
-    if (mds < 0 || !mdsmap->is_active_or_stopping(mds)) {
+    mds_rank_t mds = choose_target_mds(request);
+    if (mds < MDS_RANK_NONE || !mdsmap->is_active_or_stopping(mds)) {
       ldout(cct, 10) << " target mds." << mds << " not active, waiting for new mdsmap" << dendl;
       wait_on_list(waiting_for_mdsmap);
       continue;
@@ -1496,7 +1496,7 @@ void Client::put_request(MetaRequest *request)
 }
 
 int Client::encode_inode_release(Inode *in, MetaRequest *req,
-                        int mds, int drop,
+                        mds_rank_t mds, int drop,
                         int unless, int force)
 {
   ldout(cct, 20) << "encode_inode_release enter(in:" << *in << ", req:" << req
@@ -1535,7 +1535,7 @@ int Client::encode_inode_release(Inode *in, MetaRequest *req,
 }
 
 void Client::encode_dentry_release(Dentry *dn, MetaRequest *req,
-                          int mds, int drop, int unless)
+                          mds_rank_t mds, int drop, int unless)
 {
   ldout(cct, 20) << "encode_dentry_release enter(dn:"
           << dn << ")" << dendl;
@@ -1561,7 +1561,7 @@ void Client::encode_dentry_release(Dentry *dn, MetaRequest *req,
  * Additionally, if you set any *drop member, you'd better have
  * set the corresponding dentry!
  */
-void Client::encode_cap_releases(MetaRequest *req, int mds)
+void Client::encode_cap_releases(MetaRequest *req, mds_rank_t mds)
 {
   ldout(cct, 20) << "encode_cap_releases enter (req: "
                 << req << ", mds: " << mds << ")" << dendl;
@@ -1592,7 +1592,7 @@ void Client::encode_cap_releases(MetaRequest *req, int mds)
           << req << ", mds " << mds <<dendl;
 }
 
-bool Client::have_open_session(int mds)
+bool Client::have_open_session(mds_rank_t mds)
 {
   return
     mds_sessions.count(mds) &&
@@ -1600,7 +1600,7 @@ bool Client::have_open_session(int mds)
      mds_sessions[mds]->state == MetaSession::STATE_STALE);
 }
 
-MetaSession *Client::_get_mds_session(int mds, Connection *con)
+MetaSession *Client::_get_mds_session(mds_rank_t mds, Connection *con)
 {
   if (mds_sessions.count(mds) == 0)
     return NULL;
@@ -1610,7 +1610,7 @@ MetaSession *Client::_get_mds_session(int mds, Connection *con)
   return s;
 }
 
-MetaSession *Client::_get_or_open_mds_session(int mds)
+MetaSession *Client::_get_or_open_mds_session(mds_rank_t mds)
 {
   if (mds_sessions.count(mds))
     return mds_sessions[mds];
@@ -1653,7 +1653,7 @@ void Client::update_metadata(std::string const &k, std::string const &v)
   metadata[k] = v;
 }
 
-MetaSession *Client::_open_mds_session(int mds)
+MetaSession *Client::_open_mds_session(mds_rank_t mds)
 {
   ldout(cct, 10) << "_open_mds_session mds." << mds << dendl;
   assert(mds_sessions.count(mds) == 0);
@@ -1691,7 +1691,7 @@ void Client::_closed_mds_session(MetaSession *s)
 
 void Client::handle_client_session(MClientSession *m) 
 {
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
   ldout(cct, 10) << "handle_client_session " << *m << " from mds." << from << dendl;
 
   MetaSession *session = _get_mds_session(from, m->get_connection().get());
@@ -1747,7 +1747,7 @@ void Client::_kick_stale_sessions()
 {
   ldout(cct, 1) << "kick_stale_sessions" << dendl;
 
-  for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end(); ) {
     MetaSession *s = p->second;
     ++p;
@@ -1759,7 +1759,7 @@ void Client::_kick_stale_sessions()
 void Client::send_request(MetaRequest *request, MetaSession *session)
 {
   // make the request
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   ldout(cct, 10) << "send_request rebuilding request " << request->get_tid()
                 << " for mds." << mds << dendl;
   MClientRequest *r = build_client_request(request);
@@ -1829,7 +1829,7 @@ MClientRequest* Client::build_client_request(MetaRequest *request)
 
 void Client::handle_client_request_forward(MClientRequestForward *fwd)
 {
-  int mds = fwd->get_source().num();
+  mds_rank_t mds = mds_rank_t(fwd->get_source().num());
   MetaSession *session = _get_mds_session(mds, fwd->get_connection().get());
   if (!session) {
     fwd->put();
@@ -1867,7 +1867,7 @@ void Client::handle_client_request_forward(MClientRequestForward *fwd)
 
 void Client::handle_client_reply(MClientReply *reply)
 {
-  int mds_num = reply->get_source().num();
+  mds_rank_t mds_num = mds_rank_t(reply->get_source().num());
   MetaSession *session = _get_mds_session(mds_num, reply->get_connection().get());
   if (!session) {
     reply->put();
@@ -2046,7 +2046,7 @@ void Client::handle_mds_map(MMDSMap* m)
   mdsmap->decode(m->get_encoded());
 
   // reset session
-  for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end();
        ++p) {
     int oldstate = oldmap->get_state(p->first);
@@ -2095,7 +2095,7 @@ void Client::handle_mds_map(MMDSMap* m)
 
 void Client::send_reconnect(MetaSession *session)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   ldout(cct, 10) << "send_reconnect to mds." << mds << dendl;
 
   // trim unused caps to reduce MDS's cache rejoin time
@@ -2222,7 +2222,7 @@ void Client::handle_lease(MClientLease *m)
 
   assert(m->get_action() == CEPH_MDS_LEASE_REVOKE);
 
-  int mds = m->get_source().num();
+  mds_rank_t mds = mds_rank_t(m->get_source().num());
   MetaSession *session = _get_mds_session(mds, m->get_connection().get());
   if (!session) {
     m->put();
@@ -2639,9 +2639,9 @@ void Client::check_caps(Inode *in, bool is_delayed)
 
   utime_t now = ceph_clock_now(cct);
 
-  map<int,Cap*>::iterator it = in->caps.begin();
+  map<mds_rank_t, Cap*>::iterator it = in->caps.begin();
   while (it != in->caps.end()) {
-    int mds = it->first;
+    mds_rank_t mds = it->first;
     Cap *cap = it->second;
     ++it;
 
@@ -3056,7 +3056,7 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id
                            int flags)
 {
   Cap *cap = 0;
-  int mds = mds_session->mds_num;
+  mds_rank_t mds = mds_session->mds_num;
   if (in->caps.count(mds)) {
     cap = in->caps[mds];
 
@@ -3121,7 +3121,7 @@ void Client::add_update_cap(Inode *in, MetaSession *mds_session, uint64_t cap_id
 
   if ((issued & ~old_caps) && in->auth_cap == cap) {
     // non-auth MDS is revoking the newly grant caps ?
-    for (map<int,Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
+    for (map<mds_rank_t,Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
       if (it->second == cap)
        continue;
       if (it->second->implemented & ~it->second->issued & issued) {
@@ -3139,7 +3139,7 @@ void Client::remove_cap(Cap *cap, bool queue_release)
 {
   Inode *in = cap->inode;
   MetaSession *session = cap->session;
-  int mds = cap->session->mds_num;
+  mds_rank_t mds = cap->session->mds_num;
 
   ldout(cct, 10) << "remove_cap mds." << mds << " on " << *in << dendl;
   
@@ -3228,7 +3228,7 @@ void Client::_invalidate_kernel_dcache()
 
 void Client::trim_caps(MetaSession *s, int max)
 {
-  int mds = s->mds_num;
+  mds_rank_t mds = s->mds_num;
   ldout(cct, 10) << "trim_caps mds." << mds << " max " << max << dendl;
 
   int trimmed = 0;
@@ -3356,7 +3356,7 @@ void Client::wait_sync_caps(uint64_t want)
  retry:
   ldout(cct, 10) << "wait_sync_caps want " << want << " (last is " << last_flush_seq << ", "
           << num_flushing_caps << " total flushing)" << dendl;
-  for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end();
        ++p) {
     if (p->second->flushing_caps.empty())
@@ -3373,7 +3373,7 @@ void Client::wait_sync_caps(uint64_t want)
 
 void Client::kick_flushing_caps(MetaSession *session)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   ldout(cct, 10) << "kick_flushing_caps mds." << mds << dendl;
 
   for (xlist<CapSnap*>::iterator p = session->flushing_capsnaps.begin(); !p.end(); ++p) {
@@ -3575,7 +3575,7 @@ inodeno_t Client::update_snap_trace(bufferlist& bl, bool flush)
 void Client::handle_snap(MClientSnap *m)
 {
   ldout(cct, 10) << "handle_snap " << *m << dendl;
-  int mds = m->get_source().num();
+  mds_rank_t mds = mds_rank_t(m->get_source().num());
   MetaSession *session = _get_mds_session(mds, m->get_connection().get());
   if (!session) {
     m->put();
@@ -3651,7 +3651,7 @@ void Client::handle_snap(MClientSnap *m)
 
 void Client::handle_caps(MClientCaps *m)
 {
-  int mds = m->get_source().num();
+  mds_rank_t mds = mds_rank_t(m->get_source().num());
   MetaSession *session = _get_mds_session(mds, m->get_connection().get());
   if (!session) {
     m->put();
@@ -3716,7 +3716,7 @@ void Client::handle_caps(MClientCaps *m)
 
 void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
 
   ldout(cct, 5) << "handle_cap_import ino " << m->get_ino() << " mseq " << m->get_mseq()
                << " IMPORT from mds." << mds << dendl;
@@ -3727,8 +3727,10 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
                 m->get_caps(), m->get_seq(), m->get_mseq(), m->get_realm(),
                 CEPH_CAP_FLAG_AUTH);
 
-  if (m->peer.cap_id && in->caps.count(m->peer.mds)) {
-    Cap *cap = in->caps[m->peer.mds];
+  const mds_rank_t peer_mds = mds_rank_t(m->peer.mds);
+
+  if (m->peer.cap_id && in->caps.count(peer_mds)) {
+    Cap *cap = in->caps[peer_mds];
     if (cap && cap->cap_id == m->peer.cap_id)
       remove_cap(cap, (m->peer.flags & CEPH_CAP_FLAG_RELEASE));
   }
@@ -3744,7 +3746,7 @@ void Client::handle_cap_import(MetaSession *session, Inode *in, MClientCaps *m)
 
 void Client::handle_cap_export(MetaSession *session, Inode *in, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
 
   ldout(cct, 5) << "handle_cap_export ino " << m->get_ino() << " mseq " << m->get_mseq()
                << " EXPORT from mds." << mds << dendl;
@@ -3753,11 +3755,13 @@ void Client::handle_cap_export(MetaSession *session, Inode *in, MClientCaps *m)
   if (in->caps.count(mds))
     cap = in->caps[mds];
 
+  const mds_rank_t peer_mds = mds_rank_t(m->peer.mds);
+
   if (cap && cap->cap_id == m->get_cap_id()) {
     if (m->peer.cap_id) {
-      MetaSession *tsession = _get_or_open_mds_session(m->peer.mds);
-      if (in->caps.count(m->peer.mds)) {
-       Cap *tcap = in->caps[m->peer.mds];
+      MetaSession *tsession = _get_or_open_mds_session(peer_mds);
+      if (in->caps.count(peer_mds)) {
+       Cap *tcap = in->caps[peer_mds];
        if (tcap->cap_id != m->peer.cap_id ||
            ceph_seq_cmp(tcap->seq, m->peer.seq) < 0) {
          tcap->cap_id = m->peer.cap_id;
@@ -3786,7 +3790,7 @@ void Client::handle_cap_export(MetaSession *session, Inode *in, MClientCaps *m)
 
 void Client::handle_cap_trunc(MetaSession *session, Inode *in, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   assert(in->caps[mds]);
 
   ldout(cct, 10) << "handle_cap_trunc on ino " << *in
@@ -3806,7 +3810,7 @@ void Client::handle_cap_trunc(MetaSession *session, Inode *in, MClientCaps *m)
 
 void Client::handle_cap_flush_ack(MetaSession *session, Inode *in, Cap *cap, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   int dirty = m->get_dirty();
   int cleaned = 0;
   for (int i = 0; i < CEPH_CAP_BITS; ++i) {
@@ -3844,7 +3848,7 @@ void Client::handle_cap_flush_ack(MetaSession *session, Inode *in, Cap *cap, MCl
 
 void Client::handle_cap_flushsnap_ack(MetaSession *session, Inode *in, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   assert(in->caps[mds]);
   snapid_t follows = m->get_snap_follows();
 
@@ -3918,7 +3922,7 @@ void Client::_invalidate_inode_parents(Inode *in)
 
 void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClientCaps *m)
 {
-  int mds = session->mds_num;
+  mds_rank_t mds = session->mds_num;
   int used = get_caps_used(in);
   int wanted = in->caps_wanted();
 
@@ -4003,7 +4007,7 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient
 
     if (cap == in->auth_cap) {
       // non-auth MDS is revoking the newly grant caps ?
-      for (map<int,Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
+      for (map<mds_rank_t, Cap*>::iterator it = in->caps.begin(); it != in->caps.end(); ++it) {
        if (it->second == cap)
          continue;
        if (it->second->implemented & ~it->second->issued & new_caps) {
@@ -4058,7 +4062,6 @@ inodeno_t Client::_get_inodeno(Inode *in)
   return in->ino;
 }
 
-
 // -------------------
 // MOUNT
 
@@ -4217,7 +4220,7 @@ void Client::unmount()
   
   while (!mds_sessions.empty()) {
     // send session closes!
-    for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+    for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end();
        ++p) {
       if (p->second->state != MetaSession::STATE_CLOSING) {
@@ -4251,7 +4254,7 @@ public:
 void Client::flush_cap_releases()
 {
   // send any cap releases
-  for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end();
        ++p) {
     if (p->second->release && mdsmap->is_clientreplay_or_active_or_stopping(p->first)) {
@@ -4308,7 +4311,7 @@ void Client::renew_caps()
   ldout(cct, 10) << "renew_caps()" << dendl;
   last_cap_renew = ceph_clock_now(cct);
   
-  for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+  for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
        p != mds_sessions.end();
        ++p) {
     ldout(cct, 15) << "renew_caps requesting from mds." << p->first << dendl;
@@ -6871,7 +6874,7 @@ int Client::_fsync(Fh *f, bool syncdataonly)
   }
   
   if (!syncdataonly && (in->dirty_caps & ~CEPH_CAP_ANY_FILE_WR)) {
-    for (map<int, Cap*>::iterator iter = in->caps.begin(); iter != in->caps.end(); ++iter) {
+    for (map<mds_rank_t, Cap*>::iterator iter = in->caps.begin(); iter != in->caps.end(); ++iter) {
       if (iter->second->implemented & ~CEPH_CAP_ANY_FILE_WR) {
        MetaSession *session = mds_sessions[iter->first];
        assert(session);
@@ -9314,9 +9317,9 @@ void Client::ms_handle_remote_reset(Connection *con)
   case CEPH_ENTITY_TYPE_MDS:
     {
       // kludge to figure out which mds this is; fixme with a Connection* state
-      int mds = -1;
+      mds_rank_t mds = MDS_RANK_NONE;
       MetaSession *s = NULL;
-      for (map<int,MetaSession*>::iterator p = mds_sessions.begin();
+      for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
           p != mds_sessions.end();
           ++p) {
        if (mdsmap->get_addr(p->first) == con->get_peer_addr()) {
index 1f7c53631d7dfd3389819a8fc3381867a648fa83..1e0bcc7f2de8ab170ab1a71d09840e0959462a97 100644 (file)
@@ -239,15 +239,15 @@ public:
   client_t whoami;
 
   // mds sessions
-  map<int, MetaSession*> mds_sessions;  // mds -> push seq
+  map<mds_rank_t, MetaSession*> mds_sessions;  // mds -> push seq
   list<Cond*> waiting_for_mdsmap;
 
   void get_session_metadata(std::map<std::string, std::string> *meta) const;
-  bool have_open_session(int mds);
+  bool have_open_session(mds_rank_t mds);
   void got_mds_push(MetaSession *s);
-  MetaSession *_get_mds_session(int mds, Connection *con);  ///< return session for mds *and* con; null otherwise
-  MetaSession *_get_or_open_mds_session(int mds);
-  MetaSession *_open_mds_session(int mds);
+  MetaSession *_get_mds_session(mds_rank_t mds, Connection *con);  ///< return session for mds *and* con; null otherwise
+  MetaSession *_get_or_open_mds_session(mds_rank_t mds);
+  MetaSession *_open_mds_session(mds_rank_t mds);
   void _close_mds_session(MetaSession *s);
   void _closed_mds_session(MetaSession *s);
   void _kick_stale_sessions();
@@ -258,7 +258,6 @@ public:
   // mds requests
   ceph_tid_t last_tid, last_flush_seq;
   map<ceph_tid_t, MetaRequest*> mds_requests;
-  set<int>                 failed_mds;
 
   void dump_mds_requests(Formatter *f);
   void dump_mds_sessions(Formatter *f);
@@ -271,14 +270,14 @@ public:
 
   int verify_reply_trace(int r, MetaRequest *request, MClientReply *reply,
                         Inode **ptarget, bool *pcreated, int uid, int gid);
-  void encode_cap_releases(MetaRequest *request, int mds);
+  void encode_cap_releases(MetaRequest *request, mds_rank_t mds);
   int encode_inode_release(Inode *in, MetaRequest *req,
-                          int mds, int drop,
+                          mds_rank_t mds, int drop,
                           int unless,int force=0);
   void encode_dentry_release(Dentry *dn, MetaRequest *req,
-                            int mds, int drop, int unless);
-  int choose_target_mds(MetaRequest *req);
-  void connect_mds_targets(int mds);
+                            mds_rank_t mds, int drop, int unless);
+  mds_rank_t choose_target_mds(MetaRequest *req);
+  void connect_mds_targets(mds_rank_t mds);
   void send_request(MetaRequest *request, MetaSession *session);
   MClientRequest *build_client_request(MetaRequest *request);
   void kick_requests(MetaSession *session);
index 8dc48803b6e64a38187d8830e43ecf8e6bf0def4..aad6343f8179fc9e62bd3cee8babcd3f8cc4c9c2 100644 (file)
@@ -4,6 +4,8 @@
 #include "include/lru.h"
 #include "include/xlist.h"
 
+#include "mds/mdstypes.h"
+
 class Dir;
 struct Inode;
 
@@ -15,7 +17,7 @@ class Dentry : public LRUObject {
   Inode   *inode;
   int     ref;                       // 1 if there's a dir beneath me.
   uint64_t offset;
-  int lease_mds;
+  mds_rank_t lease_mds;
   utime_t lease_ttl;
   uint64_t lease_gen;
   ceph_seq_t lease_seq;
index 3f3de6a41dc213701780dfde9117f85f8a6b106f..7ed61d71e25deb9bb4ec571f711af5d98a047bcf 100644 (file)
@@ -20,7 +20,7 @@ ostream& operator<<(ostream &out, Inode &in)
       << " caps=" << ccap_string(in.caps_issued());
   if (!in.caps.empty()) {
     out << "(";
-    for (map<int,Cap*>::iterator p = in.caps.begin(); p != in.caps.end(); ++p) {
+    for (map<mds_rank_t,Cap*>::iterator p = in.caps.begin(); p != in.caps.end(); ++p) {
       if (p != in.caps.begin())
         out << ',';
       out << p->first << '=' << ccap_string(p->second->issued);
@@ -158,7 +158,7 @@ int Inode::caps_issued(int *implemented)
 {
   int c = snap_caps;
   int i = 0;
-  for (map<int,Cap*>::iterator it = caps.begin();
+  for (map<mds_rank_t,Cap*>::iterator it = caps.begin();
        it != caps.end();
        ++it)
     if (cap_is_valid(it->second)) {
@@ -176,7 +176,7 @@ void Inode::touch_cap(Cap *cap)
   cap->session->caps.push_back(&cap->cap_item);
 }
 
-void Inode::try_touch_cap(int mds)
+void Inode::try_touch_cap(mds_rank_t mds)
 {
   if (caps.count(mds))
     touch_cap(caps[mds]);
@@ -195,7 +195,7 @@ bool Inode::caps_issued_mask(unsigned mask)
     return true;
   }
   // try any cap
-  for (map<int,Cap*>::iterator it = caps.begin();
+  for (map<mds_rank_t,Cap*>::iterator it = caps.begin();
        it != caps.end();
        ++it) {
     if (cap_is_valid(it->second)) {
@@ -208,7 +208,7 @@ bool Inode::caps_issued_mask(unsigned mask)
   }
   if ((c & mask) == mask) {
     // bah.. touch them all
-    for (map<int,Cap*>::iterator it = caps.begin();
+    for (map<mds_rank_t,Cap*>::iterator it = caps.begin();
         it != caps.end();
         ++it)
       touch_cap(it->second);
@@ -360,7 +360,7 @@ void Inode::dump(Formatter *f) const
   }
 
   f->open_array_section("caps");
-  for (map<int,Cap*>::const_iterator p = caps.begin(); p != caps.end(); ++p) {
+  for (map<mds_rank_t,Cap*>::const_iterator p = caps.begin(); p != caps.end(); ++p) {
     f->open_object_section("cap");
     f->dump_int("mds", p->first);
     if (p->second == auth_cap)
index 0e6cec07880866d4251af5dbe00beb8c281a9672..2edeba8c4e6ac585496f4be4f8f9aa18cb894438 100644 (file)
@@ -140,7 +140,7 @@ struct Inode {
   bool      dir_hashed, dir_replicated;
 
   // per-mds caps
-  map<int,Cap*> caps;            // mds -> Cap
+  map<mds_rank_t, Cap*> caps;            // mds -> Cap
   Cap *auth_cap;
   unsigned dirty_caps, flushing_caps;
   uint64_t flushing_cap_seq;
@@ -256,7 +256,7 @@ struct Inode {
   bool cap_is_valid(Cap* cap);
   int caps_issued(int *implemented = 0);
   void touch_cap(Cap *cap);
-  void try_touch_cap(int mds);
+  void try_touch_cap(mds_rank_t mds);
   bool caps_issued_mask(unsigned mask);
   int caps_used();
   int caps_file_wanted();
index fb7f5b1aa809d109fe57675e638066adb3667e42..b73b67bf7dcdd81400eb946052b1dd258432b888 100644 (file)
@@ -42,8 +42,8 @@ public:
   int regetattr_mask;          // getattr mask if i need to re-stat after a traceless reply
  
   utime_t  sent_stamp;
-  int      mds;                // who i am asking
-  int      resend_mds;         // someone wants you to (re)send the request here
+  mds_rank_t mds;                // who i am asking
+  mds_rank_t resend_mds;         // someone wants you to (re)send the request here
   bool     send_to_auth;       // must send to auth mds
   __u32    sent_on_mseq;       // mseq at last submission of this request
   int      num_fwd;            // # of times i've been forwarded
index b6fd8f354a4714e1c7f683e4e1c0c723aa284354..6eb813cb22d4e1c4c5e6be033c956af3282fa2f5 100644 (file)
@@ -10,6 +10,7 @@
 #include "include/xlist.h"
 
 #include "messages/MClientCapRelease.h"
+#include "mds/MDSMap.h"
 
 struct Cap;
 struct Inode;
@@ -18,7 +19,7 @@ struct MetaRequest;
 class MClientCapRelease;
 
 struct MetaSession {
-  int mds_num;
+  mds_rank_t mds_num;
   ConnectionRef con;
   version_t seq;
   uint64_t cap_gen;
index 6f7d1288dcb27a6655984792dffeeb0e1fa41f67..6a6a5c8c2b15fd9a011e57c685048c47e91b9dc6 100644 (file)
@@ -50,7 +50,8 @@ Beacon::~Beacon()
 }
 
 
-void Beacon::init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_, int standby_rank_, std::string const & standby_name_)
+void Beacon::init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_,
+    mds_rank_t standby_rank_, std::string const & standby_name_)
 {
   Mutex::Locker l(lock);
   assert(mdsmap != NULL);
@@ -164,7 +165,7 @@ void Beacon::_send()
   seq_stamp[last_seq] = ceph_clock_now(g_ceph_context);
   
   MMDSBeacon *beacon = new MMDSBeacon(
-      monc->get_fsid(), monc->get_global_id(),
+      monc->get_fsid(), mds_gid_t(monc->get_global_id()),
       name,
       epoch,
       want_state,
index 9148366d94f5a3ee0d06d2033e6345de8cc8ceae..4336d1a0b3be830bef401de79c3c74ade58a2da2 100644 (file)
@@ -48,7 +48,7 @@ class Beacon : public Dispatcher
   std::string name;
   version_t epoch;
   CompatSet compat;
-  int standby_for_rank;
+  mds_rank_t standby_for_rank;
   std::string standby_for_name;
   MDSMap::DaemonState want_state;
 
@@ -83,7 +83,7 @@ public:
   Beacon(CephContext *cct_, MonClient *monc_, std::string name);
   ~Beacon();
 
-  void init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_, int standby_rank_, std::string const &standby_name_);
+  void init(MDSMap const *mdsmap, MDSMap::DaemonState want_state_, mds_rank_t standby_rank_, std::string const &standby_name_);
   void shutdown();
 
   bool ms_dispatch(Message *m); 
@@ -95,7 +95,7 @@ public:
   void notify_want_state(MDSMap::DaemonState const newstate);
   void notify_health(MDS const *mds);
 
-  void set_standby_for(int rank_, std::string const &name_);
+  void set_standby_for(mds_rank_t rank_, std::string const &name_);
 
   void handle_mds_beacon(MMDSBeacon *m);
   void send();
index 4bcb9d3a132b6ebd38c71c03e84efe89d3a4d35d..ca87a21940a62c8d4019aac32d9c5df8eaeb7af7 100644 (file)
@@ -137,7 +137,7 @@ inodeno_t CDentry::get_ino()
 }
 */
 
-pair<int,int> CDentry::authority()
+mds_authority_t CDentry::authority()
 {
   return dir->authority();
 }
index 0de626a29658fdf6a4bf545751d7be59a6a51abe..30964396417301ae555736ff8583aca220640bbe 100644 (file)
@@ -283,7 +283,7 @@ public:
   version_t get_projected_version() { return projected_version; }
   void set_projected_version(version_t v) { projected_version = v; }
   
-  pair<int,int> authority();
+  mds_authority_t authority();
 
   version_t pre_dirty(version_t min=0);
   void _mark_dirty(LogSegment *ls);
@@ -295,7 +295,7 @@ public:
   void clear_new() { state_clear(STATE_NEW); }
   
   // -- replication
-  void encode_replica(int mds, bufferlist& bl) {
+  void encode_replica(mds_rank_t mds, bufferlist& bl) {
     if (!is_replicated())
       lock.replicate_relax();
 
index e5a1f5109c1f3b8d5b1b15880d52dff9587ae72c..ba1a3eaced8af4e43377941399fd06997c76e407 100644 (file)
@@ -91,7 +91,7 @@ ostream& operator<<(ostream& out, CDir& dir)
     out << " cv=" << dir.get_committing_version();
     out << "/" << dir.get_committed_version();
   } else {
-    pair<int,int> a = dir.authority();
+    mds_authority_t a = dir.authority();
     out << " rep@" << a.first;
     if (a.second != CDIR_AUTH_UNKNOWN)
       out << "," << a.second;
@@ -981,7 +981,7 @@ void CDir::merge(list<CDir*>& subs, list<MDSInternalContextBase*>& waiters, bool
       steal_dentry(dir->items.begin()->second);
     
     // merge replica map
-    for (map<int,unsigned>::iterator p = dir->replicas_begin();
+    for (map<mds_rank_t,unsigned>::iterator p = dir->replicas_begin();
         p != dir->replica_map.end();
         ++p) {
       unsigned cur = replica_map[p->first];
@@ -2168,7 +2168,7 @@ void CDir::decode_import(bufferlist::iterator& blp, utime_t now, LogSegment *ls)
  * if dir_auth.first == parent, auth is same as inode.
  * unless .second != unknown, in which case that sticks.
  */
-pair<int,int> CDir::authority() 
+mds_authority_t CDir::authority() 
 {
   if (is_subtree_root()) 
     return dir_auth;
@@ -2219,7 +2219,7 @@ bool CDir::contains(CDir *x)
 
 /** set_dir_auth
  */
-void CDir::set_dir_auth(pair<int,int> a)
+void CDir::set_dir_auth(mds_authority_t a)
 { 
   dout(10) << "setting dir_auth=" << a
           << " from " << dir_auth
index 0e035d8743b15981eff0a54ca3bd551f6d77e942..4617f5573d732f7f283eb157f617b8b8d676fb61 100644 (file)
@@ -389,13 +389,13 @@ private:
    *  ambiguous: <mds1,mds2>         subtree_root
    *             <parent,mds2>       subtree_root     
    */
-  pair<int,int> dir_auth;
+  mds_authority_t dir_auth;
 
  public:
-  pair<int,int> authority();
-  pair<int,int> get_dir_auth() { return dir_auth; }
-  void set_dir_auth(pair<int,int> a);
-  void set_dir_auth(int a) { set_dir_auth(pair<int,int>(a, CDIR_AUTH_UNKNOWN)); }
+  mds_authority_t authority();
+  mds_authority_t get_dir_auth() { return dir_auth; }
+  void set_dir_auth(mds_authority_t a);
+  void set_dir_auth(mds_rank_t a) { set_dir_auth(mds_authority_t(a, CDIR_AUTH_UNKNOWN)); }
   bool is_ambiguous_dir_auth() {
     return dir_auth.second != CDIR_AUTH_UNKNOWN;
   }
@@ -414,9 +414,9 @@ private:
 
 
   // for giving to clients
-  void get_dist_spec(std::set<int>& ls, int auth) {
+  void get_dist_spec(std::set<mds_rank_t>& ls, mds_rank_t auth) {
     if (is_rep()) {
-      for (std::map<int,unsigned>::iterator p = replicas_begin();
+      for (std::map<mds_rank_t,unsigned>::iterator p = replicas_begin();
           p != replicas_end(); 
           ++p)
        ls.insert(p->first);
@@ -424,13 +424,13 @@ private:
        ls.insert(auth);
     }
   }
-  void encode_dirstat(bufferlist& bl, int whoami) {
+  void encode_dirstat(bufferlist& bl, mds_rank_t whoami) {
     /*
      * note: encoding matches struct ceph_client_reply_dirfrag
      */
     frag_t frag = get_frag();
-    __s32 auth;
-    std::set<__s32> dist;
+    mds_rank_t auth;
+    std::set<mds_rank_t> dist;
     
     auth = dir_auth.first;
     if (is_auth()) 
@@ -453,7 +453,7 @@ private:
     ::decode(dir_rep, p);
     ::decode(dir_rep_by, p);
   }
-  void encode_replica(int who, bufferlist& bl) {
+  void encode_replica(mds_rank_t who, bufferlist& bl) {
     __u32 nonce = add_replica(who);
     ::encode(nonce, bl);
     _encode_base(bl);
index c2bd0761a6eac184e66f92402b66cdd7a6384686..80aec74e81a45c8358e09e6ea4bb1606f7be770c 100644 (file)
@@ -111,7 +111,7 @@ ostream& operator<<(ostream& out, CInode& in)
     if (in.is_replicated()) 
       out << in.get_replicas();
   } else {
-    pair<int,int> a = in.authority();
+    mds_authority_t a = in.authority();
     out << " rep@" << a.first;
     if (a.second != CDIR_AUTH_UNKNOWN)
       out << "," << a.second;
@@ -2259,7 +2259,7 @@ void CInode::adjust_nested_auth_pins(int a, void *by)
 
 // authority
 
-pair<int,int> CInode::authority() 
+mds_authority_t CInode::authority() 
 {
   if (inode_auth.first >= 0) 
     return inode_auth;
index 2162820ed247030363c32da80e9a86599b52bb55..ff19bd6b57df7bd1823618ccd142bce0f8eb1165 100644 (file)
@@ -388,7 +388,7 @@ public:
 
   std::list<CDentry*>   projected_parent;   // for in-progress rename, (un)link, etc.
 
-  pair<int,int> inode_auth;
+  mds_authority_t inode_auth;
 
   // -- distributed state --
 protected:
@@ -557,7 +557,7 @@ public:
   void encode_store(bufferlist& bl);
   void decode_store(bufferlist::iterator& bl);
 
-  void encode_replica(int rep, bufferlist& bl) {
+  void encode_replica(mds_rank_t rep, bufferlist& bl) {
     assert(is_auth());
     
     // relax locks?
@@ -773,7 +773,7 @@ public:
 
 
   // -- authority --
-  pair<int,int> authority();
+  mds_authority_t authority();
 
 
   // -- auth pins --
index ba92196583a65b8881d2ef319df6bec088b63b7a..4474140e60ea0c7a542866ac9814e011ea2b5c25 100644 (file)
@@ -128,7 +128,7 @@ void Locker::tick()
 
 void Locker::send_lock_message(SimpleLock *lock, int msg)
 {
-  for (map<int,unsigned>::iterator it = lock->get_parent()->replicas_begin();
+  for (map<mds_rank_t,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) 
@@ -140,7 +140,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,unsigned>::iterator it = lock->get_parent()->replicas_begin();
+  for (map<mds_rank_t,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) 
@@ -209,7 +209,7 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
                           set<SimpleLock*> &rdlocks,
                           set<SimpleLock*> &wrlocks,
                           set<SimpleLock*> &xlocks,
-                          map<SimpleLock*,int> *remote_wrlocks,
+                          map<SimpleLock*,mds_rank_t> *remote_wrlocks,
                           CInode *auth_pin_freeze,
                           bool auth_pin_nonblock)
 {
@@ -287,7 +287,7 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
 
   // remote_wrlocks
   if (remote_wrlocks) {
-    for (map<SimpleLock*,int>::iterator p = remote_wrlocks->begin(); p != remote_wrlocks->end(); ++p) {
+    for (map<SimpleLock*,mds_rank_t>::iterator p = remote_wrlocks->begin(); p != remote_wrlocks->end(); ++p) {
       MDSCacheObject *object = p->first->get_parent();
       dout(20) << " must remote_wrlock on mds." << p->second << " "
               << *p->first << " " << *object << dendl;
@@ -315,7 +315,7 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
 
  
   // AUTH PINS
-  map<int, set<MDSCacheObject*> > mustpin_remote;  // mds -> (object set)
+  map<mds_rank_t, set<MDSCacheObject*> > mustpin_remote;  // mds -> (object set)
   
   // can i auth pin them all now?
   marker.message = "failed to authpin local pins";
@@ -373,17 +373,17 @@ bool Locker::acquire_locks(MDRequestRef& mdr,
   // request remote auth_pins
   if (!mustpin_remote.empty()) {
     marker.message = "requesting remote authpins";
-    for (map<MDSCacheObject*,int>::iterator p = mdr->remote_auth_pins.begin();
+    for (map<MDSCacheObject*,mds_rank_t>::iterator p = mdr->remote_auth_pins.begin();
         p != mdr->remote_auth_pins.end();
         ++p) {
       if (mustpin.count(p->first)) {
        assert(p->second == p->first->authority().first);
-       map<int, set<MDSCacheObject*> >::iterator q = mustpin_remote.find(p->second);
+       map<mds_rank_t, set<MDSCacheObject*> >::iterator q = mustpin_remote.find(p->second);
        if (q != mustpin_remote.end())
          q->second.insert(p->first);
       }
     }
-    for (map<int, set<MDSCacheObject*> >::iterator p = mustpin_remote.begin();
+    for (map<mds_rank_t, set<MDSCacheObject*> >::iterator p = mustpin_remote.begin();
         p != mustpin_remote.end();
         ++p) {
       dout(10) << "requesting remote auth_pins from mds." << p->first << dendl;
@@ -599,7 +599,7 @@ void Locker::_drop_rdlocks(MutationImpl *mut, set<CInode*> *pneed_issue)
 
 void Locker::_drop_non_rdlocks(MutationImpl *mut, set<CInode*> *pneed_issue)
 {
-  set<int> slaves;
+  set<mds_rank_t> slaves;
 
   while (!mut->xlocks.empty()) {
     SimpleLock *lock = *mut->xlocks.begin();
@@ -619,7 +619,7 @@ void Locker::_drop_non_rdlocks(MutationImpl *mut, set<CInode*> *pneed_issue)
   }
 
   while (!mut->remote_wrlocks.empty()) {
-    map<SimpleLock*,int>::iterator p = mut->remote_wrlocks.begin();
+    map<SimpleLock*,mds_rank_t>::iterator p = mut->remote_wrlocks.begin();
     slaves.insert(p->second);
     if (mut->wrlocks.count(p->first) == 0)
       mut->locks.erase(p->first);
@@ -634,7 +634,7 @@ void Locker::_drop_non_rdlocks(MutationImpl *mut, set<CInode*> *pneed_issue)
       pneed_issue->insert(static_cast<CInode*>(p));
   }
 
-  for (set<int>::iterator p = slaves.begin(); p != slaves.end(); ++p) {
+  for (set<mds_rank_t>::iterator p = slaves.begin(); p != slaves.end(); ++p) {
     if (mds->mdsmap->get_state(*p) >= MDSMap::STATE_REJOIN) {
       dout(10) << "_drop_non_rdlocks dropping remote locks on mds." << *p << dendl;
       MMDSSlaveRequest *slavereq = new MMDSSlaveRequest(mut->reqid, mut->attempt,
@@ -775,7 +775,7 @@ void Locker::eval_gather(SimpleLock *lock, bool first, bool *pneed_issue, list<M
 
     if (!lock->get_parent()->is_auth()) {
       // replica: tell auth
-      int auth = lock->get_parent()->authority().first;
+      mds_rank_t auth = lock->get_parent()->authority().first;
 
       if (lock->get_parent()->is_rejoining() &&
          mds->mdsmap->get_state(auth) == MDSMap::STATE_REJOIN) {
@@ -1181,7 +1181,7 @@ bool Locker::_rdlock_kick(SimpleLock *lock, bool as_anon)
       return true;
     } else {
       // request rdlock state change from auth
-      int auth = lock->get_parent()->authority().first;
+      mds_rank_t auth = lock->get_parent()->authority().first;
       if (mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) {
        dout(10) << "requesting rdlock from auth on "
                 << *lock << " on " << *lock->get_parent() << dendl;
@@ -1409,7 +1409,7 @@ bool Locker::wrlock_start(SimpleLock *lock, MDRequestRef& mut, bool nowait)
     } else {
       // replica.
       // auth should be auth_pinned (see acquire_locks wrlock weird mustpin case).
-      int auth = lock->get_parent()->authority().first;
+      mds_rank_t auth = lock->get_parent()->authority().first;
       if (mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) {
        dout(10) << "requesting scatter from auth on "
                 << *lock << " on " << *lock->get_parent() << dendl;
@@ -1453,7 +1453,7 @@ void Locker::wrlock_finish(SimpleLock *lock, MutationImpl *mut, bool *pneed_issu
 
 // remote wrlock
 
-void Locker::remote_wrlock_start(SimpleLock *lock, int target, MDRequestRef& mut)
+void Locker::remote_wrlock_start(SimpleLock *lock, mds_rank_t target, MDRequestRef& mut)
 {
   dout(7) << "remote_wrlock_start mds." << target << " on " << *lock << " on " << *lock->get_parent() << dendl;
 
@@ -1478,7 +1478,7 @@ void Locker::remote_wrlock_start(SimpleLock *lock, int target, MDRequestRef& mut
   mut->more()->waiting_on_slave.insert(target);
 }
 
-void Locker::remote_wrlock_finish(SimpleLock *lock, int target,
+void Locker::remote_wrlock_finish(SimpleLock *lock, mds_rank_t target,
                                   MutationImpl *mut)
 {
   // drop ref
@@ -1558,7 +1558,7 @@ bool Locker::xlock_start(SimpleLock *lock, MDRequestRef& mut)
     }
     
     // wait for active auth
-    int auth = lock->get_parent()->authority().first;
+    mds_rank_t auth = lock->get_parent()->authority().first;
     if (!mds->mdsmap->is_clientreplay_or_active_or_stopping(auth)) {
       dout(7) << " mds." << auth << " is not active" << dendl;
       if (mut->more()->waiting_on_slave.empty())
@@ -1631,7 +1631,7 @@ void Locker::xlock_finish(SimpleLock *lock, MutationImpl *mut, bool *pneed_issue
 
     // tell auth
     dout(7) << "xlock_finish releasing remote xlock on " << *lock->get_parent()  << dendl;
-    int auth = lock->get_parent()->authority().first;
+    mds_rank_t auth = lock->get_parent()->authority().first;
     if (mds->mdsmap->get_state(auth) >= MDSMap::STATE_REJOIN) {
       MMDSSlaveRequest *slavereq = new MMDSSlaveRequest(mut->reqid, mut->attempt,
                                                        MMDSSlaveRequest::OP_UNXLOCK);
@@ -2078,7 +2078,7 @@ void Locker::request_inode_file_caps(CInode *in)
       return;
     }
 
-    int auth = in->authority().first;
+    mds_rank_t auth = in->authority().first;
     if (mds->mdsmap->get_state(auth) == MDSMap::STATE_REJOIN) {
       mds->wait_for_active_peer(auth, new C_MDL_RequestInodeFileCaps(this, in));
       return;
@@ -2104,7 +2104,7 @@ void Locker::handle_inode_file_caps(MInodeFileCaps *m)
 
   // ok
   CInode *in = mdcache->get_inode(m->get_ino());
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   assert(in);
   assert(in->is_auth());
@@ -4267,7 +4267,7 @@ void Locker::scatter_nudge(ScatterLock *lock, MDSInternalContextBase *c, bool fo
     dout(10) << "scatter_nudge replica, requesting scatter/unscatter of " 
             << *lock << " on " << *p << dendl;
     // request unscatter?
-    int auth = lock->get_parent()->authority().first;
+    mds_rank_t auth = lock->get_parent()->authority().first;
     if (mds->mdsmap->is_clientreplay_or_active_or_stopping(auth))
       mds->send_message_mds(new MLock(lock, LOCK_AC_NUDGE, mds->get_nodeid()), auth);
 
index 6df00c4a75dfd3949275169c309314d830b6d2df..6322f65bd8cfbb8cd98cdcefa161b5c2debc925f 100644 (file)
@@ -88,7 +88,7 @@ public:
                     set<SimpleLock*> &rdlocks,
                     set<SimpleLock*> &wrlocks,
                     set<SimpleLock*> &xlocks,
-                    map<SimpleLock*,int> *remote_wrlocks=NULL,
+                    map<SimpleLock*,mds_rank_t> *remote_wrlocks=NULL,
                     CInode *auth_pin_freeze=NULL,
                     bool auth_pin_nonblock=false);
 
@@ -127,8 +127,8 @@ public:
   bool wrlock_start(SimpleLock *lock, MDRequestRef& mut, bool nowait=false);
   void wrlock_finish(SimpleLock *lock, MutationImpl *mut, bool *pneed_issue);
 
-  void remote_wrlock_start(SimpleLock *lock, int target, MDRequestRef& mut);
-  void remote_wrlock_finish(SimpleLock *lock, int target, MutationImpl *mut);
+  void remote_wrlock_start(SimpleLock *lock, mds_rank_t target, MDRequestRef& mut);
+  void remote_wrlock_finish(SimpleLock *lock, mds_rank_t target, MutationImpl *mut);
 
   bool xlock_start(SimpleLock *lock, MDRequestRef& mut);
   void _finish_xlock(SimpleLock *lock, client_t xlocker, bool *pneed_issue);
@@ -163,7 +163,6 @@ public:
 
 protected:
   void handle_scatter_lock(ScatterLock *lock, MLock *m);
-  void _scatter_replica_lock(ScatterLock *lock, int auth);
   bool scatter_scatter_fastpath(ScatterLock *lock);
   void scatter_scatter(ScatterLock *lock, bool nowait=false);
   void scatter_tempsync(ScatterLock *lock, bool *need_issue=0);
index 969a5cb467c9499db71f4948265eb0e89d51f4c4..921969146aa5c77fe43d6b73ca5217701d7a2e67 100644 (file)
@@ -190,18 +190,18 @@ void MDBalancer::send_heartbeat()
 
   // my load
   mds_load_t load = get_load(now);
-  map<int, mds_load_t>::value_type val(mds->get_nodeid(), load);
+  map<mds_rank_t, mds_load_t>::value_type val(mds->get_nodeid(), load);
   mds_load.insert(val);
 
   // import_map -- how much do i import from whom
-  map<int, float> import_map;
+  map<mds_rank_t, float> import_map;
   set<CDir*> authsubs;
   mds->mdcache->get_auth_subtrees(authsubs);
   for (set<CDir*>::iterator it = authsubs.begin();
        it != authsubs.end();
        ++it) {
     CDir *im = *it;
-    int from = im->inode->authority().first;
+    mds_rank_t from = im->inode->authority().first;
     if (from == mds->get_nodeid()) continue;
     if (im->get_inode()->is_stray()) continue;
     import_map[from] += im->pop_auth_subtree.meta_load(now, mds->mdcache->decayrate);
@@ -210,16 +210,16 @@ void MDBalancer::send_heartbeat()
 
 
   dout(5) << "mds." << mds->get_nodeid() << " epoch " << beat_epoch << " load " << load << dendl;
-  for (map<int, float>::iterator it = import_map.begin();
+  for (map<mds_rank_t, float>::iterator it = import_map.begin();
        it != import_map.end();
        ++it) {
     dout(5) << "  import_map from " << it->first << " -> " << it->second << dendl;
   }
 
 
-  set<int> up;
+  set<mds_rank_t> up;
   mds->get_mds_map()->get_mds_set(up);
-  for (set<int>::iterator p = up.begin(); p != up.end(); ++p) {
+  for (set<mds_rank_t>::iterator p = up.begin(); p != up.end(); ++p) {
     if (*p == mds->get_nodeid())
       continue;
     MHeartbeat *hb = new MHeartbeat(load, beat_epoch);
@@ -232,9 +232,9 @@ void MDBalancer::send_heartbeat()
 /* This function DOES put the passed message before returning */
 void MDBalancer::handle_heartbeat(MHeartbeat *m)
 {
-  typedef map<int, mds_load_t> mds_load_map_t;
+  typedef map<mds_rank_t, mds_load_t> mds_load_map_t;
 
-  int who = m->get_source().num();
+  mds_rank_t who = mds_rank_t(m->get_source().num());
   dout(25) << "=== got heartbeat " << m->get_beat() << " from " << m->get_source().num() << " " << m->get_load() << dendl;
 
   if (!mds->is_active())
@@ -309,8 +309,8 @@ void MDBalancer::export_empties()
 
 
 
-double MDBalancer::try_match(int ex, double& maxex,
-                             int im, double& maxim)
+double MDBalancer::try_match(mds_rank_t ex, double& maxex,
+                             mds_rank_t im, double& maxim)
 {
   if (maxex <= 0 || maxim <= 0) return 0.0;
 
@@ -424,15 +424,15 @@ void MDBalancer::prep_rebalance(int beat)
   if (g_conf->mds_thrash_exports) {
     //we're going to randomly export to all the mds in the cluster
     my_targets.clear();
-    set<int> up_mds;
+    set<mds_rank_t> up_mds;
     mds->get_mds_map()->get_up_mds_set(up_mds);
-    for (set<int>::iterator i = up_mds.begin();
+    for (set<mds_rank_t>::iterator i = up_mds.begin();
         i != up_mds.end();
         ++i)
       my_targets[*i] = 0.0;
   } else {
     int cluster_size = mds->get_mds_map()->get_num_in_mds();
-    int whoami = mds->get_nodeid();
+    mds_rank_t whoami = mds->get_nodeid();
     rebalance_time = ceph_clock_now(g_ceph_context);
 
     // reset
@@ -446,7 +446,7 @@ void MDBalancer::prep_rebalance(int beat)
 
     // rescale!  turn my mds_load back into meta_load units
     double load_fac = 1.0;
-    map<int, mds_load_t>::iterator m = mds_load.find(whoami);
+    map<mds_rank_t, mds_load_t>::iterator m = mds_load.find(whoami);
     if ((m != mds_load.end()) && (m->second.mds_load() > 0)) {
       double metald = m->second.auth.meta_load(rebalance_time, mds->mdcache->decayrate);
       double mdsld = m->second.mds_load();
@@ -458,10 +458,10 @@ void MDBalancer::prep_rebalance(int beat)
     }
 
     double total_load = 0;
-    multimap<double,int> load_map;
-    for (int i=0; i<cluster_size; i++) {
-      map<int, mds_load_t>::value_type val(i, mds_load_t(ceph_clock_now(g_ceph_context)));
-      std::pair < map<int, mds_load_t>::iterator, bool > r(mds_load.insert(val));
+    multimap<double,mds_rank_t> load_map;
+    for (mds_rank_t i=mds_rank_t(0); i < mds_rank_t(cluster_size); i++) {
+      map<mds_rank_t, mds_load_t>::value_type val(i, mds_load_t(ceph_clock_now(g_ceph_context)));
+      std::pair < map<mds_rank_t, mds_load_t>::iterator, bool > r(mds_load.insert(val));
       mds_load_t &load(r.first->second);
 
       double l = load.mds_load() * load_fac;
@@ -476,7 +476,7 @@ void MDBalancer::prep_rebalance(int beat)
       if (whoami == i) my_load = l;
       total_load += l;
 
-      load_map.insert(pair<double,int>( l, i ));
+      load_map.insert(pair<double,mds_rank_t>( l, i ));
     }
 
     // target load
@@ -506,21 +506,21 @@ void MDBalancer::prep_rebalance(int beat)
 
 
     // first separate exporters and importers
-    multimap<double,int> importers;
-    multimap<double,int> exporters;
-    set<int>             importer_set;
-    set<int>             exporter_set;
+    multimap<double,mds_rank_t> importers;
+    multimap<double,mds_rank_t> exporters;
+    set<mds_rank_t>             importer_set;
+    set<mds_rank_t>             exporter_set;
 
-    for (multimap<double,int>::iterator it = load_map.begin();
+    for (multimap<double,mds_rank_t>::iterator it = load_map.begin();
         it != load_map.end();
         ++it) {
       if (it->first < target_load) {
        dout(15) << "   mds." << it->second << " is importer" << dendl;
-       importers.insert(pair<double,int>(it->first,it->second));
+       importers.insert(pair<double,mds_rank_t>(it->first,it->second));
        importer_set.insert(it->second);
       } else {
        dout(15) << "   mds." << it->second << " is exporter" << dendl;
-       exporters.insert(pair<double,int>(it->first,it->second));
+       exporters.insert(pair<double,mds_rank_t>(it->first,it->second));
        exporter_set.insert(it->second);
       }
     }
@@ -534,14 +534,14 @@ void MDBalancer::prep_rebalance(int beat)
       dout(15) << "  matching exporters to import sources" << dendl;
 
       // big -> small exporters
-      for (multimap<double,int>::reverse_iterator ex = exporters.rbegin();
+      for (multimap<double,mds_rank_t>::reverse_iterator ex = exporters.rbegin();
           ex != exporters.rend();
           ++ex) {
        double maxex = get_maxex(ex->second);
        if (maxex <= .001) continue;
 
        // check importers. for now, just in arbitrary order (no intelligent matching).
-       for (map<int, float>::iterator im = mds_import_map[ex->second].begin();
+       for (map<mds_rank_t, float>::iterator im = mds_import_map[ex->second].begin();
             im != mds_import_map[ex->second].end();
             ++im) {
          double maxim = get_maxim(im->first);
@@ -559,8 +559,8 @@ void MDBalancer::prep_rebalance(int beat)
        // old way
        dout(15) << "  matching big exporters to big importers" << dendl;
        // big exporters to big importers
-       multimap<double,int>::reverse_iterator ex = exporters.rbegin();
-       multimap<double,int>::iterator im = importers.begin();
+       multimap<double,mds_rank_t>::reverse_iterator ex = exporters.rbegin();
+       multimap<double,mds_rank_t>::iterator im = importers.begin();
        while (ex != exporters.rend() &&
               im != importers.end()) {
          double maxex = get_maxex(ex->second);
@@ -575,8 +575,8 @@ void MDBalancer::prep_rebalance(int beat)
        // new way
        dout(15) << "  matching small exporters to big importers" << dendl;
        // small exporters to big importers
-       multimap<double,int>::iterator ex = exporters.begin();
-       multimap<double,int>::iterator im = importers.begin();
+       multimap<double,mds_rank_t>::iterator ex = exporters.begin();
+       multimap<double,mds_rank_t>::iterator im = importers.begin();
        while (ex != exporters.end() &&
               im != importers.end()) {
          double maxex = get_maxex(ex->second);
@@ -608,7 +608,7 @@ void MDBalancer::try_rebalance()
 
   // make a sorted list of my imports
   map<double,CDir*>    import_pop_map;
-  multimap<int,CDir*>  import_from_map;
+  multimap<mds_rank_t,CDir*>  import_from_map;
   set<CDir*> fullauthsubs;
 
   mds->mdcache->get_fullauth_subtrees(fullauthsubs);
@@ -631,9 +631,9 @@ void MDBalancer::try_rebalance()
     }
 
     import_pop_map[ pop ] = im;
-    int from = im->inode->authority().first;
+    mds_rank_t from = im->inode->authority().first;
     dout(15) << "  map: i imported " << *im << " from " << from << dendl;
-    import_from_map.insert(pair<int,CDir*>(from, im));
+    import_from_map.insert(pair<mds_rank_t,CDir*>(from, im));
   }
 
 
@@ -641,10 +641,10 @@ void MDBalancer::try_rebalance()
   // do my exports!
   set<CDir*> already_exporting;
 
-  for (map<int,double>::iterator it = my_targets.begin();
+  for (map<mds_rank_t,double>::iterator it = my_targets.begin();
        it != my_targets.end();
        ++it) {
-    int target = (*it).first;
+    mds_rank_t target = (*it).first;
     double amount = (*it).second;
 
     if (amount < MIN_OFFLOAD) continue;
@@ -662,12 +662,12 @@ void MDBalancer::try_rebalance()
     // search imports from target
     if (import_from_map.count(target)) {
       dout(5) << " aha, looking through imports from target mds." << target << dendl;
-      pair<multimap<int,CDir*>::iterator, multimap<int,CDir*>::iterator> p =
+      pair<multimap<mds_rank_t,CDir*>::iterator, multimap<mds_rank_t,CDir*>::iterator> p =
        import_from_map.equal_range(target);
       while (p.first != p.second) {
        CDir *dir = (*p.first).second;
        dout(5) << "considering " << *dir << " from " << (*p.first).first << dendl;
-       multimap<int,CDir*>::iterator plast = p.first++;
+       multimap<mds_rank_t,CDir*>::iterator plast = p.first++;
 
        if (dir->inode->is_base() ||
            dir->inode->is_stray())
@@ -758,13 +758,13 @@ void MDBalancer::try_rebalance()
 bool MDBalancer::check_targets()
 {
   // get MonMap's idea of my_targets
-  const set<int32_t>& map_targets = mds->mdsmap->get_mds_info(mds->whoami).export_targets;
+  const set<mds_rank_t>& map_targets = mds->mdsmap->get_mds_info(mds->whoami).export_targets;
 
   bool send = false;
   bool ok = true;
 
   // make sure map targets are in the old_prev_targets map
-  for (set<int32_t>::iterator p = map_targets.begin(); p != map_targets.end(); ++p) {
+  for (set<mds_rank_t>::iterator p = map_targets.begin(); p != map_targets.end(); ++p) {
     if (old_prev_targets.count(*p) == 0)
       old_prev_targets[*p] = 0;
     if (my_targets.count(*p) == 0)
@@ -772,8 +772,8 @@ bool MDBalancer::check_targets()
   }
 
   // check if the current MonMap has all our targets
-  set<int32_t> need_targets;
-  for (map<int,double>::iterator i = my_targets.begin();
+  set<mds_rank_t> need_targets;
+  for (map<mds_rank_t,double>::iterator i = my_targets.begin();
        i != my_targets.end();
        ++i) {
     need_targets.insert(i->first);
@@ -786,8 +786,8 @@ bool MDBalancer::check_targets()
     }
   }
 
-  set<int32_t> want_targets = need_targets;
-  map<int32_t, int>::iterator p = old_prev_targets.begin();
+  set<mds_rank_t> want_targets = need_targets;
+  map<mds_rank_t, int>::iterator p = old_prev_targets.begin();
   while (p != old_prev_targets.end()) {
     if (map_targets.count(p->first) == 0 &&
        need_targets.count(p->first) == 0) {
@@ -805,7 +805,7 @@ bool MDBalancer::check_targets()
   dout(10) << "check_targets have " << map_targets << " need " << need_targets << " want " << want_targets << dendl;
 
   if (send) {
-    MMDSLoadTargets* m = new MMDSLoadTargets(mds->monc->get_global_id(), want_targets);
+    MMDSLoadTargets* m = new MMDSLoadTargets(mds_gid_t(mds->monc->get_global_id()), want_targets);
     mds->monc->send_mon_message(m);
   }
   return ok;
index dacbf3ceb39e92385b9fe0c2055e9a8ea2558673..696e2ca82177f3245d2fb00ac327e3ac82bf709b 100644 (file)
@@ -50,25 +50,25 @@ class MDBalancer {
   set<dirfrag_t>   split_queue, merge_queue;
 
   // per-epoch scatter/gathered info
-  map<int, mds_load_t>  mds_load;
-  map<int, float>       mds_meta_load;
-  map<int, map<int, float> > mds_import_map;
+  map<mds_rank_t, mds_load_t>  mds_load;
+  map<mds_rank_t, float>       mds_meta_load;
+  map<mds_rank_t, map<mds_rank_t, float> > mds_import_map;
 
   // per-epoch state
   double          my_load, target_load;
-  map<int,double> my_targets;
-  map<int,double> imported;
-  map<int,double> exported;
+  map<mds_rank_t,double> my_targets;
+  map<mds_rank_t,double> imported;
+  map<mds_rank_t,double> exported;
 
-  map<int32_t, int> old_prev_targets;  // # iterations they _haven't_ been targets
+  map<mds_rank_t, int> old_prev_targets;  // # iterations they _haven't_ been targets
   bool check_targets();
 
-  double try_match(int ex, double& maxex,
-                   int im, double& maxim);
-  double get_maxim(int im) {
+  double try_match(mds_rank_t ex, double& maxex,
+                   mds_rank_t im, double& maxim);
+  double get_maxim(mds_rank_t im) {
     return target_load - mds_meta_load[im] - imported[im];
   }
-  double get_maxex(int ex) {
+  double get_maxex(mds_rank_t ex) {
     return mds_meta_load[ex] - target_load - exported[ex];    
   }
 
index 6b9d6c717782ea93a023df739387cb687c809c00..5166abb25155cfa6caba7ba70758c69207ae6499 100644 (file)
@@ -353,9 +353,9 @@ CInode *MDCache::create_system_inode(inodeno_t ino, int mode)
 
   if (in->is_base()) {
     if (in->is_root())
-      in->inode_auth = pair<int,int>(mds->whoami, CDIR_AUTH_UNKNOWN);
+      in->inode_auth = mds_authority_t(mds->whoami, CDIR_AUTH_UNKNOWN);
     else
-      in->inode_auth = pair<int,int>(in->ino() - MDS_INO_MDSDIR_OFFSET, CDIR_AUTH_UNKNOWN);
+      in->inode_auth = mds_authority_t(mds_rank_t(in->ino() - MDS_INO_MDSDIR_OFFSET), CDIR_AUTH_UNKNOWN);
     in->open_snaprealm();  // empty snaprealm
     in->snaprealm->srnode.seq = 1;
   }
@@ -401,7 +401,7 @@ void MDCache::create_mydir_hierarchy(MDSGather *gather)
 {
   // create mds dir
   char myname[10];
-  snprintf(myname, sizeof(myname), "mds%d", mds->whoami);
+  snprintf(myname, sizeof(myname), "mds%d", int(mds->whoami));
   CInode *my = create_system_inode(MDS_INO_MDSDIR(mds->whoami), S_IFDIR);
 
   CDir *mydir = my->get_or_open_dirfrag(this, frag_t());
@@ -680,7 +680,7 @@ void MDCache::populate_mydir()
 
 void MDCache::open_foreign_mdsdir(inodeno_t ino, MDSInternalContextBase *fin)
 {
-  discover_base_ino(ino, fin, ino & (MAX_MDS-1));
+  discover_base_ino(ino, fin, mds_rank_t(ino & (MAX_MDS-1)));
 }
 
 CDentry *MDCache::get_or_create_stray_dentry(CInode *in)
@@ -741,7 +741,7 @@ void MDCache::list_subtrees(list<CDir*>& ls)
  * merge with parent and/or child subtrees, if is it appropriate.
  * merge can ONLY happen if both parent and child have unambiguous auth.
  */
-void MDCache::adjust_subtree_auth(CDir *dir, pair<int,int> auth, bool do_eval)
+void MDCache::adjust_subtree_auth(CDir *dir, mds_authority_t auth, bool do_eval)
 {
   dout(7) << "adjust_subtree_auth " << dir->get_dir_auth() << " -> " << auth
          << " on " << *dir << dendl;
@@ -941,7 +941,7 @@ void MDCache::eval_subtree_root(CInode *diri)
 }
 
 
-void MDCache::adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, pair<int,int> auth)
+void MDCache::adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, mds_authority_t auth)
 {
   dout(7) << "adjust_bounded_subtree_auth " << dir->get_dir_auth() << " -> " << auth
          << " on " << *dir
@@ -964,7 +964,7 @@ void MDCache::adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, pair<in
   assert(subtrees.count(root));
   dout(7) << " current root is " << *root << dendl;
 
-  pair<int,int> oldauth = dir->authority();
+  mds_authority_t oldauth = dir->authority();
 
   if (root == dir) {
     // i am already a subtree.
@@ -1118,7 +1118,7 @@ void MDCache::get_force_dirfrag_bound_set(vector<dirfrag_t>& dfs, set<CDir*>& bo
   }
 }
 
-void MDCache::adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bound_dfs, pair<int,int> auth)
+void MDCache::adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bound_dfs, mds_authority_t auth)
 {
   dout(7) << "adjust_bounded_subtree_auth " << dir->get_dir_auth() << " -> " << auth
          << " on " << *dir << " bound_dfs " << bound_dfs << dendl;
@@ -2206,7 +2206,7 @@ void MDCache::_logged_master_commit(metareqid_t reqid)
 
 // while active...
 
-void MDCache::committed_master_slave(metareqid_t r, int from)
+void MDCache::committed_master_slave(metareqid_t r, mds_rank_t from)
 {
   dout(10) << "committed_master_slave mds." << from << " on " << r << dendl;
   assert(uncommitted_masters.count(r));
@@ -2255,7 +2255,7 @@ void MDCache::finish_committed_masters()
  * complete resolve before that happens).
  */
 struct C_MDC_SlaveCommit : public MDCacheContext {
-  int from;
+  mds_rank_t from;
   metareqid_t reqid;
   C_MDC_SlaveCommit(MDCache *c, int f, metareqid_t r) : MDCacheContext(c), from(f), reqid(r) {}
   void finish(int r) {
@@ -2263,7 +2263,7 @@ struct C_MDC_SlaveCommit : public MDCacheContext {
   }
 };
 
-void MDCache::_logged_slave_commit(int from, metareqid_t reqid)
+void MDCache::_logged_slave_commit(mds_rank_t from, metareqid_t reqid)
 {
   dout(10) << "_logged_slave_commit from mds." << from << " " << reqid << dendl;
   
@@ -2503,10 +2503,10 @@ void MDCache::send_slave_resolves()
 {
   dout(10) << "send_slave_resolves" << dendl;
 
-  map<int, MMDSResolve*> resolves;
+  map<mds_rank_t, MMDSResolve*> resolves;
 
   if (mds->is_resolve()) {
-    for (map<int, map<metareqid_t, MDSlaveUpdate*> >::iterator p = uncommitted_slave_updates.begin();
+    for (map<mds_rank_t, map<metareqid_t, MDSlaveUpdate*> >::iterator p = uncommitted_slave_updates.begin();
         p != uncommitted_slave_updates.end();
         ++p) {
       resolves[p->first] = new MMDSResolve;
@@ -2518,7 +2518,7 @@ void MDCache::send_slave_resolves()
       }
     }
   } else {
-    set<int> resolve_set;
+    set<mds_rank_t> resolve_set;
     mds->mdsmap->get_mds_set(resolve_set, MDSMap::STATE_RESOLVE);
     for (ceph::unordered_map<metareqid_t, MDRequestRef>::iterator p = active_requests.begin();
         p != active_requests.end();
@@ -2526,7 +2526,7 @@ void MDCache::send_slave_resolves()
       MDRequestRef& mdr = p->second;
       if (!mdr->is_slave() || !mdr->slave_did_prepare())
        continue;
-      int master = mdr->slave_to_mds;
+      mds_rank_t master = mdr->slave_to_mds;
       if (resolve_set.count(master) || is_ambiguous_slave_update(p->first, master)) {
        dout(10) << " including uncommitted " << *mdr << dendl;
        if (!resolves.count(master))
@@ -2547,7 +2547,7 @@ void MDCache::send_slave_resolves()
     }
   }
 
-  for (map<int, MMDSResolve*>::iterator p = resolves.begin();
+  for (map<mds_rank_t, MMDSResolve*>::iterator p = resolves.begin();
        p != resolves.end();
        ++p) {
     dout(10) << "sending slave resolve to mds." << p->first << dendl;
@@ -2568,8 +2568,8 @@ void MDCache::send_subtree_resolves()
     return;  // not now
   }
 
-  map<int, MMDSResolve*> resolves;
-  for (set<int>::iterator p = recovery_set.begin();
+  map<mds_rank_t, MMDSResolve*> resolves;
+  for (set<mds_rank_t>::iterator p = recovery_set.begin();
        p != recovery_set.end();
        ++p) {
     if (*p == mds->whoami)
@@ -2598,14 +2598,14 @@ void MDCache::send_subtree_resolves()
       vector<dirfrag_t> dfls;
       for (set<CDir*>::iterator q = bounds.begin(); q != bounds.end(); ++q)
        dfls.push_back((*q)->dirfrag());
-      for (map<int, MMDSResolve*>::iterator q = resolves.begin();
+      for (map<mds_rank_t, MMDSResolve*>::iterator q = resolves.begin();
           q != resolves.end();
           ++q)
        resolves[q->first]->add_ambiguous_import(dir->dirfrag(), dfls);
       dout(10) << " ambig " << dir->dirfrag() << " " << dfls << dendl;
     } else {
       // not ambiguous.
-      for (map<int, MMDSResolve*>::iterator q = resolves.begin();
+      for (map<mds_rank_t, MMDSResolve*>::iterator q = resolves.begin();
           q != resolves.end();
           ++q)
        resolves[q->first]->add_subtree(dir->dirfrag());
@@ -2616,7 +2616,7 @@ void MDCache::send_subtree_resolves()
           ++q) {
        CDir *bound = *q;
        dfls.push_back(bound->dirfrag());
-       for (map<int, MMDSResolve*>::iterator r = resolves.begin();
+       for (map<mds_rank_t, MMDSResolve*>::iterator r = resolves.begin();
             r != resolves.end();
             ++r)
          resolves[r->first]->add_subtree_bound(dir->dirfrag(), bound->dirfrag());
@@ -2629,7 +2629,7 @@ void MDCache::send_subtree_resolves()
   for (map<dirfrag_t, vector<dirfrag_t> >::iterator p = my_ambiguous_imports.begin();
        p != my_ambiguous_imports.end();
        ++p) {
-    for (map<int, MMDSResolve*>::iterator q = resolves.begin();
+    for (map<mds_rank_t, MMDSResolve*>::iterator q = resolves.begin();
         q != resolves.end();
         ++q)
       resolves[q->first]->add_ambiguous_import(p->first, p->second);
@@ -2637,7 +2637,7 @@ void MDCache::send_subtree_resolves()
   }
 
   // send
-  for (map<int, MMDSResolve*>::iterator p = resolves.begin();
+  for (map<mds_rank_t, MMDSResolve*>::iterator p = resolves.begin();
        p != resolves.end();
        ++p) {
     dout(10) << "sending subtee resolve to mds." << p->first << dendl;
@@ -2646,7 +2646,7 @@ void MDCache::send_subtree_resolves()
   resolves_pending = false;
 }
 
-void MDCache::handle_mds_failure(int who)
+void MDCache::handle_mds_failure(mds_rank_t who)
 {
   dout(7) << "handle_mds_failure mds." << who << dendl;
   
@@ -2733,7 +2733,7 @@ void MDCache::handle_mds_failure(int who)
       }
 
       if (mdr->more()->witnessed.count(who)) {
-       int srcdn_auth = mdr->more()->srcdn_auth_mds;
+       mds_rank_t srcdn_auth = mdr->more()->srcdn_auth_mds;
        if (srcdn_auth >= 0 && mdr->more()->waiting_on_slave.count(srcdn_auth)) {
          dout(10) << " master request " << *mdr << " waiting for rename srcdn's auth mds."
                   << mdr->more()->srcdn_auth_mds << " to reply" << dendl;
@@ -2806,7 +2806,7 @@ void MDCache::handle_mds_failure(int who)
  * handle_mds_recovery - called on another node's transition 
  * from resolve -> active.
  */
-void MDCache::handle_mds_recovery(int who)
+void MDCache::handle_mds_recovery(mds_rank_t who)
 {
   dout(7) << "handle_mds_recovery mds." << who << dendl;
 
@@ -2868,7 +2868,7 @@ void MDCache::handle_mds_recovery(int who)
   mds->queue_waiters(waiters);
 }
 
-void MDCache::set_recovery_set(set<int>& s) 
+void MDCache::set_recovery_set(set<mds_rank_t>& s) 
 {
   dout(7) << "set_recovery_set " << s << dendl;
   recovery_set = s;
@@ -2886,7 +2886,7 @@ void MDCache::set_recovery_set(set<int>& s)
 void MDCache::handle_resolve(MMDSResolve *m)
 {
   dout(7) << "handle_resolve from " << m->get_source() << dendl;
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   if (mds->get_state() < MDSMap::STATE_RESOLVE) {
     if (mds->get_want_state() == CEPH_MDS_STATE_RESOLVE) {
@@ -3058,13 +3058,13 @@ void MDCache::handle_resolve(MMDSResolve *m)
 void MDCache::process_delayed_resolve()
 {
   dout(10) << "process_delayed_resolve" << dendl;
-  map<int, MMDSResolve*> tmp;
+  map<mds_rank_t, MMDSResolve*> tmp;
   tmp.swap(delayed_resolve);
-  for (map<int, MMDSResolve*>::iterator p = tmp.begin(); p != tmp.end(); ++p)
+  for (map<mds_rank_t, MMDSResolve*>::iterator p = tmp.begin(); p != tmp.end(); ++p)
     handle_resolve(p->second);
 }
 
-void MDCache::discard_delayed_resolve(int who)
+void MDCache::discard_delayed_resolve(mds_rank_t who)
 {
   if (delayed_resolve.count(who)) {
       delayed_resolve[who]->put();
@@ -3099,7 +3099,7 @@ void MDCache::maybe_resolve_finish()
 void MDCache::handle_resolve_ack(MMDSResolveAck *ack)
 {
   dout(10) << "handle_resolve_ack " << *ack << " from " << ack->get_source() << dendl;
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   if (!resolve_ack_gather.count(from) ||
       mds->mdsmap->get_state(from) < MDSMap::STATE_RESOLVE) {
@@ -3192,7 +3192,7 @@ void MDCache::handle_resolve_ack(MMDSResolveAck *ack)
   ack->put();
 }
 
-void MDCache::add_uncommitted_slave_update(metareqid_t reqid, int master, MDSlaveUpdate *su)
+void MDCache::add_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master, MDSlaveUpdate *su)
 {
   assert(uncommitted_slave_updates[master].count(reqid) == 0);
   uncommitted_slave_updates[master][reqid] = su;
@@ -3202,7 +3202,7 @@ void MDCache::add_uncommitted_slave_update(metareqid_t reqid, int master, MDSlav
     uncommitted_slave_unlink[*p]++;
 }
 
-void MDCache::finish_uncommitted_slave_update(metareqid_t reqid, int master)
+void MDCache::finish_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master)
 {
   assert(uncommitted_slave_updates[master].count(reqid));
   MDSlaveUpdate* su = uncommitted_slave_updates[master][reqid];
@@ -3247,7 +3247,7 @@ void MDCache::finish_uncommitted_slave_update(metareqid_t reqid, int master)
   delete su;
 }
 
-MDSlaveUpdate* MDCache::get_uncommitted_slave_update(metareqid_t reqid, int master)
+MDSlaveUpdate* MDCache::get_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master)
 {
 
   MDSlaveUpdate* su = NULL;
@@ -3276,10 +3276,10 @@ void MDCache::disambiguate_imports()
 
   bool is_resolve = mds->is_resolve();
   // other nodes' ambiguous imports
-  for (map<int, map<dirfrag_t, vector<dirfrag_t> > >::iterator p = other_ambiguous_imports.begin();
+  for (map<mds_rank_t, map<dirfrag_t, vector<dirfrag_t> > >::iterator p = other_ambiguous_imports.begin();
        p != other_ambiguous_imports.end();
        ++p) {
-    int who = p->first;
+    mds_rank_t who = p->first;
     dout(10) << "ambiguous imports for mds." << who << dendl;
 
     for (map<dirfrag_t, vector<dirfrag_t> >::iterator q = p->second.begin();
@@ -3303,7 +3303,7 @@ void MDCache::disambiguate_imports()
   other_ambiguous_imports.clear();
 
   // my ambiguous imports
-  pair<int,int> me_ambig(mds->whoami, mds->whoami);
+  mds_authority_t me_ambig(mds->whoami, mds->whoami);
   while (!my_ambiguous_imports.empty()) {
     map<dirfrag_t, vector<dirfrag_t> >::iterator q = my_ambiguous_imports.begin();
 
@@ -3642,12 +3642,12 @@ void MDCache::rejoin_send_rejoins()
     return;
   }
 
-  map<int, MMDSCacheRejoin*> rejoins;
+  map<mds_rank_t, MMDSCacheRejoin*> rejoins;
 
 
   // if i am rejoining, send a rejoin to everyone.
   // otherwise, just send to others who are rejoining.
-  for (set<int>::iterator p = recovery_set.begin();
+  for (set<mds_rank_t>::iterator p = recovery_set.begin();
        p != recovery_set.end();
        ++p) {
     if (*p == mds->get_nodeid())  continue;  // nothing to myself!
@@ -3659,12 +3659,12 @@ void MDCache::rejoin_send_rejoins()
   }
 
   if (mds->is_rejoin()) {
-    map<client_t, set<int> > client_exports;
+    map<client_t, set<mds_rank_t> > client_exports;
     for (map<inodeno_t,map<client_t,ceph_mds_cap_reconnect> >::iterator p = cap_exports.begin();
          p != cap_exports.end();
         ++p) {
       assert(cap_export_targets.count(p->first));
-      int target = cap_export_targets[p->first];
+      mds_rank_t target = cap_export_targets[p->first];
       if (rejoins.count(target) == 0)
        continue;
       rejoins[target]->cap_exports[p->first] = p->second;
@@ -3673,11 +3673,11 @@ void MDCache::rejoin_send_rejoins()
           ++q)
        client_exports[q->first].insert(target);
     }
-    for (map<client_t, set<int> >::iterator p = client_exports.begin();
+    for (map<client_t, set<mds_rank_t> >::iterator p = client_exports.begin();
         p != client_exports.end();
         ++p) {
       entity_inst_t inst = mds->sessionmap.get_inst(entity_name_t::CLIENT(p->first.v));
-      for (set<int>::iterator q = p->second.begin(); q != p->second.end(); ++q)
+      for (set<mds_rank_t>::iterator q = p->second.begin(); q != p->second.end(); ++q)
        rejoins[*q]->client_map[p->first] = inst;
     }
   }
@@ -3702,7 +3702,7 @@ void MDCache::rejoin_send_rejoins()
     if (dir->is_auth())
       continue;  // skip my own regions!
 
-    int auth = dir->get_dir_auth().first;
+    mds_rank_t auth = dir->get_dir_auth().first;
     assert(auth >= 0);
     if (rejoins.count(auth) == 0)
       continue;   // don't care about this node's subtrees
@@ -3711,7 +3711,7 @@ void MDCache::rejoin_send_rejoins()
   }
   
   // rejoin root inodes, too
-  for (map<int, MMDSCacheRejoin*>::iterator p = rejoins.begin();
+  for (map<mds_rank_t, MMDSCacheRejoin*>::iterator p = rejoins.begin();
        p != rejoins.end();
        ++p) {
     if (mds->is_rejoin()) {
@@ -3765,7 +3765,7 @@ void MDCache::rejoin_send_rejoins()
       if (mdr->is_slave())
        continue;
       // auth pins
-      for (map<MDSCacheObject*,int>::iterator q = mdr->remote_auth_pins.begin();
+      for (map<MDSCacheObject*,mds_rank_t>::iterator q = mdr->remote_auth_pins.begin();
           q != mdr->remote_auth_pins.end();
           ++q) {
        if (!q->first->is_auth()) {
@@ -3792,7 +3792,7 @@ void MDCache::rejoin_send_rejoins()
           q != mdr->xlocks.end();
           ++q) {
        if (!(*q)->get_parent()->is_auth()) {
-         int who = (*q)->get_parent()->authority().first;
+         mds_rank_t who = (*q)->get_parent()->authority().first;
          if (rejoins.count(who) == 0) continue;
          MMDSCacheRejoin *rejoin = rejoins[who];
          
@@ -3808,10 +3808,10 @@ void MDCache::rejoin_send_rejoins()
        }
       }
       // remote wrlocks
-      for (map<SimpleLock*, int>::iterator q = mdr->remote_wrlocks.begin();
+      for (map<SimpleLock*, mds_rank_t>::iterator q = mdr->remote_wrlocks.begin();
           q != mdr->remote_wrlocks.end();
           ++q) {
-       int who = q->second;
+       mds_rank_t who = q->second;
        if (rejoins.count(who) == 0) continue;
        MMDSCacheRejoin *rejoin = rejoins[who];
 
@@ -3827,7 +3827,7 @@ void MDCache::rejoin_send_rejoins()
   }
 
   // send the messages
-  for (map<int,MMDSCacheRejoin*>::iterator p = rejoins.begin();
+  for (map<mds_rank_t,MMDSCacheRejoin*>::iterator p = rejoins.begin();
        p != rejoins.end();
        ++p) {
     assert(rejoin_sent.count(p->first) == 0);
@@ -3981,7 +3981,7 @@ void MDCache::handle_cache_rejoin(MMDSCacheRejoin *m)
  */
 void MDCache::handle_cache_rejoin_weak(MMDSCacheRejoin *weak)
 {
-  int from = weak->get_source().num();
+  mds_rank_t from = mds_rank_t(weak->get_source().num());
 
   // possible response(s)
   MMDSCacheRejoin *ack = 0;      // if survivor
@@ -4346,7 +4346,7 @@ bool MDCache::parallel_fetch_traverse_dir(inodeno_t ino, filepath& path,
  * all validated replicas are acked with a strong nonce, etc.  if that isn't in the
  * ack, the replica dne, and we can remove it from our replica maps.
  */
-void MDCache::rejoin_scour_survivor_replicas(int from, MMDSCacheRejoin *ack,
+void MDCache::rejoin_scour_survivor_replicas(mds_rank_t from, MMDSCacheRejoin *ack,
                                             set<vinodeno_t>& acked_inodes,
                                             set<SimpleLock *>& gather_locks)
 {
@@ -4430,7 +4430,7 @@ CDir *MDCache::rejoin_invent_dirfrag(dirfrag_t df)
 /* This functions DOES NOT put the passed message before returning */
 void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
 {
-  int from = strong->get_source().num();
+  mds_rank_t from = mds_rank_t(strong->get_source().num());
 
   // only a recovering node will get a strong rejoin.
   assert(mds->is_rejoin());
@@ -4707,7 +4707,7 @@ void MDCache::handle_cache_rejoin_strong(MMDSCacheRejoin *strong)
 void MDCache::handle_cache_rejoin_ack(MMDSCacheRejoin *ack)
 {
   dout(7) << "handle_cache_rejoin_ack from " << ack->get_source() << dendl;
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   // for sending cache expire message
   set<CInode*> isolated_inodes;
@@ -4734,7 +4734,7 @@ void MDCache::handle_cache_rejoin_ack(MMDSCacheRejoin *ack)
        diri->inode.mode = S_IFDIR;
        add_inode(diri);
        if (MDS_INO_MDSDIR(from) == p->first.ino) {
-         diri->inode_auth = pair<int,int>(from, CDIR_AUTH_UNKNOWN);
+         diri->inode_auth = mds_authority_t(from, CDIR_AUTH_UNKNOWN);
          dout(10) << " add inode " << *diri << dendl;
        } else {
          diri->inode_auth = CDIR_AUTH_DEFAULT;
@@ -5048,15 +5048,15 @@ void MDCache::rejoin_open_ino_finish(inodeno_t ino, int ret)
   } else if (ret == mds->get_nodeid()) {
     assert(get_inode(ino));
   } else {
-    map<inodeno_t,map<client_t,map<int,ceph_mds_cap_reconnect> > >::iterator p;
+    map<inodeno_t,map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> > >::iterator p;
     p = cap_imports.find(ino);
     assert(p != cap_imports.end());
-    for (map<client_t,map<int,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
+    for (map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
        q != p->second.end();
        ++q) {
-      assert(q->second.count(-1));
+      assert(q->second.count(MDS_RANK_NONE));
       assert(q->second.size() == 1);
-      rejoin_export_caps(p->first, q->first, q->second[-1], ret);
+      rejoin_export_caps(p->first, q->first, q->second[MDS_RANK_NONE], ret);
     }
     cap_imports.erase(p);
   }
@@ -5098,7 +5098,7 @@ bool MDCache::process_imported_caps()
 {
   dout(10) << "process_imported_caps" << dendl;
 
-  for (map<inodeno_t,map<client_t, map<int,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
+  for (map<inodeno_t,map<client_t, map<mds_rank_t,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
        p != cap_imports.end();
        ++p) {
     CInode *in = get_inode(p->first);
@@ -5137,7 +5137,7 @@ bool MDCache::process_imported_caps()
     rejoin_client_map.clear();
 
     // process caps that were exported by slave rename
-    for (map<inodeno_t,pair<int,map<client_t,Capability::Export> > >::iterator p = rejoin_slave_exports.begin();
+    for (map<inodeno_t,pair<mds_rank_t,map<client_t,Capability::Export> > >::iterator p = rejoin_slave_exports.begin();
         p != rejoin_slave_exports.end();
         ++p) {
       CInode *in = get_inode(p->first);
@@ -5167,7 +5167,7 @@ bool MDCache::process_imported_caps()
 
     // process cap imports
     //  ino -> client -> frommds -> capex
-    for (map<inodeno_t,map<client_t, map<int,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
+    for (map<inodeno_t,map<client_t, map<mds_rank_t,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
         p != cap_imports.end(); ) {
       CInode *in = get_inode(p->first);
       if (!in) {
@@ -5177,12 +5177,12 @@ bool MDCache::process_imported_caps()
        continue;
       }
       assert(in->is_auth());
-      for (map<client_t,map<int,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
+      for (map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
           q != p->second.end();
           ++q) {
        Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(q->first.v));
        assert(session);
-       for (map<int,ceph_mds_cap_reconnect>::iterator r = q->second.begin();
+       for (map<mds_rank_t,ceph_mds_cap_reconnect>::iterator r = q->second.begin();
             r != q->second.end();
             ++r) {
          add_reconnected_cap(in, q->first, inodeno_t(r->second.snaprealm));
@@ -5353,7 +5353,7 @@ void MDCache::clean_open_file_lists()
 
 
 
-Capability* MDCache::rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconnect& icr, int frommds)
+Capability* MDCache::rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconnect& icr, mds_rank_t frommds)
 {
   dout(10) << "rejoin_import_cap for client." << client << " from mds." << frommds
           << " on " << *in << dendl;
@@ -5377,11 +5377,11 @@ void MDCache::export_remaining_imported_caps()
 
   stringstream warn_str;
 
-  for (map<inodeno_t,map<client_t,map<int,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
+  for (map<inodeno_t,map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> > >::iterator p = cap_imports.begin();
        p != cap_imports.end();
        ++p) {
     warn_str << " ino " << p->first << "\n";
-    for (map<client_t,map<int,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
+    for (map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> >::iterator q = p->second.begin();
        q != p->second.end();
        ++q) {
       Session *session = mds->sessionmap.get_session(entity_name_t::CLIENT(q->first.v));
@@ -5656,7 +5656,7 @@ void MDCache::rejoin_send_acks()
   dout(7) << "rejoin_send_acks" << dendl;
 
   // replicate stray
-  for (map<int, set<CInode*> >::iterator p = rejoin_unlinked_inodes.begin();
+  for (map<mds_rank_t, set<CInode*> >::iterator p = rejoin_unlinked_inodes.begin();
        p != rejoin_unlinked_inodes.end();
        ++p) {
     for (set<CInode*>::iterator q = p->second.begin();
@@ -5687,8 +5687,8 @@ void MDCache::rejoin_send_acks()
   rejoin_unlinked_inodes.clear();
   
   // send acks to everyone in the recovery set
-  map<int,MMDSCacheRejoin*> ack;
-  for (set<int>::iterator p = recovery_set.begin();
+  map<mds_rank_t,MMDSCacheRejoin*> ack;
+  for (set<mds_rank_t>::iterator p = recovery_set.begin();
        p != recovery_set.end();
        ++p) 
     ack[*p] = new MMDSCacheRejoin(MMDSCacheRejoin::OP_ACK);
@@ -5711,7 +5711,7 @@ void MDCache::rejoin_send_acks()
       dq.pop_front();
       
       // dir
-      for (map<int,unsigned>::iterator r = dir->replicas_begin();
+      for (map<mds_rank_t,unsigned>::iterator r = dir->replicas_begin();
           r != dir->replicas_end();
           ++r) {
        ack[r->first]->add_strong_dirfrag(dir->dirfrag(), ++r->second, dir->dir_rep);
@@ -5730,7 +5730,7 @@ void MDCache::rejoin_send_acks()
          in = dnl->get_inode();
 
        // dentry
-       for (map<int,unsigned>::iterator r = dn->replicas_begin();
+       for (map<mds_rank_t,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,
@@ -5747,7 +5747,7 @@ void MDCache::rejoin_send_acks()
        if (!in)
          continue;
 
-       for (map<int,unsigned>::iterator r = in->replicas_begin();
+       for (map<mds_rank_t,unsigned>::iterator r = in->replicas_begin();
             r != in->replicas_end();
             ++r) {
          ack[r->first]->add_inode_base(in);
@@ -5764,7 +5764,7 @@ void MDCache::rejoin_send_acks()
 
   // base inodes too
   if (root && root->is_auth()) 
-    for (map<int,unsigned>::iterator r = root->replicas_begin();
+    for (map<mds_rank_t,unsigned>::iterator r = root->replicas_begin();
         r != root->replicas_end();
         ++r) {
       ack[r->first]->add_inode_base(root);
@@ -5773,7 +5773,7 @@ void MDCache::rejoin_send_acks()
       ack[r->first]->add_inode_locks(root, ++r->second, bl);
     }
   if (myin)
-    for (map<int,unsigned>::iterator r = myin->replicas_begin();
+    for (map<mds_rank_t,unsigned>::iterator r = myin->replicas_begin();
         r != myin->replicas_end();
         ++r) {
       ack[r->first]->add_inode_base(myin);
@@ -5787,14 +5787,14 @@ void MDCache::rejoin_send_acks()
        p != rejoin_potential_updated_scatterlocks.end();
        ++p) {
     CInode *in = *p;
-    for (map<int,unsigned>::iterator r = in->replicas_begin();
+    for (map<mds_rank_t,unsigned>::iterator r = in->replicas_begin();
         r != in->replicas_end();
         ++r)
       ack[r->first]->add_inode_base(in);
   }
 
   // send acks
-  for (map<int,MMDSCacheRejoin*>::iterator p = ack.begin();
+  for (map<mds_rank_t,MMDSCacheRejoin*>::iterator p = ack.begin();
        p != ack.end();
        ++p) {
     ::encode(rejoin_imported_caps[p->first], p->second->imported_caps);
@@ -6135,7 +6135,7 @@ bool MDCache::trim(int max, int count)
     eval_stray(dn);
   }
 
-  map<int, MCacheExpire*> expiremap;
+  map<mds_rank_t, MCacheExpire*> expiremap;
   bool is_standby_replay = mds->is_standby_replay();
   int unexpirable = 0;
   list<CDentry*> unexpirables;
@@ -6190,10 +6190,10 @@ bool MDCache::trim(int max, int count)
   return true;
 }
 
-void MDCache::send_expire_messages(map<int, MCacheExpire*>& expiremap)
+void MDCache::send_expire_messages(map<mds_rank_t, MCacheExpire*>& expiremap)
 {
   // send expires
-  for (map<int, MCacheExpire*>::iterator it = expiremap.begin();
+  for (map<mds_rank_t, MCacheExpire*>::iterator it = expiremap.begin();
        it != expiremap.end();
        ++it) {
     if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN ||
@@ -6208,7 +6208,7 @@ void MDCache::send_expire_messages(map<int, MCacheExpire*>& expiremap)
 }
 
 
-bool MDCache::trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap)
+bool MDCache::trim_dentry(CDentry *dn, map<mds_rank_t, MCacheExpire*>& expiremap)
 {
   dout(12) << "trim_dentry " << *dn << dendl;
   
@@ -6260,10 +6260,10 @@ bool MDCache::trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap)
        !dn->get_dir()->get_inode()->is_stray())
       return true;
 
-    pair<int,int> auth = dn->authority();
+    mds_authority_t auth = dn->authority();
     
     for (int p=0; p<2; p++) {
-      int a = auth.first;
+      mds_rank_t a = auth.first;
       if (p) a = auth.second;
       if (a < 0 || (p == 1 && auth.second == auth.first)) break;
       if (mds->get_nodeid() == auth.second &&
@@ -6295,7 +6295,7 @@ bool MDCache::trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap)
 }
 
 
-void MDCache::trim_dirfrag(CDir *dir, CDir *con, map<int, MCacheExpire*>& expiremap)
+void MDCache::trim_dirfrag(CDir *dir, CDir *con, map<mds_rank_t, MCacheExpire*>& expiremap)
 {
   dout(15) << "trim_dirfrag " << *dir << dendl;
 
@@ -6309,7 +6309,7 @@ void MDCache::trim_dirfrag(CDir *dir, CDir *con, map<int, MCacheExpire*>& expire
   CInode *in = dir->get_inode();
 
   if (!dir->is_auth()) {
-    pair<int,int> auth = dir->authority();
+    mds_authority_t auth = dir->authority();
     
     // was this an auth delegation?  (if so, slightly modified container)
     dirfrag_t condf;
@@ -6322,7 +6322,7 @@ void MDCache::trim_dirfrag(CDir *dir, CDir *con, map<int, MCacheExpire*>& expire
     }
       
     for (int p=0; p<2; p++) {
-      int a = auth.first;
+      mds_rank_t a = auth.first;
       if (p) a = auth.second;
       if (a < 0 || (p == 1 && auth.second == auth.first)) break;
       if (mds->get_nodeid() == auth.second &&
@@ -6340,7 +6340,7 @@ void MDCache::trim_dirfrag(CDir *dir, CDir *con, map<int, MCacheExpire*>& expire
   in->close_dirfrag(dir->dirfrag().frag);
 }
 
-bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map<int, MCacheExpire*>& expiremap)
+bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map<mds_rank_t, MCacheExpire*>& expiremap)
 {
   dout(15) << "trim_inode " << *in << dendl;
   assert(in->get_num_ref() == 0);
@@ -6375,7 +6375,7 @@ bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map<int, MCacheExpi
        return true;
     }
   } else {
-    pair<int,int> auth = in->authority();
+    mds_authority_t auth = in->authority();
     
     dirfrag_t df;
     if (con)
@@ -6384,7 +6384,7 @@ bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map<int, MCacheExpi
       df = dirfrag_t(0,frag_t());   // must be a root or stray inode.
 
     for (int p=0; p<2; p++) {
-      int a = auth.first;
+      mds_rank_t a = auth.first;
       if (p) a = auth.second;
       if (a < 0 || (p == 1 && auth.second == auth.first)) break;
       if (con && mds->get_nodeid() == auth.second &&
@@ -6726,7 +6726,7 @@ void MDCache::standby_trim_segment(LogSegment *ls)
 /* This function DOES put the passed message before returning */
 void MDCache::handle_cache_expire(MCacheExpire *m)
 {
-  int from = m->get_from();
+  mds_rank_t from = mds_rank_t(m->get_from());
   
   dout(7) << "cache_expire from mds." << from << dendl;
 
@@ -6932,7 +6932,7 @@ void MDCache::handle_cache_expire(MCacheExpire *m)
 void MDCache::process_delayed_expire(CDir *dir)
 {
   dout(7) << "process_delayed_expire on " << *dir << dendl;
-  for (map<int,MCacheExpire*>::iterator p = delayed_expire[dir].begin();
+  for (map<mds_rank_t,MCacheExpire*>::iterator p = delayed_expire[dir].begin();
        p != delayed_expire[dir].end();
        ++p) 
     handle_cache_expire(p->second);
@@ -6942,14 +6942,14 @@ void MDCache::process_delayed_expire(CDir *dir)
 void MDCache::discard_delayed_expire(CDir *dir)
 {
   dout(7) << "discard_delayed_expire on " << *dir << dendl;
-  for (map<int,MCacheExpire*>::iterator p = delayed_expire[dir].begin();
+  for (map<mds_rank_t,MCacheExpire*>::iterator p = delayed_expire[dir].begin();
        p != delayed_expire[dir].end();
        ++p) 
     p->second->put();
   delayed_expire.erase(dir);  
 }
 
-void MDCache::inode_remove_replica(CInode *in, int from, bool rejoin,
+void MDCache::inode_remove_replica(CInode *in, mds_rank_t from, bool rejoin,
                                   set<SimpleLock *>& gather_locks)
 {
   in->remove_replica(from);
@@ -6972,7 +6972,7 @@ void MDCache::inode_remove_replica(CInode *in, int from, bool rejoin,
   if (in->nestlock.remove_replica(from, rejoin)) gather_locks.insert(&in->nestlock);
 }
 
-void MDCache::dentry_remove_replica(CDentry *dn, int from, set<SimpleLock *>& gather_locks)
+void MDCache::dentry_remove_replica(CDentry *dn, mds_rank_t from, set<SimpleLock *>& gather_locks)
 {
   dn->remove_replica(from);
 
@@ -7171,7 +7171,7 @@ bool MDCache::shutdown_pass()
     int max = 5; // throttle shutdown exports.. hack!
     for (list<CDir*>::iterator p = ls.begin(); p != ls.end(); ++p) {
       CDir *dir = *p;
-      int dest = dir->get_inode()->authority().first;
+      mds_rank_t dest = dir->get_inode()->authority().first;
       if (dest > 0 && !mds->mdsmap->is_active(dest))
        dest = 0;
       dout(7) << "sending " << *dir << " back to mds." << dest << dendl;
@@ -7290,7 +7290,7 @@ bool MDCache::shutdown_export_strays()
       // FIXME: we'll deadlock if a rename fails.
       if (exported_strays.count(dnl->get_inode()->ino()) == 0) {
        exported_strays.insert(dnl->get_inode()->ino());
-       migrate_stray(dn, 0);  // send to root!
+       migrate_stray(dn, mds_rank_t(0));  // send to root!
       } else {
        dout(10) << "already exporting " << *dn << dendl;
       }
@@ -7710,7 +7710,7 @@ int MDCache::path_traverse(MDRequestRef& mdr, Message *req, MDSInternalContextBa
       }
     } else {
       // dirfrag/dentry is not mine.
-      pair<int,int> dauth = curdir->authority();
+      mds_authority_t dauth = curdir->authority();
 
       if (forward &&
          snapid && mdr && mdr->client_request &&
@@ -7854,7 +7854,7 @@ void MDCache::open_remote_dirfrag(CInode *diri, frag_t approxfg, MDSInternalCont
   assert(!diri->is_auth());
   assert(diri->get_dirfrag(approxfg) == 0);
 
-  int auth = diri->authority().first;
+  mds_rank_t auth = diri->authority().first;
 
   if (mds->mdsmap->get_state(auth) >= MDSMap::STATE_REJOIN) {
     discover_dir_frag(diri, approxfg, fin);
@@ -7971,6 +7971,7 @@ struct C_MDC_OpenInoTraverseDir : public MDCacheContext {
   C_MDC_OpenInoTraverseDir(MDCache *c, inodeno_t i) : MDCacheContext(c), ino(i) {}
   void finish(int r) {
     assert(mdcache->opening_inodes.count(ino));
+    assert(r >= 0);
     mdcache->_open_ino_traverse_dir(ino, mdcache->opening_inodes[ino], r);
   }
 };
@@ -8066,9 +8067,10 @@ void MDCache::_open_ino_parent_opened(inodeno_t ino, int ret)
     _open_ino_traverse_dir(ino, info, 0);
   } else {
     if (ret >= 0) {
+      mds_rank_t checked_rank;
       info.check_peers = true;
-      info.auth_hint = ret;
-      info.checked.erase(ret);
+      info.auth_hint = checked_rank;
+      info.checked.erase(checked_rank);
     }
     do_open_ino(ino, info, ret);
   }
@@ -8098,7 +8100,7 @@ void MDCache::_open_ino_traverse_dir(inodeno_t ino, open_ino_info_t& info, int r
     return;
   }
 
-  int hint = info.auth_hint;
+  mds_rank_t hint = info.auth_hint;
   ret = open_ino_traverse_dir(ino, NULL, info.ancestors,
                              info.discover, info.want_xlocked, &hint);
   if (ret > 0)
@@ -8117,7 +8119,7 @@ void MDCache::_open_ino_fetch_dir(inodeno_t ino, MMDSOpenIno *m, CDir *dir)
 
 int MDCache::open_ino_traverse_dir(inodeno_t ino, MMDSOpenIno *m,
                                   vector<inode_backpointer_t>& ancestors,
-                                  bool discover, bool want_xlocked, int *hint)
+                                  bool discover, bool want_xlocked, mds_rank_t *hint)
 {
   dout(10) << "open_ino_traverse_dir ino " << ino << " " << ancestors << dendl;
   int err = 0;
@@ -8225,7 +8227,7 @@ void MDCache::do_open_ino(inodeno_t ino, open_ino_info_t& info, int err)
   if (err < 0) {
     info.checked.clear();
     info.checked.insert(mds->get_nodeid());
-    info.checking = -1;
+    info.checking = MDS_RANK_NONE;
     info.check_peers = true;
     info.fetch_backtrace = true;
     if (info.discover) {
@@ -8236,7 +8238,7 @@ void MDCache::do_open_ino(inodeno_t ino, open_ino_info_t& info, int err)
 
   if (info.check_peers) {
     info.check_peers = false;
-    info.checking = -1;
+    info.checking = MDS_RANK_NONE;
     do_open_ino_peer(ino, info);
   } else if (info.fetch_backtrace) {
     info.check_peers = true;
@@ -8258,7 +8260,7 @@ void MDCache::do_open_ino(inodeno_t ino, open_ino_info_t& info, int err)
 
 void MDCache::do_open_ino_peer(inodeno_t ino, open_ino_info_t& info)
 {
-  set<int> all, active;
+  set<mds_rank_t> all, active;
   mds->mdsmap->get_mds_set(all);
   mds->mdsmap->get_clientreplay_or_active_or_stopping_mds_set(active);
   if (mds->get_state() == MDSMap::STATE_REJOIN)
@@ -8267,14 +8269,14 @@ void MDCache::do_open_ino_peer(inodeno_t ino, open_ino_info_t& info)
   dout(10) << "do_open_ino_peer " << ino << " active " << active
           << " all " << all << " checked " << info.checked << dendl;
 
-  int peer = -1;
+  mds_rank_t peer = MDS_RANK_NONE;
   if (info.auth_hint >= 0) {
     if (active.count(info.auth_hint)) {
       peer = info.auth_hint;
-      info.auth_hint = -1;
+      info.auth_hint = MDS_RANK_NONE;
     }
   } else {
-    for (set<int>::iterator p = active.begin(); p != active.end(); ++p)
+    for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p)
       if (*p != mds->get_nodeid() && info.checked.count(*p) == 0) {
        peer = *p;
        break;
@@ -8302,7 +8304,7 @@ void MDCache::handle_open_ino(MMDSOpenIno *m)
   CInode *in = get_inode(ino);
   if (in) {
     dout(10) << " have " << *in << dendl;
-    reply = new MMDSOpenInoReply(m->get_tid(), ino, 0);
+    reply = new MMDSOpenInoReply(m->get_tid(), ino, mds_rank_t(0));
     if (in->is_auth()) {
       touch_inode(in);
       while (1) {
@@ -8318,7 +8320,7 @@ void MDCache::handle_open_ino(MMDSOpenIno *m)
       reply->hint = in->authority().first;
     }
   } else {
-    int hint = -1;
+    mds_rank_t hint = MDS_RANK_NONE;
     int ret = open_ino_traverse_dir(ino, m, m->ancestors, false, false, &hint);
     if (ret > 0)
       return;
@@ -8333,12 +8335,12 @@ void MDCache::handle_open_ino_reply(MMDSOpenInoReply *m)
   dout(10) << "handle_open_ino_reply " << *m << dendl;
 
   inodeno_t ino = m->ino;
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
   if (opening_inodes.count(ino)) {
     open_ino_info_t& info = opening_inodes[ino];
 
     if (info.checking == from)
-       info.checking = -1;
+       info.checking = MDS_RANK_NONE;
     info.checked.insert(from);
 
     CInode *in = get_inode(ino);
@@ -8371,7 +8373,7 @@ void MDCache::handle_open_ino_reply(MMDSOpenInoReply *m)
   m->put();
 }
 
-void MDCache::kick_open_ino_peers(int who)
+void MDCache::kick_open_ino_peers(mds_rank_t who)
 {
   dout(10) << "kick_open_ino_peers mds." << who << dendl;
 
@@ -8383,7 +8385,7 @@ void MDCache::kick_open_ino_peers(int who)
       dout(10) << "  kicking ino " << p->first << " who was checking mds." << who << dendl;
       info.checking = -1;
       do_open_ino_peer(p->first, info);
-    } else if (info.checking == -1) {
+    } else if (info.checking == MDS_RANK_NONE) {
       dout(10) << "  kicking ino " << p->first << " who was waiting" << dendl;
       do_open_ino_peer(p->first, info);
     }
@@ -8439,7 +8441,7 @@ void MDCache::open_ino(inodeno_t ino, int64_t pool, MDSInternalContextBase* fin,
   - traverse path
 
  */
-void MDCache::find_ino_peers(inodeno_t ino, MDSInternalContextBase *c, int hint)
+void MDCache::find_ino_peers(inodeno_t ino, MDSInternalContextBase *c, mds_rank_t hint)
 {
   dout(5) << "find_ino_peers " << ino << " hint " << hint << dendl;
   assert(!have_inode(ino));
@@ -8456,7 +8458,7 @@ void MDCache::find_ino_peers(inodeno_t ino, MDSInternalContextBase *c, int hint)
 
 void MDCache::_do_find_ino_peer(find_ino_peer_info_t& fip)
 {
-  set<int> all, active;
+  set<mds_rank_t> all, active;
   mds->mdsmap->get_mds_set(all);
   mds->mdsmap->get_clientreplay_or_active_or_stopping_mds_set(active);
 
@@ -8465,19 +8467,19 @@ void MDCache::_do_find_ino_peer(find_ino_peer_info_t& fip)
           << " checked " << fip.checked
           << dendl;
     
-  int m = -1;
+  mds_rank_t m = MDS_RANK_NONE;
   if (fip.hint >= 0) {
     m = fip.hint;
-    fip.hint = -1;
+    fip.hint = MDS_RANK_NONE;
   } else {
-    for (set<int>::iterator p = active.begin(); p != active.end(); ++p)
+    for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p)
       if (*p != mds->whoami &&
          fip.checked.count(*p) == 0) {
        m = *p;
        break;
       }
   }
-  if (m < 0) {
+  if (m == MDS_RANK_NONE) {
     if (all.size() > active.size()) {
       dout(10) << "_do_find_ino_peer waiting for more peers to be active" << dendl;
     } else {
@@ -8521,7 +8523,7 @@ void MDCache::handle_find_ino_reply(MMDSFindInoReply *m)
       return;
     }
 
-    int from = m->get_source().num();
+    mds_rank_t from = mds_rank_t(m->get_source().num());
     if (fip.checking == from)
       fip.checking = -1;
     fip.checked.insert(from);
@@ -8547,7 +8549,7 @@ void MDCache::handle_find_ino_reply(MMDSFindInoReply *m)
   m->put();
 }
 
-void MDCache::kick_find_ino_peers(int who)
+void MDCache::kick_find_ino_peers(mds_rank_t who)
 {
   // find_ino_peers requests we should move on from
   for (map<ceph_tid_t,find_ino_peer_info_t>::iterator p = find_ino_peer.begin();
@@ -8678,7 +8680,7 @@ void MDCache::request_finish(MDRequestRef& mdr)
 }
 
 
-void MDCache::request_forward(MDRequestRef& mdr, int who, int port)
+void MDCache::request_forward(MDRequestRef& mdr, mds_rank_t who, int port)
 {
   mdr->mark_event("forwarding request");
   if (mdr->client_request->get_source().is_client()) {
@@ -8727,7 +8729,7 @@ void MDCache::request_drop_foreign_locks(MDRequestRef& mdr)
 
   // clean up slaves
   //  (will implicitly drop remote dn pins)
-  for (set<int>::iterator p = mdr->more()->slaves.begin();
+  for (set<mds_rank_t>::iterator p = mdr->more()->slaves.begin();
        p != mdr->more()->slaves.end();
        ++p) {
     MMDSSlaveRequest *r = new MMDSSlaveRequest(mdr->reqid, mdr->attempt,
@@ -8758,7 +8760,7 @@ void MDCache::request_drop_foreign_locks(MDRequestRef& mdr)
     }
   }
 
-  map<SimpleLock*, int>::iterator q = mdr->remote_wrlocks.begin();
+  map<SimpleLock*, mds_rank_t>::iterator q = mdr->remote_wrlocks.begin();
   while (q != mdr->remote_wrlocks.end()) {
     dout(10) << "request_drop_foreign_locks forgetting remote_wrlock " << *q->first
             << " on mds." << q->second
@@ -9408,7 +9410,7 @@ void MDCache::reintegrate_stray(CDentry *straydn, CDentry *rdn)
 }
  
 
-void MDCache::migrate_stray(CDentry *dn, int to)
+void MDCache::migrate_stray(CDentry *dn, mds_rank_t to)
 {
   CInode *in = dn->get_linkage()->get_inode();
   assert(in);
@@ -9458,7 +9460,7 @@ void MDCache::_send_discover(discover_info_t& d)
 
 void MDCache::discover_base_ino(inodeno_t want_ino,
                                MDSInternalContextBase *onfinish,
-                               int from) 
+                               mds_rank_t from) 
 {
   dout(7) << "discover_base_ino " << want_ino << " from mds." << from << dendl;
   if (waiting_for_base_ino[from].count(want_ino) == 0) {
@@ -9473,7 +9475,7 @@ void MDCache::discover_base_ino(inodeno_t want_ino,
 void MDCache::discover_dir_frag(CInode *base,
                                frag_t approx_fg,
                                MDSInternalContextBase *onfinish,
-                               int from)
+                               mds_rank_t from)
 {
   if (from < 0)
     from = base->authority().first;
@@ -9498,8 +9500,8 @@ struct C_MDC_RetryDiscoverPath : public MDCacheContext {
   CInode *base;
   snapid_t snapid;
   filepath path;
-  int from;
-  C_MDC_RetryDiscoverPath(MDCache *c, CInode *b, snapid_t s, filepath &p, int f) :
+  mds_rank_t from;
+  C_MDC_RetryDiscoverPath(MDCache *c, CInode *b, snapid_t s, filepath &p, mds_rank_t f) :
     MDCacheContext(c), base(b), snapid(s), path(p), from(f)  {}
   void finish(int r) {
     mdcache->discover_path(base, snapid, path, 0, from);
@@ -9511,7 +9513,7 @@ void MDCache::discover_path(CInode *base,
                            filepath want_path,
                            MDSInternalContextBase *onfinish,
                            bool want_xlocked,
-                           int from)
+                           mds_rank_t from)
 {
   if (from < 0)
     from = base->authority().first;
@@ -9568,7 +9570,7 @@ void MDCache::discover_path(CDir *base,
                            MDSInternalContextBase *onfinish,
                            bool want_xlocked)
 {
-  int from = base->authority().first;
+  mds_rank_t from = base->authority().first;
 
   dout(7) << "discover_path " << base->dirfrag() << " " << want_path << " snap " << snap << " from mds." << from
          << (want_xlocked ? " want_xlocked":"")
@@ -9604,7 +9606,7 @@ void MDCache::discover_path(CDir *base,
     base->add_dentry_waiter(want_path[0], snap, onfinish);
 }
 
-void MDCache::kick_discovers(int who)
+void MDCache::kick_discovers(mds_rank_t who)
 {
   for (map<ceph_tid_t,discover_info_t>::iterator p = discovers.begin();
        p != discovers.end();
@@ -9619,13 +9621,13 @@ void MDCache::kick_discovers(int who)
 /* This function DOES put the passed message before returning */
 void MDCache::handle_discover(MDiscover *dis) 
 {
-  int whoami = mds->get_nodeid();
-  int from = dis->get_source_inst().name._num;
+  mds_rank_t whoami = mds->get_nodeid();
+  mds_rank_t from = mds_rank_t(dis->get_source_inst().name._num);
 
   assert(from != whoami);
 
   if (mds->get_state() <= MDSMap::STATE_REJOIN) {
-    int from = dis->get_source().num();
+    mds_rank_t from = mds_rank_t(dis->get_source().num());
     // proceed if requester is in the REJOIN stage, the request is from parallel_fetch().
     // delay processing request from survivor because we may not yet choose lock states.
     if (mds->get_state() < MDSMap::STATE_REJOIN ||
@@ -9914,7 +9916,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
     dout(7) << " flag error, dentry = " << m->get_error_dentry() << dendl;
 
   list<MDSInternalContextBase*> finished, error;
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   // starting point
   CInode *cur = get_inode(m->get_base_ino());
@@ -9958,7 +9960,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
     frag_t fg;
     CDir *curdir = 0;
     if (next == MDiscoverReply::DIR) {
-      curdir = add_replica_dir(p, cur, m->get_source().num(), finished);
+      curdir = add_replica_dir(p, cur, mds_rank_t(m->get_source().num()), finished);
       if (cur->ino() == m->get_base_ino() && curdir->get_frag() != m->get_base_dir_frag()) {
        assert(m->get_wanted_base_dir());
        cur->take_dir_waiting(m->get_base_dir_frag(), finished);
@@ -9993,7 +9995,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
     // not a dir.
     cur->take_waiting(CInode::WAIT_DIR, error);
   } else if (m->is_flag_error_dir() || m->get_dir_auth_hint() != CDIR_AUTH_UNKNOWN) {
-    int who = m->get_dir_auth_hint();
+    mds_rank_t who = m->get_dir_auth_hint();
     if (who == mds->get_nodeid()) who = -1;
     if (who >= 0)
       dout(7) << " dir_auth_hint is " << m->get_dir_auth_hint() << dendl;
@@ -10043,7 +10045,7 @@ void MDCache::handle_discover_reply(MDiscoverReply *m)
 // ----------------------------
 // REPLICAS
 
-CDir *MDCache::add_replica_dir(bufferlist::iterator& p, CInode *diri, int from,
+CDir *MDCache::add_replica_dir(bufferlist::iterator& p, CInode *diri, mds_rank_t from,
                               list<MDSInternalContextBase*>& finished)
 {
   dirfrag_t df;
@@ -10085,7 +10087,7 @@ CDir *MDCache::add_replica_dir(bufferlist::iterator& p, CInode *diri, int from,
   return dir;
 }
 
-CDir *MDCache::forge_replica_dir(CInode *diri, frag_t fg, int from)
+CDir *MDCache::forge_replica_dir(CInode *diri, frag_t fg, mds_rank_t from)
 {
   assert(mds->mdsmap->get_state(from) < MDSMap::STATE_REJOIN);
   
@@ -10158,7 +10160,7 @@ CInode *MDCache::add_replica_inode(bufferlist::iterator& p, CDentry *dn, list<MD
 }
 
  
-void MDCache::replicate_stray(CDentry *straydn, int who, bufferlist& bl)
+void MDCache::replicate_stray(CDentry *straydn, mds_rank_t who, bufferlist& bl)
 {
   replicate_inode(get_myin(), who, bl);
   replicate_dir(straydn->get_dir()->inode->get_parent_dn()->get_dir(), who, bl);
@@ -10168,7 +10170,7 @@ void MDCache::replicate_stray(CDentry *straydn, int who, bufferlist& bl)
   replicate_dentry(straydn, who, bl);
 }
    
-CDentry *MDCache::add_replica_stray(bufferlist &bl, int from)
+CDentry *MDCache::add_replica_stray(bufferlist &bl, mds_rank_t from)
 {
   list<MDSInternalContextBase*> finished;
   bufferlist::iterator p = bl.begin();
@@ -10190,11 +10192,11 @@ int MDCache::send_dir_updates(CDir *dir, bool bcast)
 {
   // this is an FYI, re: replication
 
-  set<int> who;
+  set<mds_rank_t> who;
   if (bcast) {
     mds->get_mds_map()->get_active_mds_set(who);
   } else {
-    for (map<int,unsigned>::iterator p = dir->replicas_begin();
+    for (map<mds_rank_t,unsigned>::iterator p = dir->replicas_begin();
         p != dir->replicas_end();
         ++p)
       who.insert(p->first);
@@ -10205,8 +10207,8 @@ int MDCache::send_dir_updates(CDir *dir, bool bcast)
   filepath path;
   dir->inode->make_path(path);
 
-  int whoami = mds->get_nodeid();
-  for (set<int>::iterator it = who.begin();
+  mds_rank_t whoami = mds->get_nodeid();
+  for (set<mds_rank_t>::iterator it = who.begin();
        it != who.end();
        ++it) {
     if (*it == whoami) continue;
@@ -10275,7 +10277,7 @@ void MDCache::send_dentry_link(CDentry *dn, MDRequestRef& mdr)
   dout(7) << "send_dentry_link " << *dn << dendl;
 
   CDir *subtree = get_subtree_root(dn->get_dir());
-  for (map<int,unsigned>::iterator p = dn->replicas_begin();
+  for (map<mds_rank_t,unsigned>::iterator p = dn->replicas_begin();
        p != dn->replicas_end(); 
        ++p) {
     // don't tell (rename) witnesses; they already know
@@ -10356,11 +10358,11 @@ void MDCache::send_dentry_unlink(CDentry *dn, CDentry *straydn, MDRequestRef& md
 {
   dout(10) << "send_dentry_unlink " << *dn << dendl;
   // share unlink news with replicas
-  map<int,unsigned> replicas;
+  map<mds_rank_t,unsigned> replicas;
   replicas.insert(dn->replicas_begin(), dn->replicas_end());
   if (straydn)
     replicas.insert(straydn->replicas_begin(), straydn->replicas_end());
-  for (map<int,unsigned>::iterator it = replicas.begin();
+  for (map<mds_rank_t,unsigned>::iterator it = replicas.begin();
        it != replicas.end();
        ++it) {
     // don't tell (rmdir) witnesses; they already know
@@ -10385,7 +10387,7 @@ void MDCache::handle_dentry_unlink(MDentryUnlink *m)
   // straydn
   CDentry *straydn = NULL;
   if (m->straybl.length())
-    straydn = add_replica_stray(m->straybl, m->get_source().num());
+    straydn = add_replica_stray(m->straybl, mds_rank_t(m->get_source().num()));
 
   CDir *dir = get_dirfrag(m->get_dirfrag());
   if (!dir) {
@@ -10437,7 +10439,7 @@ void MDCache::handle_dentry_unlink(MDentryUnlink *m)
   if (straydn) {
     assert(straydn->get_num_ref() == 0);
     assert(straydn->get_linkage()->is_null());
-    map<int, MCacheExpire*> expiremap;
+    map<mds_rank_t, MCacheExpire*> expiremap;
     trim_dentry(straydn, expiremap);
     send_expire_messages(expiremap);
   }
@@ -11182,7 +11184,7 @@ void MDCache::_fragment_stored(MDRequestRef& mdr)
 
   // tell peers
   CDir *first = *info.resultfrags.begin();
-  for (map<int,unsigned>::iterator p = first->replicas_begin();
+  for (map<mds_rank_t,unsigned>::iterator p = first->replicas_begin();
        p != first->replica_map.end();
        ++p) {
     if (mds->mdsmap->get_state(p->first) < MDSMap::STATE_REJOIN ||
@@ -11327,7 +11329,7 @@ void MDCache::handle_fragment_notify(MMDSFragmentNotify *notify)
     // add new replica dirs values
     bufferlist::iterator p = notify->basebl.begin();
     while (!p.end())
-      add_replica_dir(p, diri, notify->get_source().num(), waiters);
+      add_replica_dir(p, diri, mds_rank_t(notify->get_source().num()), waiters);
 
     mds->queue_waiters(waiters);
   } else {
@@ -11584,9 +11586,9 @@ void MDCache::show_subtrees(int dbl)
 
     char s[10];
     if (dir->get_dir_auth().second == CDIR_AUTH_UNKNOWN)
-      snprintf(s, sizeof(s), "%2d   ", dir->get_dir_auth().first);
+      snprintf(s, sizeof(s), "%2d   ", int(dir->get_dir_auth().first));
     else
-      snprintf(s, sizeof(s), "%2d,%2d", dir->get_dir_auth().first, dir->get_dir_auth().second);
+      snprintf(s, sizeof(s), "%2d,%2d", int(dir->get_dir_auth().first), int(dir->get_dir_auth().second));
     
     // print
     dout(dbl) << indent << "|_" << pad << s << " " << auth << *dir << dendl;
@@ -11663,7 +11665,7 @@ void MDCache::dump_cache(const char *fn)
   int r;
   char deffn[200];
   if (!fn) {
-    snprintf(deffn, sizeof(deffn), "cachedump.%d.mds%d", (int)mds->mdsmap->get_epoch(), mds->get_nodeid());
+    snprintf(deffn, sizeof(deffn), "cachedump.%d.mds%d", (int)mds->mdsmap->get_epoch(), int(mds->get_nodeid()));
     fn = deffn;
   }
 
index 9f02b3ba31fe2444ee412c42942d09cfb36a644e..de12ced545679e82a5ef46a82c43d891e1d9bba9 100644 (file)
@@ -134,7 +134,7 @@ public:
   // -- discover --
   struct discover_info_t {
     ceph_tid_t tid;
-    int mds;
+    mds_rank_t mds;
     inodeno_t ino;
     frag_t frag;
     snapid_t snap;
@@ -149,7 +149,7 @@ public:
   ceph_tid_t discover_last_tid;
 
   void _send_discover(discover_info_t& dis);
-  discover_info_t& _create_discover(int mds) {
+  discover_info_t& _create_discover(mds_rank_t mds) {
     ceph_tid_t t = ++discover_last_tid;
     discover_info_t& d = discovers[t];
     d.tid = t;
@@ -160,14 +160,14 @@ public:
   // waiters
   map<int, map<inodeno_t, list<MDSInternalContextBase*> > > waiting_for_base_ino;
 
-  void discover_base_ino(inodeno_t want_ino, MDSInternalContextBase *onfinish, int from=-1);
+  void discover_base_ino(inodeno_t want_ino, MDSInternalContextBase *onfinish, mds_rank_t from=MDS_RANK_NONE);
   void discover_dir_frag(CInode *base, frag_t approx_fg, MDSInternalContextBase *onfinish,
-                        int from=-1);
+                        mds_rank_t from=MDS_RANK_NONE);
   void discover_path(CInode *base, snapid_t snap, filepath want_path, MDSInternalContextBase *onfinish,
-                    bool want_xlocked=false, int from=-1);
+                    bool want_xlocked=false, mds_rank_t from=MDS_RANK_NONE);
   void discover_path(CDir *base, snapid_t snap, filepath want_path, MDSInternalContextBase *onfinish,
                     bool want_xlocked=false);
-  void kick_discovers(int who);  // after a failure.
+  void kick_discovers(mds_rank_t who);  // after a failure.
 
 
 public:
@@ -187,17 +187,17 @@ protected:
 public:
   bool is_subtrees() { return !subtrees.empty(); }
   void list_subtrees(list<CDir*>& ls);
-  void adjust_subtree_auth(CDir *root, pair<int,int> auth, bool do_eval=true);
-  void adjust_subtree_auth(CDir *root, int a, int b=CDIR_AUTH_UNKNOWN, bool do_eval=true) {
-    adjust_subtree_auth(root, pair<int,int>(a,b), do_eval); 
+  void adjust_subtree_auth(CDir *root, mds_authority_t auth, bool do_eval=true);
+  void adjust_subtree_auth(CDir *root, mds_rank_t a, mds_rank_t b=CDIR_AUTH_UNKNOWN, bool do_eval=true) {
+    adjust_subtree_auth(root, mds_authority_t(a,b), do_eval); 
   }
-  void adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, pair<int,int> auth);
-  void adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, int a) {
-    adjust_bounded_subtree_auth(dir, bounds, pair<int,int>(a, CDIR_AUTH_UNKNOWN));
+  void adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, mds_authority_t auth);
+  void adjust_bounded_subtree_auth(CDir *dir, set<CDir*>& bounds, mds_rank_t a) {
+    adjust_bounded_subtree_auth(dir, bounds, mds_authority_t(a, CDIR_AUTH_UNKNOWN));
   }
-  void adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bounds, pair<int,int> auth);
-  void adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bounds, int a) {
-    adjust_bounded_subtree_auth(dir, bounds, pair<int,int>(a, CDIR_AUTH_UNKNOWN));
+  void adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bounds, mds_authority_t auth);
+  void adjust_bounded_subtree_auth(CDir *dir, vector<dirfrag_t>& bounds, mds_rank_t a) {
+    adjust_bounded_subtree_auth(dir, bounds, mds_authority_t(a, CDIR_AUTH_UNKNOWN));
   }
   void map_dirfrag_set(list<dirfrag_t>& dfs, set<CDir*>& result);
   void try_subtree_merge(CDir *root);
@@ -233,7 +233,7 @@ public:
   
 protected:
   // delayed cache expire
-  map<CDir*, map<int, MCacheExpire*> > delayed_expire; // subtree root -> expire msg
+  map<CDir*, map<mds_rank_t, MCacheExpire*> > delayed_expire; // subtree root -> expire msg
 
 
   // -- requests --
@@ -252,7 +252,7 @@ public:
   MDRequestRef request_get(metareqid_t rid);
   void request_pin_ref(MDRequestRef& r, CInode *ref, vector<CDentry*>& trace);
   void request_finish(MDRequestRef& mdr);
-  void request_forward(MDRequestRef& mdr, int mds, int port=0);
+  void request_forward(MDRequestRef& mdr, mds_rank_t mds, int port=0);
   void dispatch_request(MDRequestRef& mdr);
   void request_drop_foreign_locks(MDRequestRef& mdr);
   void request_drop_non_rdlocks(MDRequestRef& r);
@@ -283,7 +283,7 @@ public:
                                snapid_t follows=CEPH_NOSNAP);
 
   // slaves
-  void add_uncommitted_master(metareqid_t reqid, LogSegment *ls, set<int> &slaves, bool safe=false) {
+  void add_uncommitted_master(metareqid_t reqid, LogSegment *ls, set<mds_rank_t> &slaves, bool safe=false) {
     uncommitted_masters[reqid].ls = ls;
     uncommitted_masters[reqid].slaves = slaves;
     uncommitted_masters[reqid].safe = safe;
@@ -294,34 +294,34 @@ public:
   void log_master_commit(metareqid_t reqid);
   void logged_master_update(metareqid_t reqid);
   void _logged_master_commit(metareqid_t reqid);
-  void committed_master_slave(metareqid_t r, int from);
+  void committed_master_slave(metareqid_t r, mds_rank_t from);
   void finish_committed_masters();
 
-  void _logged_slave_commit(int from, metareqid_t reqid);
+  void _logged_slave_commit(mds_rank_t from, metareqid_t reqid);
 
   // -- recovery --
 protected:
-  set<int> recovery_set;
+  set<mds_rank_t> recovery_set;
 
 public:
-  void set_recovery_set(set<int>& s);
-  void handle_mds_failure(int who);
-  void handle_mds_recovery(int who);
+  void set_recovery_set(set<mds_rank_t>& s);
+  void handle_mds_failure(mds_rank_t who);
+  void handle_mds_recovery(mds_rank_t who);
 
 protected:
   // [resolve]
   // from EImportStart w/o EImportFinish during journal replay
   map<dirfrag_t, vector<dirfrag_t> >            my_ambiguous_imports;  
   // from MMDSResolves
-  map<int, map<dirfrag_t, vector<dirfrag_t> > > other_ambiguous_imports;  
+  map<mds_rank_t, map<dirfrag_t, vector<dirfrag_t> > > other_ambiguous_imports;  
 
-  map<int, map<metareqid_t, MDSlaveUpdate*> > uncommitted_slave_updates;  // slave: for replay.
+  map<mds_rank_t, map<metareqid_t, MDSlaveUpdate*> > uncommitted_slave_updates;  // slave: for replay.
   map<CInode*, int> uncommitted_slave_rename_olddir;  // slave: preserve the non-auth dir until seeing commit.
   map<CInode*, int> uncommitted_slave_unlink;  // slave: preserve the unlinked inode until seeing commit.
 
   // track master requests whose slaves haven't acknowledged commit
   struct umaster {
-    set<int> slaves;
+    set<mds_rank_t> slaves;
     LogSegment *ls;
     list<MDSInternalContextBase*> waiters;
     bool safe;
@@ -338,40 +338,40 @@ protected:
   friend class ECommitted;
 
   bool resolves_pending;
-  set<int> resolve_gather;     // nodes i need resolves from
-  set<int> resolve_ack_gather; // nodes i need a resolve_ack from
-  map<metareqid_t, int> need_resolve_rollback;  // rollbacks i'm writing to the journal
-  map<int, MMDSResolve*> delayed_resolve;
+  set<mds_rank_t> resolve_gather;      // nodes i need resolves from
+  set<mds_rank_t> resolve_ack_gather;  // nodes i need a resolve_ack from
+  map<metareqid_t, mds_rank_t> need_resolve_rollback;  // rollbacks i'm writing to the journal
+  map<mds_rank_t, MMDSResolve*> delayed_resolve;
   
   void handle_resolve(MMDSResolve *m);
   void handle_resolve_ack(MMDSResolveAck *m);
   void process_delayed_resolve();
-  void discard_delayed_resolve(int who);
+  void discard_delayed_resolve(mds_rank_t who);
   void maybe_resolve_finish();
   void disambiguate_imports();
   void trim_unlinked_inodes();
-  void add_uncommitted_slave_update(metareqid_t reqid, int master, MDSlaveUpdate*);
-  void finish_uncommitted_slave_update(metareqid_t reqid, int master);
-  MDSlaveUpdate* get_uncommitted_slave_update(metareqid_t reqid, int master);
+  void add_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master, MDSlaveUpdate*);
+  void finish_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master);
+  MDSlaveUpdate* get_uncommitted_slave_update(metareqid_t reqid, mds_rank_t master);
 public:
   void recalc_auth_bits(bool replay);
   void remove_inode_recursive(CInode *in);
 
-  bool is_ambiguous_slave_update(metareqid_t reqid, int master) {
+  bool is_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) {
     return ambiguous_slave_updates.count(master) &&
           ambiguous_slave_updates[master].count(reqid);
   }
-  void add_ambiguous_slave_update(metareqid_t reqid, int master) {
+  void add_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) {
     ambiguous_slave_updates[master].insert(reqid);
   }
-  void remove_ambiguous_slave_update(metareqid_t reqid, int master) {
+  void remove_ambiguous_slave_update(metareqid_t reqid, mds_rank_t master) {
     assert(ambiguous_slave_updates[master].count(reqid));
     ambiguous_slave_updates[master].erase(reqid);
     if (ambiguous_slave_updates[master].empty())
       ambiguous_slave_updates.erase(master);
   }
 
-  void add_rollback(metareqid_t reqid, int master) {
+  void add_rollback(metareqid_t reqid, mds_rank_t master) {
     need_resolve_rollback[reqid] = master;
   }
   void finish_rollback(metareqid_t reqid);
@@ -407,17 +407,17 @@ public:
 protected:
   // [rejoin]
   bool rejoins_pending;
-  set<int> rejoin_gather;      // nodes from whom i need a rejoin
-  set<int> rejoin_sent;        // nodes i sent a rejoin to
-  set<int> rejoin_ack_gather;  // nodes from whom i need a rejoin ack
-  map<int,map<inodeno_t,map<client_t,Capability::Import> > > rejoin_imported_caps;
-  map<inodeno_t,pair<int,map<client_t,Capability::Export> > > rejoin_slave_exports;
+  set<mds_rank_t> rejoin_gather;      // nodes from whom i need a rejoin
+  set<mds_rank_t> rejoin_sent;        // nodes i sent a rejoin to
+  set<mds_rank_t> rejoin_ack_gather;  // nodes from whom i need a rejoin ack
+  map<mds_rank_t,map<inodeno_t,map<client_t,Capability::Import> > > rejoin_imported_caps;
+  map<inodeno_t,pair<mds_rank_t,map<client_t,Capability::Export> > > rejoin_slave_exports;
   map<client_t,entity_inst_t> rejoin_client_map;
 
   map<inodeno_t,map<client_t,ceph_mds_cap_reconnect> > cap_exports; // ino -> client -> capex
-  map<inodeno_t,int> cap_export_targets; // ino -> auth mds
+  map<inodeno_t,mds_rank_t> cap_export_targets; // ino -> auth mds
 
-  map<inodeno_t,map<client_t,map<int,ceph_mds_cap_reconnect> > > cap_imports;  // ino -> client -> frommds -> capex
+  map<inodeno_t,map<client_t,map<mds_rank_t,ceph_mds_cap_reconnect> > > cap_imports;  // ino -> client -> frommds -> capex
   map<inodeno_t,filepath> cap_import_paths;
   set<inodeno_t> cap_imports_missing;
   int cap_imports_num_opening;
@@ -425,7 +425,7 @@ protected:
   set<CInode*> rejoin_undef_inodes;
   set<CInode*> rejoin_potential_updated_scatterlocks;
   set<CDir*>   rejoin_undef_dirfrags;
-  map<int, set<CInode*> > rejoin_unlinked_inodes;
+  map<mds_rank_t, set<CInode*> > rejoin_unlinked_inodes;
 
   vector<CInode*> rejoin_recover_q, rejoin_check_q;
   list<SimpleLock*> rejoin_eval_locks;
@@ -437,7 +437,7 @@ protected:
   CInode* rejoin_invent_inode(inodeno_t ino, snapid_t last);
   CDir* rejoin_invent_dirfrag(dirfrag_t df);
   void handle_cache_rejoin_strong(MMDSCacheRejoin *m);
-  void rejoin_scour_survivor_replicas(int from, MMDSCacheRejoin *ack,
+  void rejoin_scour_survivor_replicas(mds_rank_t from, MMDSCacheRejoin *ack,
                                      set<vinodeno_t>& acked_inodes,
                                      set<SimpleLock *>& gather_locks);
   void handle_cache_rejoin_ack(MMDSCacheRejoin *m);
@@ -457,15 +457,15 @@ public:
     cap_export_targets[ino] = target;
   }
   void rejoin_recovered_caps(inodeno_t ino, client_t client, cap_reconnect_t& icr, 
-                            int frommds=-1) {
+                            mds_rank_t frommds=MDS_RANK_NONE) {
     cap_imports[ino][client][frommds] = icr.capinfo;
     cap_import_paths[ino] = filepath(icr.path, (uint64_t)icr.capinfo.pathbase);
   }
   ceph_mds_cap_reconnect *get_replay_cap_reconnect(inodeno_t ino, client_t client) {
     if (cap_imports.count(ino) &&
        cap_imports[ino].count(client) &&
-       cap_imports[ino][client].count(-1)) {
-      return &cap_imports[ino][client][-1];
+       cap_imports[ino][client].count(MDS_RANK_NONE)) {
+      return &cap_imports[ino][client][MDS_RANK_NONE];
     }
     return NULL;
   }
@@ -497,7 +497,7 @@ public:
                           map<client_t,MClientSnap*>& splits);
   void do_realm_invalidate_and_update_notify(CInode *in, int snapop, bool nosend=false);
   void send_snaps(map<client_t,MClientSnap*>& splits);
-  Capability* rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconnect& icr, int frommds);
+  Capability* rejoin_import_cap(CInode *in, client_t client, ceph_mds_cap_reconnect& icr, mds_rank_t frommds);
   void finish_snaprealm_reconnect(client_t client, SnapRealm *realm, snapid_t seq);
   void try_reconnect_cap(CInode *in, Session *session);
   void export_remaining_imported_caps();
@@ -558,12 +558,12 @@ public:
 
   // trimming
   bool trim(int max=-1, int count=-1);   // trim cache
-  bool trim_dentry(CDentry *dn, map<int, MCacheExpire*>& expiremap);
+  bool trim_dentry(CDentry *dn, map<mds_rank_t, MCacheExpire*>& expiremap);
   void trim_dirfrag(CDir *dir, CDir *con,
-                   map<int, MCacheExpire*>& expiremap);
+                   map<mds_rank_t, MCacheExpire*>& expiremap);
   bool trim_inode(CDentry *dn, CInode *in, CDir *con,
-                 map<int,class MCacheExpire*>& expiremap);
-  void send_expire_messages(map<int, MCacheExpire*>& expiremap);
+                 map<mds_rank_t,class MCacheExpire*>& expiremap);
+  void send_expire_messages(map<mds_rank_t, MCacheExpire*>& expiremap);
   void trim_non_auth();      // trim out trimmable non-auth items
   bool trim_non_auth_subtree(CDir *directory);
   void standby_trim_segment(LogSegment *ls);
@@ -665,9 +665,9 @@ public:
   }
 protected:
 
-  void inode_remove_replica(CInode *in, int rep, bool rejoin,
+  void inode_remove_replica(CInode *in, mds_rank_t rep, bool rejoin,
                            set<SimpleLock *>& gather_locks);
-  void dentry_remove_replica(CDentry *dn, int rep, set<SimpleLock *>& gather_locks);
+  void dentry_remove_replica(CDentry *dn, mds_rank_t rep, set<SimpleLock *>& gather_locks);
 
   void rename_file(CDentry *srcdn, CDentry *destdn);
 
@@ -783,9 +783,9 @@ public:
 protected:
   struct open_ino_info_t {
     vector<inode_backpointer_t> ancestors;
-    set<int> checked;
-    int checking;
-    int auth_hint;
+    set<mds_rank_t> checked;
+    mds_rank_t checking;
+    mds_rank_t auth_hint;
     bool check_peers;
     bool fetch_backtrace;
     bool discover;
@@ -794,7 +794,7 @@ protected:
     version_t tid;
     int64_t pool;
     list<MDSInternalContextBase*> waiters;
-    open_ino_info_t() : checking(-1), auth_hint(-1),
+    open_ino_info_t() : checking(MDS_RANK_NONE), auth_hint(MDS_RANK_NONE),
       check_peers(true), fetch_backtrace(true), discover(false) {}
   };
   ceph_tid_t open_ino_last_tid;
@@ -807,7 +807,7 @@ protected:
   MDSInternalContextBase* _open_ino_get_waiter(inodeno_t ino, MMDSOpenIno *m);
   int open_ino_traverse_dir(inodeno_t ino, MMDSOpenIno *m,
                            vector<inode_backpointer_t>& ancestors,
-                           bool discover, bool want_xlocked, int *hint);
+                           bool discover, bool want_xlocked, mds_rank_t *hint);
   void open_ino_finish(inodeno_t ino, open_ino_info_t& info, int err);
   void do_open_ino(inodeno_t ino, open_ino_info_t& info, int err);
   void do_open_ino_peer(inodeno_t ino, open_ino_info_t& info);
@@ -818,7 +818,7 @@ protected:
   friend struct C_MDC_OpenInoParentOpened;
 
 public:
-  void kick_open_ino_peers(int who);
+  void kick_open_ino_peers(mds_rank_t who);
   void open_ino(inodeno_t ino, int64_t pool, MDSInternalContextBase *fin,
                bool want_replica=true, bool want_xlocked=false);
   
@@ -827,21 +827,21 @@ public:
     inodeno_t ino;
     ceph_tid_t tid;
     MDSInternalContextBase *fin;
-    int hint;
-    int checking;
-    set<int> checked;
+    mds_rank_t hint;
+    mds_rank_t checking;
+    set<mds_rank_t> checked;
 
-    find_ino_peer_info_t() : tid(0), fin(NULL), hint(-1), checking(-1) {}
+    find_ino_peer_info_t() : tid(0), fin(NULL), hint(MDS_RANK_NONE), checking(MDS_RANK_NONE) {}
   };
 
   map<ceph_tid_t, find_ino_peer_info_t> find_ino_peer;
   ceph_tid_t find_ino_peer_last_tid;
 
-  void find_ino_peers(inodeno_t ino, MDSInternalContextBase *c, int hint=-1);
+  void find_ino_peers(inodeno_t ino, MDSInternalContextBase *c, mds_rank_t hint=MDS_RANK_NONE);
   void _do_find_ino_peer(find_ino_peer_info_t& fip);
   void handle_find_ino(MMDSFindIno *m);
   void handle_find_ino_reply(MMDSFindInoReply *m);
-  void kick_find_ino_peers(int who);
+  void kick_find_ino_peers(mds_rank_t who);
 
   // -- snaprealms --
 public:
@@ -877,7 +877,7 @@ protected:
   friend class C_MDC_PurgeStrayLoggedTruncate;
   friend class C_IO_MDC_PurgeStrayPurged;
   void reintegrate_stray(CDentry *dn, CDentry *rlink);
-  void migrate_stray(CDentry *dn, int dest);
+  void migrate_stray(CDentry *dn, mds_rank_t dest);
 
 
   // == messages ==
@@ -891,29 +891,29 @@ protected:
   friend class C_MDC_Join;
 
 public:
-  void replicate_dir(CDir *dir, int to, bufferlist& bl) {
+  void replicate_dir(CDir *dir, mds_rank_t to, bufferlist& bl) {
     dirfrag_t df = dir->dirfrag();
     ::encode(df, bl);
     dir->encode_replica(to, bl);
   }
-  void replicate_dentry(CDentry *dn, int to, bufferlist& bl) {
+  void replicate_dentry(CDentry *dn, mds_rank_t to, bufferlist& bl) {
     ::encode(dn->name, bl);
     ::encode(dn->last, bl);
     dn->encode_replica(to, bl);
   }
-  void replicate_inode(CInode *in, int to, bufferlist& bl) {
+  void replicate_inode(CInode *in, mds_rank_t to, bufferlist& bl) {
     ::encode(in->inode.ino, bl);  // bleh, minor assymetry here
     ::encode(in->last, bl);
     in->encode_replica(to, bl);
   }
   
-  CDir* add_replica_dir(bufferlist::iterator& p, CInode *diri, int from, list<MDSInternalContextBase*>& finished);
-  CDir* forge_replica_dir(CInode *diri, frag_t fg, int from);
+  CDir* add_replica_dir(bufferlist::iterator& p, CInode *diri, mds_rank_t from, list<MDSInternalContextBase*>& finished);
+  CDir* forge_replica_dir(CInode *diri, frag_t fg, mds_rank_t from);
   CDentry *add_replica_dentry(bufferlist::iterator& p, CDir *dir, list<MDSInternalContextBase*>& finished);
   CInode *add_replica_inode(bufferlist::iterator& p, CDentry *dn, list<MDSInternalContextBase*>& finished);
 
-  void replicate_stray(CDentry *straydn, int who, bufferlist& bl);
-  CDentry *add_replica_stray(bufferlist &bl, int from);
+  void replicate_stray(CDentry *straydn, mds_rank_t who, bufferlist& bl);
+  CDentry *add_replica_stray(bufferlist &bl, mds_rank_t from);
 
   // -- namespace --
 public:
index 74719cdd97e15445464ee0af6e6fd1c9ba9a4c7e..54971e0691159b0ab8188c2b604ea05cf2cab064 100644 (file)
@@ -95,7 +95,7 @@ MDS::MDS(const std::string &n, Messenger *m, MonClient *mc) :
                                                                      m->cct->_conf->auth_supported :
                                                                      m->cct->_conf->auth_service_required)),
   name(n),
-  whoami(-1), incarnation(0),
+  whoami(MDS_RANK_NONE), incarnation(0),
   standby_for_rank(MDSMap::MDS_NO_STANDBY_PREF),
   standby_type(MDSMap::STATE_NULL),
   standby_replaying(false),
@@ -460,7 +460,7 @@ void MDS::send_message(Message *m, Connection *c)
 }
 
 
-void MDS::send_message_mds(Message *m, int mds)
+void MDS::send_message_mds(Message *m, mds_rank_t mds)
 {
   if (!mdsmap->is_up(mds)) {
     dout(10) << "send_message_mds mds." << mds << " not up, dropping " << *m << dendl;
@@ -479,7 +479,7 @@ void MDS::send_message_mds(Message *m, int mds)
   messenger->send_message(m, mdsmap->get_inst(mds));
 }
 
-void MDS::forward_message_mds(Message *m, int mds)
+void MDS::forward_message_mds(Message *m, mds_rank_t mds)
 {
   assert(mds != whoami);
 
@@ -680,7 +680,7 @@ int MDS::init(MDSMap::DaemonState wanted_state)
     standby_type = wanted_state;
   }
 
-  standby_for_rank = g_conf->mds_standby_for_rank;
+  standby_for_rank = mds_rank_t(g_conf->mds_standby_for_rank);
   standby_for_name.assign(g_conf->mds_standby_for_name);
 
   if (wanted_state == MDSMap::STATE_STANDBY_REPLAY &&
@@ -886,7 +886,7 @@ void MDS::handle_command(MMonCommand *m)
   } else if (m->cmd[0] == "export_dir") {
     if (m->cmd.size() == 3) {
       filepath fp(m->cmd[1].c_str());
-      int target = atoi(m->cmd[2].c_str());
+      mds_rank_t target = mds_rank_t(atoi(m->cmd[2].c_str()));
       if (target != whoami && mdsmap->is_up(target) && mdsmap->is_in(target)) {
        CInode *in = mdcache->cache_traverse(fp);
        if (in) {
@@ -925,11 +925,11 @@ void MDS::handle_mds_map(MMDSMap *m)
 
   // note source's map version
   if (m->get_source().is_mds() && 
-      peer_mdsmap_epoch[m->get_source().num()] < epoch) {
+      peer_mdsmap_epoch[mds_rank_t(m->get_source().num())] < epoch) {
     dout(15) << " peer " << m->get_source()
             << " has mdsmap epoch >= " << epoch
             << dendl;
-    peer_mdsmap_epoch[m->get_source().num()] = epoch;
+    peer_mdsmap_epoch[mds_rank_t(m->get_source().num())] = epoch;
   }
 
   // is it new?
@@ -966,14 +966,14 @@ void MDS::handle_mds_map(MMDSMap *m)
 
   // see who i am
   addr = messenger->get_myaddr();
-  whoami = mdsmap->get_rank_gid(monc->get_global_id());
-  state = mdsmap->get_state_gid(monc->get_global_id());
-  incarnation = mdsmap->get_inc_gid(monc->get_global_id());
+  whoami = mdsmap->get_rank_gid(mds_gid_t(monc->get_global_id()));
+  state = mdsmap->get_state_gid(mds_gid_t(monc->get_global_id()));
+  incarnation = mdsmap->get_inc_gid(mds_gid_t(monc->get_global_id()));
   dout(10) << "map says i am " << addr << " mds." << whoami << "." << incarnation
           << " state " << ceph_mds_state_name(state) << dendl;
 
   // mark down any failed peers
-  for (map<uint64_t,MDSMap::mds_info_t>::const_iterator p = oldmap->get_mds_info().begin();
+  for (map<mds_gid_t,MDSMap::mds_info_t>::const_iterator p = oldmap->get_mds_info().begin();
        p != oldmap->get_mds_info().end();
        ++p) {
     if (mdsmap->get_mds_info().count(p->first) == 0) {
@@ -1008,7 +1008,7 @@ void MDS::handle_mds_map(MMDSMap *m)
         state == MDSMap::STATE_ONESHOT_REPLAY) {
       // fill in whoami from standby-for-rank. If we let this be changed
       // the logic used to set it here will need to be adjusted.
-      whoami = mdsmap->get_mds_info_gid(monc->get_global_id()).standby_for_rank;
+      whoami = mdsmap->get_mds_info_gid(mds_gid_t(monc->get_global_id())).standby_for_rank;
     } else {
       if (want_state == MDSMap::STATE_STANDBY) {
         dout(10) << "dropped out of mdsmap, try to re-add myself" << dendl;
@@ -1021,7 +1021,7 @@ void MDS::handle_mds_map(MMDSMap *m)
       } else {
        // did i get kicked by someone else?
        if (g_conf->mds_enforce_unique_name) {
-         if (uint64_t existing = mdsmap->find_mds_gid_by_name(name)) {
+         if (mds_gid_t existing = mdsmap->find_mds_gid_by_name(name)) {
            MDSMap::mds_info_t& i = mdsmap->get_info_gid(existing);
            if (i.global_id > monc->get_global_id()) {
              dout(1) << "handle_mds_map i (" << addr
@@ -1109,7 +1109,7 @@ void MDS::handle_mds_map(MMDSMap *m)
   if (is_resolve() || is_reconnect() || is_rejoin() ||
       is_clientreplay() || is_active() || is_stopping()) {
     if (!oldmap->is_resolving() && mdsmap->is_resolving()) {
-      set<int> resolve;
+      set<mds_rank_t> resolve;
       mdsmap->get_mds_set(resolve, MDSMap::STATE_RESOLVE);
       dout(10) << " resolve set is " << resolve << dendl;
       calc_recovery_set();
@@ -1131,14 +1131,14 @@ void MDS::handle_mds_map(MMDSMap *m)
 
     if (oldstate >= MDSMap::STATE_REJOIN) {
       // ACTIVE|CLIENTREPLAY|REJOIN => we can discover from them.
-      set<int> olddis, dis;
+      set<mds_rank_t> olddis, dis;
       oldmap->get_mds_set(olddis, MDSMap::STATE_ACTIVE);
       oldmap->get_mds_set(olddis, MDSMap::STATE_CLIENTREPLAY);
       oldmap->get_mds_set(olddis, MDSMap::STATE_REJOIN);
       mdsmap->get_mds_set(dis, MDSMap::STATE_ACTIVE);
       mdsmap->get_mds_set(dis, MDSMap::STATE_CLIENTREPLAY);
       mdsmap->get_mds_set(dis, MDSMap::STATE_REJOIN);
-      for (set<int>::iterator p = dis.begin(); p != dis.end(); ++p)
+      for (set<mds_rank_t>::iterator p = dis.begin(); p != dis.end(); ++p)
        if (*p != whoami &&            // not me
            olddis.count(*p) == 0) {  // newly so?
          mdcache->kick_discovers(*p);
@@ -1153,12 +1153,12 @@ void MDS::handle_mds_map(MMDSMap *m)
   // did someone go active?
   if (oldstate >= MDSMap::STATE_CLIENTREPLAY &&
       (is_clientreplay() || is_active() || is_stopping())) {
-    set<int> oldactive, active;
+    set<mds_rank_t> oldactive, active;
     oldmap->get_mds_set(oldactive, MDSMap::STATE_ACTIVE);
     oldmap->get_mds_set(oldactive, MDSMap::STATE_CLIENTREPLAY);
     mdsmap->get_mds_set(active, MDSMap::STATE_ACTIVE);
     mdsmap->get_mds_set(active, MDSMap::STATE_CLIENTREPLAY);
-    for (set<int>::iterator p = active.begin(); p != active.end(); ++p) 
+    for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p) 
       if (*p != whoami &&            // not me
          oldactive.count(*p) == 0)  // newly so?
        handle_mds_recovery(*p);
@@ -1167,10 +1167,10 @@ void MDS::handle_mds_map(MMDSMap *m)
   // did someone fail?
   if (true) {
     // new failed?
-    set<int> oldfailed, failed;
+    set<mds_rank_t> oldfailed, failed;
     oldmap->get_failed_mds_set(oldfailed);
     mdsmap->get_failed_mds_set(failed);
-    for (set<int>::iterator p = failed.begin(); p != failed.end(); ++p)
+    for (set<mds_rank_t>::iterator p = failed.begin(); p != failed.end(); ++p)
       if (oldfailed.count(*p) == 0) {
        messenger->mark_down(oldmap->get_inst(*p).addr);
        handle_mds_failure(*p);
@@ -1178,9 +1178,9 @@ void MDS::handle_mds_map(MMDSMap *m)
     
     // or down then up?
     //  did their addr/inst change?
-    set<int> up;
+    set<mds_rank_t> up;
     mdsmap->get_up_mds_set(up);
-    for (set<int>::iterator p = up.begin(); p != up.end(); ++p) 
+    for (set<mds_rank_t>::iterator p = up.begin(); p != up.end(); ++p) 
       if (oldmap->have_inst(*p) &&
          oldmap->get_inst(*p) != mdsmap->get_inst(*p)) {
        messenger->mark_down(oldmap->get_inst(*p).addr);
@@ -1189,10 +1189,10 @@ void MDS::handle_mds_map(MMDSMap *m)
   }
   if (is_clientreplay() || is_active() || is_stopping()) {
     // did anyone stop?
-    set<int> oldstopped, stopped;
+    set<mds_rank_t> oldstopped, stopped;
     oldmap->get_stopped_mds_set(oldstopped);
     mdsmap->get_stopped_mds_set(stopped);
-    for (set<int>::iterator p = stopped.begin(); p != stopped.end(); ++p) 
+    for (set<mds_rank_t>::iterator p = stopped.begin(); p != stopped.end(); ++p) 
       if (oldstopped.count(*p) == 0)      // newly so?
        mdcache->migrator->handle_mds_failure_or_stop(*p);
   }
@@ -1403,7 +1403,7 @@ void MDS::starting_done()
 void MDS::calc_recovery_set()
 {
   // initialize gather sets
-  set<int> rs;
+  set<mds_rank_t> rs;
   mdsmap->get_recovery_mds_set(rs);
   rs.erase(whoami);
   mdcache->set_recovery_set(rs);
@@ -1669,7 +1669,7 @@ void MDS::recovery_done(int oldstate)
   
   // kick snaptable (resent AGREEs)
   if (mdsmap->get_tableserver() == whoami) {
-    set<int> active;
+    set<mds_rank_t> active;
     mdsmap->get_clientreplay_or_active_or_stopping_mds_set(active);
     snapserver->finish_recovery(active);
   }
@@ -1688,7 +1688,7 @@ void MDS::recovery_done(int oldstate)
   mdcache->populate_mydir();
 }
 
-void MDS::handle_mds_recovery(int who) 
+void MDS::handle_mds_recovery(mds_rank_t who) 
 {
   dout(5) << "handle_mds_recovery mds." << who << dendl;
   
@@ -1702,7 +1702,7 @@ void MDS::handle_mds_recovery(int who)
   waiting_for_active_peer.erase(who);
 }
 
-void MDS::handle_mds_failure(int who)
+void MDS::handle_mds_failure(mds_rank_t who)
 {
   if (who == whoami) {
     dout(5) << "handle_mds_failure for myself; not doing anything" << dendl;
@@ -1998,7 +1998,7 @@ bool MDS::is_stale_message(Message *m)
 {
   // from bad mds?
   if (m->get_source().is_mds()) {
-    int from = m->get_source().num();
+    mds_rank_t from = mds_rank_t(m->get_source().num());
     if (!mdsmap->have_inst(from) ||
        mdsmap->get_inst(from) != m->get_source_inst() ||
        mdsmap->is_down(from)) {
@@ -2118,7 +2118,7 @@ bool MDS::_dispatch(Message *m)
   if (el > 30.0 &&
     el < 60.0)*/
   for (int i=0; i<g_conf->mds_thrash_exports; i++) {
-    set<int> s;
+    set<mds_rank_t> s;
     if (!is_active()) break;
     mdsmap->get_mds_set(s, MDSMap::STATE_ACTIVE);
     if (s.size() < 2 || mdcache->get_num_inodes() < 10) 
@@ -2141,10 +2141,10 @@ bool MDS::_dispatch(Message *m)
     if (!dir->get_parent_dir()) continue;    // must be linked.
     if (!dir->is_auth()) continue;           // must be auth.
 
-    int dest;
+    mds_rank_t dest;
     do {
       int k = rand() % s.size();
-      set<int>::iterator p = s.begin();
+      set<mds_rank_t>::iterator p = s.begin();
       while (k--) ++p;
       dest = *p;
     } while (dest == whoami);
index a51a5f9b032dc6121ab72c55f43f70e4eea2a385..1c224bfd3ffbef1293ac0082824ed1e36d747e71 100644 (file)
@@ -159,10 +159,10 @@ class MDS : public Dispatcher, public md_config_obs_t {
   AuthAuthorizeHandlerRegistry *authorize_handler_service_registry;
 
   string name;
-  int whoami;
+  mds_rank_t whoami;
   int incarnation;
 
-  int standby_for_rank;
+  mds_rank_t standby_for_rank;
   MDSMap::DaemonState standby_type;  // one of STANDBY_REPLAY, ONESHOT_REPLAY
   string standby_for_name;
   bool standby_replaying;  // true if current replay pass is in standby-replay mode
@@ -206,11 +206,11 @@ class MDS : public Dispatcher, public md_config_obs_t {
 
   list<MDSInternalContextBase*> waiting_for_active, waiting_for_replay, waiting_for_reconnect, waiting_for_resolve;
   list<MDSInternalContextBase*> replay_queue;
-  map<int, list<MDSInternalContextBase*> > waiting_for_active_peer;
+  map<mds_rank_t, list<MDSInternalContextBase*> > waiting_for_active_peer;
   list<Message*> waiting_for_nolaggy;
   map<epoch_t, list<MDSInternalContextBase*> > waiting_for_mdsmap;
 
-  map<int,version_t> peer_mdsmap_epoch;
+  map<mds_rank_t, version_t> peer_mdsmap_epoch;
 
   ceph_tid_t last_tid;    // for mds-initiated requests (e.g. stray rename)
 
@@ -218,7 +218,7 @@ class MDS : public Dispatcher, public md_config_obs_t {
   void wait_for_active(MDSInternalContextBase *c) { 
     waiting_for_active.push_back(c); 
   }
-  void wait_for_active_peer(int who, MDSInternalContextBase *c) { 
+  void wait_for_active_peer(mds_rank_t who, MDSInternalContextBase *c) { 
     waiting_for_active_peer[who].push_back(c);
   }
   void wait_for_replay(MDSInternalContextBase *c) { 
@@ -345,12 +345,12 @@ private:
   void handle_signal(int signum);
 
   // who am i etc
-  int get_nodeid() const { return whoami; }
+  mds_rank_t get_nodeid() const { return whoami; }
   uint64_t get_metadata_pool() { return mdsmap->get_metadata_pool(); }
   MDSMap *get_mds_map() { return mdsmap; }
 
-  void send_message_mds(Message *m, int mds);
-  void forward_message_mds(Message *req, int mds);
+  void send_message_mds(Message *m, mds_rank_t mds);
+  void forward_message_mds(Message *req, mds_rank_t mds);
 
   void send_message_client_counted(Message *m, client_t client);
   void send_message_client_counted(Message *m, Session *session);
@@ -428,8 +428,8 @@ private:
   void stopping_start();
   void stopping_done();
 
-  void handle_mds_recovery(int who);
-  void handle_mds_failure(int who);
+  void handle_mds_recovery(mds_rank_t who);
+  void handle_mds_failure(mds_rank_t who);
 
   void suicide();
   void respawn();
index 54ebf16fb9e64a38e0d13160bfcd745712f3f396..831e236b67d07c6256e9a2b628ac082ceeaf6e04 100644 (file)
 using std::stringstream;
 
 
+const mds_rank_t MDSMap::MDS_NO_STANDBY_PREF(-1);
+const mds_rank_t MDSMap::MDS_STANDBY_ANY(-2);
+const mds_rank_t MDSMap::MDS_STANDBY_NAME(-3);
+const mds_rank_t MDSMap::MDS_MATCHED_ACTIVE(-4);
+
 // features
 CompatSet get_mdsmap_compat_set_all() {
   CompatSet::FeatureSet feature_compat;
@@ -76,7 +81,7 @@ void MDSMap::mds_info_t::dump(Formatter *f) const
   f->dump_int("standby_for_rank", standby_for_rank);
   f->dump_string("standby_for_name", standby_for_name);
   f->open_array_section("export_targets");
-  for (set<int32_t>::iterator p = export_targets.begin();
+  for (set<mds_rank_t>::iterator p = export_targets.begin();
        p != export_targets.end(); ++p) {
     f->dump_int("mds", *p);
   }
@@ -112,26 +117,26 @@ void MDSMap::dump(Formatter *f) const
   f->close_section();
   f->dump_int("max_mds", max_mds);
   f->open_array_section("in");
-  for (set<int32_t>::const_iterator p = in.begin(); p != in.end(); ++p)
+  for (set<mds_rank_t>::const_iterator p = in.begin(); p != in.end(); ++p)
     f->dump_int("mds", *p);
   f->close_section();
   f->open_object_section("up");
-  for (map<int32_t,uint64_t>::const_iterator p = up.begin(); p != up.end(); ++p) {
+  for (map<mds_rank_t,mds_gid_t>::const_iterator p = up.begin(); p != up.end(); ++p) {
     char s[10];
-    sprintf(s, "mds_%d", p->first);
+    sprintf(s, "mds_%d", int(p->first));
     f->dump_int(s, p->second);
   }
   f->close_section();
   f->open_array_section("failed");
-  for (set<int32_t>::const_iterator p = failed.begin(); p != failed.end(); ++p)
+  for (set<mds_rank_t>::const_iterator p = failed.begin(); p != failed.end(); ++p)
     f->dump_int("mds", *p);
   f->close_section();
   f->open_array_section("stopped");
-  for (set<int32_t>::const_iterator p = stopped.begin(); p != stopped.end(); ++p)
+  for (set<mds_rank_t>::const_iterator p = stopped.begin(); p != stopped.end(); ++p)
     f->dump_int("mds", *p);
   f->close_section();
   f->open_object_section("info");
-  for (map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) {
+  for (map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) {
     char s[25]; // 'gid_' + len(str(ULLONG_MAX)) + '\0'
     sprintf(s, "gid_%llu", (long long unsigned)p->first);
     f->open_object_section(s);
@@ -187,13 +192,13 @@ void MDSMap::print(ostream& out)
   out << "metadata_pool\t" << metadata_pool << "\n";
   out << "inline_data\t" << (inline_data_enabled ? "enabled" : "disabled") << "\n";
 
-  multimap< pair<unsigned,unsigned>, uint64_t > foo;
-  for (map<uint64_t,mds_info_t>::iterator p = mds_info.begin();
+  multimap< pair<mds_rank_t, unsigned>, mds_gid_t > foo;
+  for (map<mds_gid_t,mds_info_t>::iterator p = mds_info.begin();
        p != mds_info.end();
        ++p)
-    foo.insert(pair<pair<unsigned,unsigned>,uint64_t>(pair<unsigned,unsigned>(p->second.rank, p->second.inc-1), p->first));
+    foo.insert(std::make_pair(std::make_pair(p->second.rank, p->second.inc-1), p->first));
 
-  for (multimap< pair<unsigned,unsigned>, uint64_t >::iterator p = foo.begin();
+  for (multimap< pair<mds_rank_t, unsigned>, mds_gid_t >::iterator p = foo.begin();
        p != foo.end();
        ++p) {
     mds_info_t& info = mds_info[p->second];
@@ -226,7 +231,7 @@ void MDSMap::print(ostream& out)
 
 void MDSMap::print_summary(Formatter *f, ostream *out)
 {
-  map<int,string> by_rank;
+  map<mds_rank_t,string> by_rank;
   map<string,int> by_state;
 
   if (f) {
@@ -240,7 +245,7 @@ void MDSMap::print_summary(Formatter *f, ostream *out)
 
   if (f)
     f->open_array_section("by_rank");
-  for (map<uint64_t,mds_info_t>::iterator p = mds_info.begin();
+  for (map<mds_gid_t,mds_info_t>::iterator p = mds_info.begin();
        p != mds_info.end();
        ++p) {
     string s = ceph_mds_state_name(p->second.state);
@@ -299,7 +304,7 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
        << " failed";
     summary.push_back(make_pair(HEALTH_ERR, oss.str()));
     if (detail) {
-      for (set<int>::const_iterator p = failed.begin(); p != failed.end(); ++p) {
+      for (set<mds_rank_t>::const_iterator p = failed.begin(); p != failed.end(); ++p) {
        std::ostringstream oss;
        oss << "mds." << *p << " has failed";
        detail->push_back(make_pair(HEALTH_ERR, oss.str()));
@@ -311,11 +316,11 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
     summary.push_back(make_pair(HEALTH_WARN, "mds cluster is degraded"));
     if (detail) {
       detail->push_back(make_pair(HEALTH_WARN, "mds cluster is degraded"));
-      for (unsigned i=0; i< get_max_mds(); i++) {
+      for (mds_rank_t i = mds_rank_t(0); i< get_max_mds(); i++) {
        if (!is_up(i))
          continue;
-       uint64_t gid = up.find(i)->second;
-       map<uint64_t,mds_info_t>::const_iterator info = mds_info.find(gid);
+       mds_gid_t gid = up.find(i)->second;
+       map<mds_gid_t,mds_info_t>::const_iterator info = mds_info.find(gid);
        stringstream ss;
        if (is_resolve(i))
          ss << "mds." << info->second.name << " at " << info->second.addr << " rank " << i << " is resolving";
@@ -331,12 +336,12 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
     }
   }
 
-  map<int32_t,uint64_t>::const_iterator u = up.begin();
-  map<int32_t,uint64_t>::const_iterator u_end = up.end();
-  map<uint64_t,mds_info_t>::const_iterator m_end = mds_info.end();
+  map<mds_rank_t, mds_gid_t>::const_iterator u = up.begin();
+  map<mds_rank_t, mds_gid_t>::const_iterator u_end = up.end();
+  map<mds_gid_t, mds_info_t>::const_iterator m_end = mds_info.end();
   set<string> laggy;
   for (; u != u_end; ++u) {
-    map<uint64_t,mds_info_t>::const_iterator m = mds_info.find(u->second);
+    map<mds_gid_t, mds_info_t>::const_iterator m = mds_info.find(u->second);
     assert(m != m_end);
     const mds_info_t &mds_info(m->second);
     if (mds_info.laggy()) {
@@ -427,7 +432,7 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const
     ::encode(max_mds, bl);
     __u32 n = mds_info.size();
     ::encode(n, bl);
-    for (map<uint64_t, mds_info_t>::const_iterator i = mds_info.begin();
+    for (map<mds_gid_t, mds_info_t>::const_iterator i = mds_info.begin();
        i != mds_info.end(); ++i) {
       ::encode(i->first, bl);
       ::encode(i->second, bl, features);
@@ -455,7 +460,7 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const
     ::encode(max_mds, bl);
     __u32 n = mds_info.size();
     ::encode(n, bl);
-    for (map<uint64_t, mds_info_t>::const_iterator i = mds_info.begin();
+    for (map<mds_gid_t, mds_info_t>::const_iterator i = mds_info.begin();
        i != mds_info.end(); ++i) {
       ::encode(i->first, bl);
       ::encode(i->second, bl, features);
index 84ba4d42059decbbd6ea7b5b6afd40459effc923..0e36c14557e349654ce53abefce520b1733b9627 100644 (file)
@@ -31,6 +31,7 @@
 #include "include/CompatSet.h"
 #include "include/ceph_features.h"
 #include "common/Formatter.h"
+#include "mds/mdstypes.h"
 
 /*
 
@@ -114,29 +115,33 @@ public:
 
   // indicate startup standby preferences for MDS
   // of course, if they have a specific rank to follow, they just set that!
-  static const int MDS_NO_STANDBY_PREF = -1; // doesn't have instructions to do anything
-  static const int MDS_STANDBY_ANY = -2; // is instructed to be standby-replay, may
-                                     // or may not have specific name to follow
-  static const int MDS_STANDBY_NAME = -3; // standby for a named MDS
-  static const int MDS_MATCHED_ACTIVE = -4; // has a matched standby, which if up
-                                            // it should follow, but otherwise should
-                                            // be assigned a rank
+  static const mds_rank_t MDS_NO_STANDBY_PREF; // doesn't have instructions to do anything
+  static const mds_rank_t MDS_STANDBY_ANY;     // is instructed to be standby-replay, may
+                                               // or may not have specific name to follow
+  static const mds_rank_t MDS_STANDBY_NAME;    // standby for a named MDS
+  static const mds_rank_t MDS_MATCHED_ACTIVE;  // has a matched standby, which if up
+                                               // it should follow, but otherwise should
+                                               // be assigned a rank
 
   struct mds_info_t {
-    uint64_t global_id;
+    mds_gid_t global_id;
     std::string name;
-    int32_t rank;
+    mds_rank_t rank;
     int32_t inc;
     MDSMap::DaemonState state;
     version_t state_seq;
     entity_addr_t addr;
     utime_t laggy_since;
-    int32_t standby_for_rank;
+    mds_rank_t standby_for_rank;
     std::string standby_for_name;
-    std::set<int32_t> export_targets;
+    std::set<mds_rank_t> export_targets;
 
-    mds_info_t() : global_id(0), rank(-1), inc(0), state(STATE_STANDBY), state_seq(0),
+#if 1
+    mds_info_t() : global_id(MDS_GID_NONE), rank(MDS_RANK_NONE), inc(0), state(STATE_STANDBY), state_seq(0),
                   standby_for_rank(MDS_NO_STANDBY_PREF) { }
+#else
+    mds_info_t();
+#endif
 
     bool laggy() const { return !(laggy_since == utime_t()); }
     void clear_laggy() { laggy_since = utime_t(); }
@@ -167,8 +172,8 @@ protected:
                                   // at least this osdmap to ensure the blacklist propagates.
   utime_t created, modified;
 
-  int32_t tableserver;   // which MDS has snaptable
-  int32_t root;          // which MDS has root directory
+  mds_rank_t tableserver;   // which MDS has snaptable
+  mds_rank_t root;          // which MDS has root directory
 
   __u32 session_timeout;
   __u32 session_autoclose;
@@ -188,13 +193,13 @@ protected:
    *    @up + @failed = @in.  @in * @stopped = {}.
    */
 
-  uint32_t max_mds; /* The maximum number of active MDSes. Also, the maximum rank. */
+  mds_rank_t max_mds; /* The maximum number of active MDSes. Also, the maximum rank. */
 
-  std::set<int32_t> in;              // currently defined cluster
-  std::map<int32_t,int32_t> inc;     // most recent incarnation.
-  std::set<int32_t> failed, stopped; // which roles are failed or stopped
-  std::map<int32_t,uint64_t> up;        // who is in those roles
-  std::map<uint64_t,mds_info_t> mds_info;
+  std::set<mds_rank_t> in;              // currently defined cluster
+  std::map<mds_rank_t,int32_t> inc;     // most recent incarnation.
+  std::set<mds_rank_t> failed, stopped; // which roles are failed or stopped
+  std::map<mds_rank_t, mds_gid_t> up;        // who is in those roles
+  std::map<mds_gid_t, mds_info_t> mds_info;
 
   bool ever_allowed_snaps; //< the cluster has ever allowed snap creation
   bool explicitly_allowed_snaps; //< the user has explicitly enabled snap creation
@@ -257,11 +262,11 @@ public:
   epoch_t get_last_failure() const { return last_failure; }
   epoch_t get_last_failure_osd_epoch() const { return last_failure_osd_epoch; }
 
-  unsigned get_max_mds() const { return max_mds; }
-  void set_max_mds(int m) { max_mds = m; }
+  mds_rank_t get_max_mds() const { return max_mds; }
+  void set_max_mds(mds_rank_t m) { max_mds = m; }
 
-  int get_tableserver() const { return tableserver; }
-  int get_root() const { return root; }
+  mds_rank_t get_tableserver() const { return tableserver; }
+  mds_rank_t get_root() const { return root; }
 
   const std::set<int64_t> &get_data_pools() const { return data_pools; }
   int64_t get_first_data_pool() const { return *data_pools.begin(); }
@@ -275,24 +280,24 @@ public:
     return get_enabled() && (is_data_pool(poolid) || metadata_pool == poolid);
   }
 
-  const std::map<uint64_t,mds_info_t>& get_mds_info() { return mds_info; }
-  const mds_info_t& get_mds_info_gid(uint64_t gid) {
+  const std::map<mds_gid_t,mds_info_t>& get_mds_info() { return mds_info; }
+  const mds_info_t& get_mds_info_gid(mds_gid_t gid) {
     assert(mds_info.count(gid));
     return mds_info[gid];
   }
-  const mds_info_t& get_mds_info(int m) {
+  const mds_info_t& get_mds_info(mds_rank_t m) {
     assert(up.count(m) && mds_info.count(up[m]));
     return mds_info[up[m]];
   }
-  uint64_t find_mds_gid_by_name(const std::string& s) {
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+  mds_gid_t find_mds_gid_by_name(const std::string& s) {
+    for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p) {
       if (p->second.name == s) {
        return p->first;
       }
     }
-    return 0;
+    return MDS_GID_NONE;
   }
 
   // counts
@@ -307,7 +312,7 @@ public:
   }
   unsigned get_num_mds(int state) const {
     unsigned n = 0;
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+    for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p)
       if (p->second.state == state) ++n;
@@ -327,45 +332,45 @@ public:
   }
 
   // sets
-  void get_mds_set(std::set<int>& s) {
+  void get_mds_set(std::set<mds_rank_t>& s) {
     s = in;
   }
-  void get_up_mds_set(std::set<int>& s) {
-    for (std::map<int32_t,uint64_t>::const_iterator p = up.begin();
+  void get_up_mds_set(std::set<mds_rank_t>& s) {
+    for (std::map<mds_rank_t, mds_gid_t>::const_iterator p = up.begin();
         p != up.end();
         ++p)
       s.insert(p->first);
   }
-  void get_active_mds_set(std::set<int>& s) {
+  void get_active_mds_set(std::set<mds_rank_t>& s) {
     get_mds_set(s, MDSMap::STATE_ACTIVE);
   }
-  void get_failed_mds_set(std::set<int>& s) {
+  void get_failed_mds_set(std::set<mds_rank_t>& s) {
     s = failed;
   }
   int get_failed() {
     if (!failed.empty()) return *failed.begin();
     return -1;
   }
-  void get_stopped_mds_set(std::set<int>& s) {
+  void get_stopped_mds_set(std::set<mds_rank_t>& s) {
     s = stopped;
   }
-  void get_recovery_mds_set(std::set<int>& s) {
+  void get_recovery_mds_set(std::set<mds_rank_t>& s) {
     s = failed;
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+    for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p)
       if (p->second.state >= STATE_REPLAY && p->second.state <= STATE_STOPPING)
        s.insert(p->second.rank);
   }
-  void get_clientreplay_or_active_or_stopping_mds_set(std::set<int>& s) {
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+  void get_clientreplay_or_active_or_stopping_mds_set(std::set<mds_rank_t>& s) {
+    for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p)
       if (p->second.state >= STATE_CLIENTREPLAY && p->second.state <= STATE_STOPPING)
        s.insert(p->second.rank);
   }
-  void get_mds_set(std::set<int>& s, DaemonState state) {
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+  void get_mds_set(std::set<mds_rank_t>& s, DaemonState state) {
+    for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p)
       if (p->second.state == state)
@@ -375,14 +380,14 @@ public:
   int get_random_up_mds() {
     if (up.empty())
       return -1;
-    std::map<int32_t,uint64_t>::iterator p = up.begin();
+    std::map<mds_rank_t, mds_gid_t>::iterator p = up.begin();
     for (int n = rand() % up.size(); n; n--)
       ++p;
     return p->first;
   }
 
   const mds_info_t* find_by_name(const std::string& name) const {
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+    for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p) {
       if (p->second.name == name)
@@ -391,10 +396,10 @@ public:
     return NULL;
   }
 
-  uint64_t find_standby_for(int mds, std::string& name) {
-    std::map<uint64_t, mds_info_t>::const_iterator generic_standby
+  mds_gid_t find_standby_for(mds_rank_t mds, std::string& name) {
+    std::map<mds_gid_t, mds_info_t>::const_iterator generic_standby
       = mds_info.end();
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+    for (std::map<mds_gid_t, mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p) {
       if ((p->second.state != MDSMap::STATE_STANDBY && p->second.state != MDSMap::STATE_STANDBY_REPLAY) ||
@@ -408,26 +413,28 @@ public:
     }
     if (generic_standby != mds_info.end())
       return generic_standby->first;
-    return 0;
+    return MDS_GID_NONE;
   }
-  uint64_t find_unused_for(int mds, std::string& name) {
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
-        p != mds_info.end();
-        ++p) {
+
+  mds_gid_t find_unused_for(mds_rank_t mds, std::string& name) const {
+    for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
+         p != mds_info.end();
+         ++p) {
       if (p->second.state != MDSMap::STATE_STANDBY ||
-         p->second.laggy() ||
-         p->second.rank >= 0)
-       continue;
+          p->second.laggy() ||
+          p->second.rank >= 0)
+        continue;
       if ((p->second.standby_for_rank == MDS_NO_STANDBY_PREF ||
-          p->second.standby_for_rank == MDS_MATCHED_ACTIVE ||
-          (p->second.standby_for_rank == MDS_STANDBY_ANY && g_conf->mon_force_standby_active))) {
-       return p->first;
+           p->second.standby_for_rank == MDS_MATCHED_ACTIVE ||
+           (p->second.standby_for_rank == MDS_STANDBY_ANY && g_conf->mon_force_standby_active))) {
+        return p->first;
       }
     }
-    return 0;
+    return MDS_GID_NONE;
   }
-  uint64_t find_replacement_for(int mds, std::string& name) {
-    uint64_t standby = find_standby_for(mds, name);
+
+  mds_gid_t find_replacement_for(mds_rank_t mds, std::string& name) {
+    const mds_gid_t standby = find_standby_for(mds, name);
     if (standby)
       return standby;
     else
@@ -438,22 +445,22 @@ public:
                  list<pair<health_status_t,std::string> > *detail) const;
 
   // mds states
-  bool is_down(int m) const { return up.count(m) == 0; }
-  bool is_up(int m) const { return up.count(m); }
-  bool is_in(int m) const { return up.count(m) || failed.count(m); }
-  bool is_out(int m) const { return !is_in(m); }
+  bool is_down(mds_rank_t m) const { return up.count(m) == 0; }
+  bool is_up(mds_rank_t m) const { return up.count(m); }
+  bool is_in(mds_rank_t m) const { return up.count(m) || failed.count(m); }
+  bool is_out(mds_rank_t m) const { return !is_in(m); }
 
-  bool is_failed(int m) const   { return failed.count(m); }
-  bool is_stopped(int m) const    { return stopped.count(m); }
+  bool is_failed(mds_rank_t m) const   { return failed.count(m); }
+  bool is_stopped(mds_rank_t m) const    { return stopped.count(m); }
 
-  bool is_dne(int m) const      { return in.count(m) == 0; }
-  bool is_dne_gid(uint64_t gid) const     { return mds_info.count(gid) == 0; }
+  bool is_dne(mds_rank_t m) const      { return in.count(m) == 0; }
+  bool is_dne_gid(mds_gid_t gid) const     { return mds_info.count(gid) == 0; }
 
   /**
    * Get MDS rank state if the rank is up, else STATE_NULL
    */
-  DaemonState get_state(int m) const {
-    std::map<int32_t,uint64_t>::const_iterator u = up.find(m);
+  DaemonState get_state(mds_rank_t m) const {
+    std::map<mds_rank_t, mds_gid_t>::const_iterator u = up.find(m);
     if (u == up.end())
       return STATE_NULL;
     return get_state_gid(u->second);
@@ -462,34 +469,34 @@ public:
   /**
    * Get MDS daemon status by GID
    */
-  DaemonState get_state_gid(uint64_t gid) const {
-    std::map<uint64_t,mds_info_t>::const_iterator i = mds_info.find(gid);
+  DaemonState get_state_gid(mds_gid_t gid) const {
+    std::map<mds_gid_t,mds_info_t>::const_iterator i = mds_info.find(gid);
     if (i == mds_info.end())
       return STATE_NULL;
     return i->second.state;
   }
 
-  mds_info_t& get_info(int m) { assert(up.count(m)); return mds_info[up[m]]; }
-  mds_info_t& get_info_gid(uint64_t gid) { assert(mds_info.count(gid)); return mds_info[gid]; }
-
-  bool is_boot(int m) const { return get_state(m) == STATE_BOOT; }
-  bool is_creating(int m) const { return get_state(m) == STATE_CREATING; }
-  bool is_starting(int m) const { return get_state(m) == STATE_STARTING; }
-  bool is_replay(int m) const   { return get_state(m) == STATE_REPLAY; }
-  bool is_resolve(int m) const  { return get_state(m) == STATE_RESOLVE; }
-  bool is_reconnect(int m) const { return get_state(m) == STATE_RECONNECT; }
-  bool is_rejoin(int m) const   { return get_state(m) == STATE_REJOIN; }
-  bool is_clientreplay(int m) const { return get_state(m) == STATE_CLIENTREPLAY; }
-  bool is_active(int m) const  { return get_state(m) == STATE_ACTIVE; }
-  bool is_stopping(int m) const { return get_state(m) == STATE_STOPPING; }
-  bool is_active_or_stopping(int m) const {
+  mds_info_t& get_info(mds_rank_t m) { assert(up.count(m)); return mds_info[up[m]]; }
+  mds_info_t& get_info_gid(mds_gid_t gid) { assert(mds_info.count(gid)); return mds_info[gid]; }
+
+  bool is_boot(mds_rank_t m) const { return get_state(m) == STATE_BOOT; }
+  bool is_creating(mds_rank_t m) const { return get_state(m) == STATE_CREATING; }
+  bool is_starting(mds_rank_t m) const { return get_state(m) == STATE_STARTING; }
+  bool is_replay(mds_rank_t m) const   { return get_state(m) == STATE_REPLAY; }
+  bool is_resolve(mds_rank_t m) const  { return get_state(m) == STATE_RESOLVE; }
+  bool is_reconnect(mds_rank_t m) const { return get_state(m) == STATE_RECONNECT; }
+  bool is_rejoin(mds_rank_t m) const   { return get_state(m) == STATE_REJOIN; }
+  bool is_clientreplay(mds_rank_t m) const { return get_state(m) == STATE_CLIENTREPLAY; }
+  bool is_active(mds_rank_t m) const  { return get_state(m) == STATE_ACTIVE; }
+  bool is_stopping(mds_rank_t m) const { return get_state(m) == STATE_STOPPING; }
+  bool is_active_or_stopping(mds_rank_t m) const {
     return is_active(m) || is_stopping(m);
   }
-  bool is_clientreplay_or_active_or_stopping(int m) const {
+  bool is_clientreplay_or_active_or_stopping(mds_rank_t m) const {
     return is_clientreplay(m) || is_active(m) || is_stopping(m);
   }
 
-  bool is_followable(int m) const {
+  bool is_followable(mds_rank_t m) const {
     return (is_resolve(m) ||
            is_replay(m) ||
            is_rejoin(m) ||
@@ -498,22 +505,22 @@ public:
            is_stopping(m));
   }
 
-  bool is_laggy_gid(uint64_t gid) const {
+  bool is_laggy_gid(mds_gid_t gid) const {
     if (!mds_info.count(gid))
       return false;
-    std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.find(gid);
+    std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.find(gid);
     return p->second.laggy();
   }
 
 
   // cluster states
   bool is_full() const {
-    return in.size() >= max_mds;
+    return mds_rank_t(in.size()) >= max_mds;
   }
   bool is_degraded() const {   // degraded = some recovery in process.  fixes active membership and recovery_set.
     if (!failed.empty())
       return true;
-    for (std::map<uint64_t,mds_info_t>::const_iterator p = mds_info.begin();
+    for (std::map<mds_gid_t,mds_info_t>::const_iterator p = mds_info.begin();
         p != mds_info.end();
         ++p)
       if (p->second.state >= STATE_REPLAY && p->second.state <= STATE_CLIENTREPLAY)
@@ -543,18 +550,18 @@ public:
   }
 
   // inst
-  bool have_inst(int m) {
+  bool have_inst(mds_rank_t m) {
     return up.count(m);
   }
-  const entity_inst_t get_inst(int m) {
+  const entity_inst_t get_inst(mds_rank_t m) {
     assert(up.count(m));
     return mds_info[up[m]].get_inst();
   }
-  const entity_addr_t get_addr(int m) {
+  const entity_addr_t get_addr(mds_rank_t m) {
     assert(up.count(m));
     return mds_info[up[m]].addr;
   }
-  bool get_inst(int m, entity_inst_t& inst) { 
+  bool get_inst(mds_rank_t m, entity_inst_t& inst) {
     if (up.count(m)) {
       inst = get_inst(m);
       return true;
@@ -562,18 +569,18 @@ public:
     return false;
   }
   
-  int get_rank_gid(uint64_t gid) {
+  mds_rank_t get_rank_gid(mds_gid_t gid) {
     if (mds_info.count(gid))
       return mds_info[gid].rank;
-    return -1;
+    return MDS_RANK_NONE;
   }
 
-  int get_inc(int m) {
+  int get_inc(mds_rank_t m) {
     if (up.count(m)) 
       return mds_info[up[m]].inc;
     return 0;
   }
-  int get_inc_gid(uint64_t gid) {
+  int get_inc_gid(mds_gid_t gid) {
     if (mds_info.count(gid))
       return mds_info[gid].inc;
     return -1;
index 323740fbb0d27d613add9d56b2561ba1a74315e2..36c2d0a7b110c66b2a4c9c8a30ee9b4035a7e485 100644 (file)
@@ -134,7 +134,7 @@ object_t MDSTable::get_object_name()
 {
   char n[50];
   if (per_mds)
-    snprintf(n, sizeof(n), "mds%d_%s", mds->whoami, table_name);
+    snprintf(n, sizeof(n), "mds%d_%s", int(mds->whoami), table_name);
   else
     snprintf(n, sizeof(n), "mds_%s", table_name);
   return object_t(n);
index 2ba4f499f59416b60db31ad54483ec124aad82e8..e06f92bea5a09f8999b7f90846192b746a29e3c1 100644 (file)
@@ -243,7 +243,7 @@ void MDSTableClient::resend_prepares()
   }
 }
 
-void MDSTableClient::handle_mds_failure(int who)
+void MDSTableClient::handle_mds_failure(mds_rank_t who)
 {
   if (who != mds->mdsmap->get_tableserver())
     return; // do nothing.
index 064cc289253317c42f9fa186f18731744506a8e5..a5671d0538e8ec0e58f213f33bf60194fc53a63a 100644 (file)
@@ -80,7 +80,7 @@ public:
     ack_waiters[tid].push_back(c);
   }
 
-  void handle_mds_failure(int mds);
+  void handle_mds_failure(mds_rank_t mds);
 
   // child must implement
   virtual void resend_queries() = 0;
index fc6221c3b49c709de73d274cbedb28844ded6506..42f421351796b0e11e2d51db6de2cfb1af9d2b86 100644 (file)
@@ -54,7 +54,7 @@ public:
 void MDSTableServer::handle_prepare(MMDSTableRequest *req)
 {
   dout(7) << "handle_prepare " << *req << dendl;
-  int from = req->get_source().num();
+  mds_rank_t from = mds_rank_t(req->get_source().num());
   bufferlist bl = req->bl;
 
   _prepare(req->bl, req->reqid, from);
@@ -77,7 +77,7 @@ void MDSTableServer::_prepare_logged(MMDSTableRequest *req, version_t tid)
 
   MMDSTableRequest *reply = new MMDSTableRequest(table, TABLESERVER_OP_AGREE, req->reqid, tid);
   reply->bl = req->bl;
-  mds->send_message_mds(reply, req->get_source().num());
+  mds->send_message_mds(reply, mds_rank_t(req->get_source().num()));
   req->put();
 }
 
@@ -107,7 +107,7 @@ void MDSTableServer::handle_commit(MMDSTableRequest *req)
       return;
 
     _note_commit(tid);
-    mds->mdlog->start_submit_entry(new ETableServer(table, TABLESERVER_OP_COMMIT, 0, -1
+    mds->mdlog->start_submit_entry(new ETableServer(table, TABLESERVER_OP_COMMIT, 0, MDS_RANK_NONE
                                                    tid, version),
                                   new C_Commit(this, req));
   }
@@ -132,7 +132,7 @@ void MDSTableServer::_commit_logged(MMDSTableRequest *req)
   assert(g_conf->mds_kill_mdstable_at != 6);
 
   MMDSTableRequest *reply = new MMDSTableRequest(table, TABLESERVER_OP_ACK, req->reqid, req->get_tid());
-  mds->send_message_mds(reply, req->get_source().num());
+  mds->send_message_mds(reply, mds_rank_t(req->get_source().num()));
   req->put();
 }
 
@@ -146,7 +146,7 @@ void MDSTableServer::handle_rollback(MMDSTableRequest *req)
   assert(pending_for_mds.count(tid));
   _rollback(tid);
   _note_rollback(tid);
-  mds->mdlog->start_submit_entry(new ETableServer(table, TABLESERVER_OP_ROLLBACK, 0, -1
+  mds->mdlog->start_submit_entry(new ETableServer(table, TABLESERVER_OP_ROLLBACK, 0, MDS_RANK_NONE
                                                  tid, version));
   req->put();
 }
@@ -159,7 +159,7 @@ void MDSTableServer::do_server_update(bufferlist& bl)
 {
   dout(10) << "do_server_update len " << bl.length() << dendl;
   _server_update(bl);
-  ETableServer *le = new ETableServer(table, TABLESERVER_OP_SERVER_UPDATE, 0, -1, 0, version);
+  ETableServer *le = new ETableServer(table, TABLESERVER_OP_SERVER_UPDATE, 0, MDS_RANK_NONE, 0, version);
   mds->mdlog->start_entry(le);
   le->mutation = bl;
   mds->mdlog->submit_entry(le);
@@ -168,14 +168,14 @@ void MDSTableServer::do_server_update(bufferlist& bl)
 
 // recovery
 
-void MDSTableServer::finish_recovery(set<int>& active)
+void MDSTableServer::finish_recovery(set<mds_rank_t>& active)
 {
   dout(7) << "finish_recovery" << dendl;
-  for (set<int>::iterator p = active.begin(); p != active.end(); ++p)
+  for (set<mds_rank_t>::iterator p = active.begin(); p != active.end(); ++p)
     handle_mds_recovery(*p);  // resend agrees for everyone.
 }
 
-void MDSTableServer::handle_mds_recovery(int who)
+void MDSTableServer::handle_mds_recovery(mds_rank_t who)
 {
   dout(7) << "handle_mds_recovery mds." << who << dendl;
 
index 8d54693cd6e9b195d21d19c97c6506dcaf756959..b70c260a434005b8b23df8abf876c3717cccca38 100644 (file)
@@ -39,12 +39,12 @@ private:
 
  public:
   virtual void handle_query(MMDSTableRequest *m) = 0;
-  virtual void _prepare(bufferlist &bl, uint64_t reqid, int bymds) = 0;
+  virtual void _prepare(bufferlist &bl, uint64_t reqid, mds_rank_t bymds) = 0;
   virtual bool _commit(version_t tid, MMDSTableRequest *req=NULL) = 0;
   virtual void _rollback(version_t tid) = 0;
   virtual void _server_update(bufferlist& bl) { assert(0); }
 
-  void _note_prepare(int mds, uint64_t reqid) {
+  void _note_prepare(mds_rank_t mds, uint64_t reqid) {
     pending_for_mds[version].mds = mds;
     pending_for_mds[version].reqid = reqid;
     pending_for_mds[version].tid = version;
@@ -76,8 +76,8 @@ private:
   }
 
   // recovery
-  void finish_recovery(set<int>& active);
-  void handle_mds_recovery(int who);
+  void finish_recovery(set<mds_rank_t>& active);
+  void handle_mds_recovery(mds_rank_t who);
 };
 
 #endif
index 81a7565cd42cbbbc7bd52c2b4a8faaed22ec3fe2..b95f861de18bc8c9bd72d6b295c2832dad14740d 100644 (file)
@@ -182,7 +182,7 @@ void Migrator::export_empty_import(CDir *dir)
     return;
   }
   
-  int dest = dir->inode->authority().first;
+  mds_rank_t dest = dir->inode->authority().first;
   //if (mds->is_shutting_down()) dest = 0;  // this is more efficient.
   
   dout(7) << " really empty, exporting to " << dest << dendl;
@@ -360,7 +360,7 @@ void Migrator::export_try_cancel(CDir *dir, bool notify_peer)
 // ==========================================================
 // mds failure handling
 
-void Migrator::handle_mds_failure_or_stop(int who)
+void Migrator::handle_mds_failure_or_stop(mds_rank_t who)
 {
   dout(5) << "handle_mds_failure_or_stop mds." << who << dendl;
 
@@ -639,11 +639,11 @@ void Migrator::audit()
 // ==========================================================
 // EXPORT
 
-void Migrator::export_dir_nicely(CDir *dir, int dest)
+void Migrator::export_dir_nicely(CDir *dir, mds_rank_t dest)
 {
   // enqueue
   dout(7) << "export_dir_nicely " << *dir << " to " << dest << dendl;
-  export_queue.push_back(pair<dirfrag_t,int>(dir->dirfrag(), dest));
+  export_queue.push_back(pair<dirfrag_t,mds_rank_t>(dir->dirfrag(), dest));
 
   maybe_do_queued_export();
 }
@@ -657,7 +657,7 @@ void Migrator::maybe_do_queued_export()
   while (!export_queue.empty() &&
         export_state.size() <= 4) {
     dirfrag_t df = export_queue.front().first;
-    int dest = export_queue.front().second;
+    mds_rank_t dest = export_queue.front().second;
     export_queue.pop_front();
     
     CDir *dir = mds->mdcache->get_dirfrag(df);
@@ -722,7 +722,7 @@ void Migrator::get_export_lock_set(CDir *dir, set<SimpleLock*>& locks)
  * public method to initiate an export.
  * will fail if the directory is freezing, frozen, unpinnable, or root. 
  */
-void Migrator::export_dir(CDir *dir, int dest)
+void Migrator::export_dir(CDir *dir, mds_rank_t dest)
 {
   dout(7) << "export_dir " << *dir << " to " << dest << dendl;
   assert(dir->is_auth());
@@ -852,7 +852,7 @@ void Migrator::handle_export_discover_ack(MExportDirDiscoverAck *m)
   map<CDir*,export_state_t>::iterator it = export_state.find(dir);
   if (it == export_state.end() ||
       it->second.tid != m->get_tid() ||
-      it->second.peer != m->get_source().num()) {
+      it->second.peer != mds_rank_t(m->get_source().num())) {
     dout(7) << "must have aborted" << dendl;
   } else {
     assert(it->second.state == EXPORT_DISCOVERING);
@@ -896,8 +896,8 @@ void Migrator::export_sessions_flushed(CDir *dir, uint64_t tid)
   }
 
   assert(it->second.state == EXPORT_PREPPING || it->second.state == EXPORT_WARNING);
-  assert(it->second.warning_ack_waiting.count(-1) > 0);
-  it->second.warning_ack_waiting.erase(-1);
+  assert(it->second.warning_ack_waiting.count(MDS_RANK_NONE) > 0);
+  it->second.warning_ack_waiting.erase(MDS_RANK_NONE);
   if (it->second.state == EXPORT_WARNING && it->second.warning_ack_waiting.empty())
     export_go(dir);     // start export.
 }
@@ -958,7 +958,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid)
   MExportDirPrep *prep = new MExportDirPrep(dir->dirfrag(), it->second.tid);
 
   // include list of bystanders
-  for (map<int,unsigned>::iterator p = dir->replicas_begin();
+  for (map<mds_rank_t,unsigned>::iterator p = dir->replicas_begin();
        p != dir->replicas_end();
        ++p) {
     if (p->first != it->second.peer) {
@@ -1056,7 +1056,7 @@ void Migrator::export_frozen(CDir *dir, uint64_t tid)
   MDSGatherBuilder gather(g_ceph_context);
   mds->server->flush_client_sessions(export_client_set, gather);
   if (gather.has_subs()) {
-    it->second.warning_ack_waiting.insert(-1);
+    it->second.warning_ack_waiting.insert(MDS_RANK_NONE);
     gather.set_finisher(new C_M_ExportSessionsFlushed(this, dir, it->second.tid));
     gather.activate();
   }
@@ -1113,7 +1113,7 @@ void Migrator::handle_export_prep_ack(MExportDirPrepAck *m)
   map<CDir*,export_state_t>::iterator it = export_state.find(dir);
   if (it == export_state.end() ||
       it->second.tid != m->get_tid() ||
-      it->second.peer != m->get_source().num()) {
+      it->second.peer != mds_rank_t(m->get_source().num())) {
     // export must have aborted.  
     dout(7) << "export must have aborted" << dendl;
     m->put();
@@ -1135,10 +1135,10 @@ void Migrator::handle_export_prep_ack(MExportDirPrepAck *m)
 
   assert(it->second.warning_ack_waiting.empty() ||
          (it->second.warning_ack_waiting.size() == 1 &&
-         it->second.warning_ack_waiting.count(-1) > 0));
+         it->second.warning_ack_waiting.count(MDS_RANK_NONE) > 0));
   assert(it->second.notify_ack_waiting.empty());
 
-  for (map<int,unsigned>::iterator p = dir->replicas_begin();
+  for (map<mds_rank_t,unsigned>::iterator p = dir->replicas_begin();
        p != dir->replicas_end();
        ++p) {
     if (p->first == it->second.peer) continue;
@@ -1148,8 +1148,8 @@ void Migrator::handle_export_prep_ack(MExportDirPrepAck *m)
     it->second.notify_ack_waiting.insert(p->first);  // we'll eventually get a notifyack, too!
 
     MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(), it->second.tid, true,
-                                                   pair<int,int>(mds->get_nodeid(),CDIR_AUTH_UNKNOWN),
-                                                   pair<int,int>(mds->get_nodeid(),it->second.peer));
+                                                   mds_authority_t(mds->get_nodeid(),CDIR_AUTH_UNKNOWN),
+                                                   mds_authority_t(mds->get_nodeid(),it->second.peer));
     for (set<CDir*>::iterator q = bounds.begin(); q != bounds.end(); ++q)
       notify->get_bounds().push_back((*q)->dirfrag());
     mds->send_message_mds(notify, p->first);
@@ -1299,7 +1299,7 @@ void Migrator::encode_export_inode_caps(CInode *in, bool auth_cap, bufferlist& b
     exported_client_map[it->first] = mds->sessionmap.get_inst(entity_name_t::CLIENT(it->first.v));
 }
 
-void Migrator::finish_export_inode_caps(CInode *in, int peer,
+void Migrator::finish_export_inode_caps(CInode *in, mds_rank_t peer,
                                        map<client_t,Capability::Import>& peer_imported)
 {
   dout(20) << "finish_export_inode_caps " << *in << dendl;
@@ -1326,7 +1326,7 @@ void Migrator::finish_export_inode_caps(CInode *in, int peer,
   mds->locker->eval(in, CEPH_CAP_LOCKS);
 }
 
-void Migrator::finish_export_inode(CInode *in, utime_t now, int peer,
+void Migrator::finish_export_inode(CInode *in, utime_t now, mds_rank_t peer,
                                   map<client_t,Capability::Import>& peer_imported,
                                   list<MDSInternalContextBase*>& finished)
 {
@@ -1473,7 +1473,7 @@ int Migrator::encode_export_dir(bufferlist& exportbl,
   return num_exported;
 }
 
-void Migrator::finish_export_dir(CDir *dir, utime_t now, int peer,
+void Migrator::finish_export_dir(CDir *dir, utime_t now, mds_rank_t peer,
                                 map<inodeno_t,map<client_t,Capability::Import> >& peer_imported,
                                 list<MDSInternalContextBase*>& finished, int *num_dentries)
 {
@@ -1595,7 +1595,7 @@ void Migrator::export_notify_abort(CDir *dir, set<CDir*>& bounds)
 
   export_state_t& stat = export_state[dir];
 
-  for (set<int>::iterator p = stat.notify_ack_waiting.begin();
+  for (set<mds_rank_t>::iterator p = stat.notify_ack_waiting.begin();
        p != stat.notify_ack_waiting.end();
        ++p) {
     MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(),stat.tid,false,
@@ -1678,7 +1678,7 @@ void Migrator::export_logged_finish(CDir *dir)
   set<CDir*> bounds;
   cache->get_subtree_bounds(dir, bounds);
 
-  for (set<int>::iterator p = stat.notify_ack_waiting.begin();
+  for (set<mds_rank_t>::iterator p = stat.notify_ack_waiting.begin();
        p != stat.notify_ack_waiting.end();
        ++p) {
     MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(), stat.tid, true,
@@ -1722,7 +1722,7 @@ void Migrator::handle_export_notify_ack(MExportDirNotifyAck *m)
 {
   CDir *dir = cache->get_dirfrag(m->get_dirfrag());
   assert(dir);
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   if (export_state.count(dir)) {
     export_state_t& stat = export_state[dir];
@@ -1851,7 +1851,7 @@ void Migrator::export_finish(CDir *dir)
 
 void Migrator::handle_export_discover(MExportDirDiscover *m)
 {
-  int from = m->get_source_mds();
+  mds_rank_t from = m->get_source_mds();
   assert(from != mds->get_nodeid());
 
   dout(7) << "handle_export_discover on " << m->get_path() << dendl;
@@ -1976,7 +1976,7 @@ void Migrator::handle_export_cancel(MExportDirCancel *m)
 /* This function DOES put the passed message before returning*/
 void Migrator::handle_export_prep(MExportDirPrep *m)
 {
-  int oldauth = m->get_source().num();
+  mds_rank_t oldauth = mds_rank_t(m->get_source().num());
   assert(oldauth != mds->get_nodeid());
 
   CDir *dir;
@@ -2174,12 +2174,12 @@ void Migrator::handle_export_prep(MExportDirPrep *m)
 class C_MDS_ImportDirLoggedStart : public MigratorContext {
   dirfrag_t df;
   CDir *dir;
-  int from;
+  mds_rank_t from;
 public:
   map<client_t,entity_inst_t> imported_client_map;
   map<client_t,uint64_t> sseqmap;
 
-  C_MDS_ImportDirLoggedStart(Migrator *m, CDir *d, int f) :
+  C_MDS_ImportDirLoggedStart(Migrator *m, CDir *d, mds_rank_t f) :
     MigratorContext(m), df(d->dirfrag()), dir(d), from(f) {
   }
   void finish(int r) {
@@ -2200,7 +2200,7 @@ void Migrator::handle_export_dir(MExportDir *m)
   assert(it->second.tid == m->get_tid());
 
   utime_t now = ceph_clock_now(g_ceph_context);
-  int oldauth = m->get_source().num();
+  mds_rank_t oldauth = mds_rank_t(m->get_source().num());
   dout(7) << "handle_export_dir importing " << *dir << " from " << oldauth << dendl;
   assert(dir->is_auth() == false);
 
@@ -2209,7 +2209,8 @@ void Migrator::handle_export_dir(MExportDir *m)
 
   cache->show_subtrees();
 
-  C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(this, dir, m->get_source().num());
+  C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(
+      this, dir, mds_rank_t(m->get_source().num()));
 
   // start the journal entry
   EImportStart *le = new EImportStart(mds->mdlog, dir->dirfrag(), m->bounds);
@@ -2453,7 +2454,7 @@ void Migrator::import_notify_finish(CDir *dir, set<CDir*>& bounds)
   dout(7) << "import_notify_finish " << *dir << dendl;
 
   import_state_t& stat = import_state[dir->dirfrag()];
-  for (set<int>::iterator p = stat.bystanders.begin();
+  for (set<mds_rank_t>::iterator p = stat.bystanders.begin();
        p != stat.bystanders.end();
        ++p) {
     MExportDirNotify *notify =
@@ -2471,13 +2472,13 @@ void Migrator::import_notify_abort(CDir *dir, set<CDir*>& bounds)
   dout(7) << "import_notify_abort " << *dir << dendl;
   
   import_state_t& stat = import_state[dir->dirfrag()];
-  for (set<int>::iterator p = stat.bystanders.begin();
+  for (set<mds_rank_t>::iterator p = stat.bystanders.begin();
        p != stat.bystanders.end();
        ++p) {
     MExportDirNotify *notify =
       new MExportDirNotify(dir->dirfrag(), stat.tid, true,
-                          pair<int,int>(stat.peer, mds->get_nodeid()),
-                          pair<int,int>(stat.peer, CDIR_AUTH_UNKNOWN));
+                          mds_authority_t(stat.peer, mds->get_nodeid()),
+                          mds_authority_t(stat.peer, CDIR_AUTH_UNKNOWN));
     for (set<CDir*>::iterator i = bounds.begin(); i != bounds.end(); ++i)
       notify->get_bounds().push_back((*i)->dirfrag());
     mds->send_message_mds(notify, *p);
@@ -2521,7 +2522,7 @@ void Migrator::import_reverse_final(CDir *dir)
 
 
 
-void Migrator::import_logged_start(dirfrag_t df, CDir *dir, int from,
+void Migrator::import_logged_start(dirfrag_t df, CDir *dir, mds_rank_t from,
                                   map<client_t,entity_inst_t>& imported_client_map,
                                   map<client_t,uint64_t>& sseqmap)
 {
@@ -2548,8 +2549,8 @@ void Migrator::import_logged_start(dirfrag_t df, CDir *dir, int from,
   for (map<CInode*, map<client_t,Capability::Export> >::iterator p = it->second.peer_exports.begin();
        p != it->second.peer_exports.end();
        ++p) {
-    // parameter 'peer' is -1, delay sending cap import messages to client
-    finish_import_inode_caps(p->first, -1, true, p->second, imported_caps[p->first->ino()]);
+    // parameter 'peer' is NONE, delay sending cap import messages to client
+    finish_import_inode_caps(p->first, MDS_RANK_NONE, true, p->second, imported_caps[p->first->ino()]);
   }
   
   // send notify's etc.
@@ -2698,7 +2699,7 @@ void Migrator::import_finish(CDir *dir, bool notify, bool last)
 }
 
 
-void Migrator::decode_import_inode(CDentry *dn, bufferlist::iterator& blp, int oldauth,
+void Migrator::decode_import_inode(CDentry *dn, bufferlist::iterator& blp, mds_rank_t oldauth,
                                   LogSegment *ls, uint64_t log_offset,
                                   map<CInode*, map<client_t,Capability::Export> >& peer_exports,
                                   list<ScatterLock*>& updated_scatterlocks)
@@ -2780,7 +2781,7 @@ void Migrator::decode_import_inode_caps(CInode *in, bool auth_cap,
   }
 }
 
-void Migrator::finish_import_inode_caps(CInode *in, int peer, bool auth_cap,
+void Migrator::finish_import_inode_caps(CInode *in, mds_rank_t peer, bool auth_cap,
                                        map<client_t,Capability::Export> &export_map,
                                        map<client_t,Capability::Import> &import_map)
 {
@@ -2818,7 +2819,7 @@ void Migrator::finish_import_inode_caps(CInode *in, int peer, bool auth_cap,
 }
 
 int Migrator::decode_import_dir(bufferlist::iterator& blp,
-                               int oldauth,
+                               mds_rank_t oldauth,
                                CDir *import_root,
                                EImportStart *le,
                                LogSegment *ls,
@@ -2950,9 +2951,9 @@ void Migrator::handle_export_notify(MExportDirNotify *m)
 {
   CDir *dir = cache->get_dirfrag(m->get_dirfrag());
 
-  int from = m->get_source().num();
-  pair<int,int> old_auth = m->get_old_auth();
-  pair<int,int> new_auth = m->get_new_auth();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
+  mds_authority_t old_auth = m->get_old_auth();
+  mds_authority_t new_auth = m->get_new_auth();
   
   if (!dir) {
     dout(7) << "handle_export_notify " << old_auth << " -> " << new_auth
@@ -2987,7 +2988,7 @@ void Migrator::handle_export_notify(MExportDirNotify *m)
 /** cap exports **/
 void Migrator::export_caps(CInode *in)
 {
-  int dest = in->authority().first;
+  mds_rank_t dest = in->authority().first;
   dout(7) << "export_caps to mds." << dest << " " << *in << dendl;
 
   assert(in->is_any_caps());
@@ -3005,13 +3006,13 @@ void Migrator::export_caps(CInode *in)
 
 class C_M_LoggedImportCaps : public MigratorContext {
   CInode *in;
-  int from;
+  mds_rank_t from;
 public:
   map<CInode*, map<client_t,Capability::Export> > peer_exports;
   map<client_t,entity_inst_t> client_map;
   map<client_t,uint64_t> sseqmap;
 
-  C_M_LoggedImportCaps(Migrator *m, CInode *i, int f) : MigratorContext(m), in(i), from(f) {}
+  C_M_LoggedImportCaps(Migrator *m, CInode *i, mds_rank_t f) : MigratorContext(m), in(i), from(f) {}
   void finish(int r) {
     mig->logged_import_caps(in, from, peer_exports, client_map, sseqmap);
   }  
@@ -3030,7 +3031,8 @@ void Migrator::handle_export_caps(MExportCaps *ex)
   if (in->is_frozen())
     return;
 
-  C_M_LoggedImportCaps *finish = new C_M_LoggedImportCaps(this, in, ex->get_source().num());
+  C_M_LoggedImportCaps *finish = new C_M_LoggedImportCaps(
+      this, in, mds_rank_t(ex->get_source().num()));
   finish->client_map = ex->client_map;
 
   // decode new caps
@@ -3050,7 +3052,7 @@ void Migrator::handle_export_caps(MExportCaps *ex)
 
 
 void Migrator::logged_import_caps(CInode *in, 
-                                 int from,
+                                 mds_rank_t from,
                                  map<CInode*, map<client_t,Capability::Export> >& peer_exports,
                                  map<client_t,entity_inst_t>& client_map,
                                  map<client_t,uint64_t>& sseqmap) 
index 01f3abc12576725fd231c33e18854cf6b654dda4..49c8e6ff1a9fd2a443b8ad7455c64837068a4cea 100644 (file)
@@ -83,10 +83,10 @@ protected:
   // export fun
   struct export_state_t {
     int state;
-    int peer;
+    mds_rank_t peer;
     uint64_t tid;
-    set<int> warning_ack_waiting;
-    set<int> notify_ack_waiting;
+    set<mds_rank_t> warning_ack_waiting;
+    set<mds_rank_t> notify_ack_waiting;
     map<inodeno_t,map<client_t,Capability::Import> > peer_imported;
     list<MDSInternalContextBase*> waiting_for_finish;
     MutationRef mut;
@@ -100,7 +100,7 @@ protected:
 
   map<CDir*, export_state_t>  export_state;
   
-  list<pair<dirfrag_t,int> >  export_queue;
+  list<pair<dirfrag_t,mds_rank_t> >  export_queue;
 
 
   // -- imports --
@@ -131,9 +131,9 @@ public:
 protected:
   struct import_state_t {
     int state;
-    int peer;
+    mds_rank_t peer;
     uint64_t tid;
-    set<int> bystanders;
+    set<mds_rank_t> bystanders;
     list<dirfrag_t> bound_ls;
     list<ScatterLock*> updated_scatterlocks;
     map<client_t,entity_inst_t> client_map;
@@ -197,14 +197,14 @@ public:
   // and are not waiting for @who to be
   // be warned of ambiguous auth.
   // only returns meaningful results during EXPORT_WARNING state.
-  bool export_has_warned(CDir *dir, int who) {
+  bool export_has_warned(CDir *dir, mds_rank_t who) {
     map<CDir*, export_state_t>::iterator it = export_state.find(dir);
     assert(it != export_state.end());
     assert(it->second.state == EXPORT_WARNING);
     return (it->second.warning_ack_waiting.count(who) == 0);
   }
 
-  bool export_has_notified(CDir *dir, int who) {
+  bool export_has_notified(CDir *dir, mds_rank_t who) {
     map<CDir*, export_state_t>::iterator it = export_state.find(dir);
     assert(it != export_state.end());
     assert(it->second.state == EXPORT_NOTIFYING);
@@ -219,7 +219,7 @@ public:
   void find_stale_export_freeze();
 
   // -- misc --
-  void handle_mds_failure_or_stop(int who);
+  void handle_mds_failure_or_stop(mds_rank_t who);
 
   void audit();
 
@@ -227,10 +227,10 @@ public:
   // exporter
  public:
   void dispatch_export_dir(MDRequestRef& mdr);
-  void export_dir(CDir *dir, int dest);
+  void export_dir(CDir *dir, mds_rank_t dest);
   void export_empty_import(CDir *dir);
 
-  void export_dir_nicely(CDir *dir, int dest);
+  void export_dir_nicely(CDir *dir, mds_rank_t dest);
   void maybe_do_queued_export();
   void clear_export_queue() {
     export_queue.clear();
@@ -244,10 +244,10 @@ public:
                           map<client_t,entity_inst_t>& exported_client_map);
   void encode_export_inode_caps(CInode *in, bool auth_cap, bufferlist& bl,
                                map<client_t,entity_inst_t>& exported_client_map);
-  void finish_export_inode(CInode *in, utime_t now, int target,
+  void finish_export_inode(CInode *in, utime_t now, mds_rank_t target,
                           map<client_t,Capability::Import>& peer_imported,
                           list<MDSInternalContextBase*>& finished);
-  void finish_export_inode_caps(CInode *in, int target,
+  void finish_export_inode_caps(CInode *in, mds_rank_t target,
                                map<client_t,Capability::Import>& peer_imported);
 
 
@@ -255,7 +255,7 @@ public:
                        CDir *dir,
                        map<client_t,entity_inst_t>& exported_client_map,
                        utime_t now);
-  void finish_export_dir(CDir *dir, utime_t now, int target,
+  void finish_export_dir(CDir *dir, utime_t now, mds_rank_t target,
                         map<inodeno_t,map<client_t,Capability::Import> >& peer_imported,
                         list<MDSInternalContextBase*>& finished, int *num_dentries);
 
@@ -296,17 +296,17 @@ public:
   void handle_export_dir(MExportDir *m);
 
 public:
-  void decode_import_inode(CDentry *dn, bufferlist::iterator& blp, int oldauth, 
+  void decode_import_inode(CDentry *dn, bufferlist::iterator& blp, mds_rank_t oldauth, 
                           LogSegment *ls, uint64_t log_offset,
                           map<CInode*, map<client_t,Capability::Export> >& cap_imports,
                           list<ScatterLock*>& updated_scatterlocks);
   void decode_import_inode_caps(CInode *in, bool auth_cap, bufferlist::iterator &blp,
                                map<CInode*, map<client_t,Capability::Export> >& cap_imports);
-  void finish_import_inode_caps(CInode *in, int from, bool auth_cap,
+  void finish_import_inode_caps(CInode *in, mds_rank_t from, bool auth_cap,
                                map<client_t,Capability::Export> &export_map,
                                map<client_t,Capability::Import> &import_map);
   int decode_import_dir(bufferlist::iterator& blp,
-                       int oldauth,
+                       mds_rank_t oldauth,
                        CDir *import_root,
                        EImportStart *le, 
                        LogSegment *ls,
@@ -324,7 +324,7 @@ protected:
   void import_reverse_final(CDir *dir);
   void import_notify_abort(CDir *dir, set<CDir*>& bounds);
   void import_notify_finish(CDir *dir, set<CDir*>& bounds);
-  void import_logged_start(dirfrag_t df, CDir *dir, int from,
+  void import_logged_start(dirfrag_t df, CDir *dir, mds_rank_t from,
                           map<client_t,entity_inst_t> &imported_client_map,
                           map<client_t,uint64_t>& sseqmap);
   void handle_export_finish(MExportDirFinish *m);
@@ -334,7 +334,7 @@ protected:
 
   void handle_export_caps(MExportCaps *m);
   void logged_import_caps(CInode *in, 
-                         int from,
+                         mds_rank_t from,
                          map<CInode*, map<client_t,Capability::Export> >& cap_imports,
                          map<client_t,entity_inst_t>& client_map,
                          map<client_t,uint64_t>& sseqmap);
index bcc1efe300bb0ef5db60dc4f670957e24fadf4e6..507f9a5b45badd369ce3d6e2b56c6d80569c4551 100644 (file)
@@ -46,7 +46,7 @@ private:
 
 public:
   // flag mutation as slave
-  int slave_to_mds;                // this is a slave request if >= 0.
+  mds_rank_t slave_to_mds;                // this is a slave request if >= 0.
 
   // -- my pins and locks --
   // cache pins (so things don't expire)
@@ -54,20 +54,20 @@ public:
   set<CInode*> stickydirs;
 
   // auth pins
-  map<MDSCacheObject*,int> remote_auth_pins;
+  map<MDSCacheObject*, mds_rank_t> remote_auth_pins;
   set< MDSCacheObject* > auth_pins;
   
   // held locks
   set< SimpleLock* > rdlocks;  // always local.
   set< SimpleLock* > wrlocks;  // always local.
-  map< SimpleLock*, int > remote_wrlocks;
+  map< SimpleLock*, mds_rank_t > remote_wrlocks;
   set< SimpleLock* > xlocks;   // local or remote.
   set< SimpleLock*, SimpleLock::ptr_lt > locks;  // full ordering
 
   // lock we are currently trying to acquire.  if we give up for some reason,
   // be sure to eval() this.
   SimpleLock *locking;
-  int locking_target_mds;
+  mds_rank_t locking_target_mds;
 
   // if this flag is set, do not attempt to acquire further locks.
   //  (useful for wrlock, which may be a moving auth target)
@@ -88,11 +88,11 @@ public:
   MutationImpl()
     : attempt(0),
       ls(0),
-      slave_to_mds(-1),
+      slave_to_mds(MDS_RANK_NONE),
       locking(NULL),
       locking_target_mds(-1),
       done_locking(false), committing(false), aborted(false), killed(false) { }
-  MutationImpl(metareqid_t ri, __u32 att=0, int slave_to=-1)
+  MutationImpl(metareqid_t ri, __u32 att=0, mds_rank_t slave_to=MDS_RANK_NONE)
     : reqid(ri), attempt(att),
       ls(0),
       slave_to_mds(slave_to), 
@@ -109,8 +109,8 @@ public:
     assert(remote_wrlocks.empty());
   }
 
-  bool is_master() { return slave_to_mds < 0; }
-  bool is_slave() { return slave_to_mds >= 0; }
+  bool is_master() { return slave_to_mds == MDS_RANK_NONE; }
+  bool is_slave() { return slave_to_mds != MDS_RANK_NONE; }
 
   client_t get_client() {
     if (reqid.name.is_client())
@@ -221,19 +221,19 @@ struct MDRequestImpl : public MutationImpl, public TrackedOp {
   // break rarely-used fields into a separately allocated structure 
   // to save memory for most ops
   struct More {
-    set<int> slaves;           // mds nodes that have slave requests to me (implies client_request)
-    set<int> waiting_on_slave; // peers i'm waiting for slavereq replies from. 
+    set<mds_rank_t> slaves;           // mds nodes that have slave requests to me (implies client_request)
+    set<mds_rank_t> waiting_on_slave; // peers i'm waiting for slavereq replies from. 
 
     // for rename/link/unlink
-    set<int> witnessed;       // nodes who have journaled a RenamePrepare
+    set<mds_rank_t> witnessed;       // nodes who have journaled a RenamePrepare
     map<MDSCacheObject*,version_t> pvmap;
 
     bool has_journaled_slaves;
     bool slave_update_journaled;
     
     // for rename
-    set<int> extra_witnesses; // replica list from srcdn auth (rename)
-    int srcdn_auth_mds;
+    set<mds_rank_t> extra_witnesses; // replica list from srcdn auth (rename)
+    mds_rank_t srcdn_auth_mds;
     bufferlist inode_import;
     version_t inode_import_v;
     CInode* rename_inode;
@@ -278,13 +278,13 @@ struct MDRequestImpl : public MutationImpl, public TrackedOp {
     __u32 attempt;
     MClientRequest *client_req;
     class Message *triggering_slave_req;
-    int slave_to;
+    mds_rank_t slave_to;
     utime_t initiated;
     utime_t throttled, all_read, dispatched;
     int internal_op;
     // keep these default values synced to MutationImpl's
     Params() : attempt(0), client_req(NULL),
-        triggering_slave_req(NULL), slave_to(-1), internal_op(-1) {}
+        triggering_slave_req(NULL), slave_to(MDS_RANK_NONE), internal_op(-1) {}
   };
   MDRequestImpl(const Params& params, OpTracker *tracker) :
     MutationImpl(params.reqid, params.attempt, params.slave_to),
index a8c14b1b6a284c4ee6a43bc32a81c7236b237164..84f59faebc8a7a620ad1f0709ce5bc46b47f2630 100644 (file)
@@ -729,7 +729,7 @@ void Server::handle_client_reconnect(MClientReconnect *m)
     } else {
       // don't know if the inode is mine
       dout(10) << "missing ino " << p->first << ", will load later" << dendl;
-      mdcache->rejoin_recovered_caps(p->first, from, p->second, -1);
+      mdcache->rejoin_recovered_caps(p->first, from, p->second, MDS_RANK_NONE);
     }
   }
 
@@ -1113,7 +1113,7 @@ void Server::set_trace_dist(Session *session, MClientReply *reply,
 
   // inode, dentry, dir, ..., inode
   bufferlist bl;
-  int whoami = mds->get_nodeid();
+  mds_rank_t whoami = mds->get_nodeid();
   client_t client = session->get_client();
   utime_t now = ceph_clock_now(g_ceph_context);
 
@@ -1393,7 +1393,7 @@ void Server::dispatch_client_request(MDRequestRef& mdr)
 void Server::handle_slave_request(MMDSSlaveRequest *m)
 {
   dout(4) << "handle_slave_request " << m->get_reqid() << " from " << m->get_source() << dendl;
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   if (logger) logger->inc(l_mdss_handle_slave_request);
 
@@ -1482,7 +1482,7 @@ void Server::handle_slave_request(MMDSSlaveRequest *m)
 /* This function DOES put the passed message before returning*/
 void Server::handle_slave_request_reply(MMDSSlaveRequest *m)
 {
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
   
   if (!mds->is_clientreplay() && !mds->is_active() && !mds->is_stopping()) {
     dout(3) << "not clientreplay|active yet, waiting" << dendl;
@@ -1834,7 +1834,7 @@ void Server::handle_slave_auth_pin(MDRequestRef& mdr)
 void Server::handle_slave_auth_pin_ack(MDRequestRef& mdr, MMDSSlaveRequest *ack)
 {
   dout(10) << "handle_slave_auth_pin_ack on " << *mdr << " " << *ack << dendl;
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   // added auth pins?
   set<MDSCacheObject*> pinned;
@@ -1852,7 +1852,7 @@ void Server::handle_slave_auth_pin_ack(MDRequestRef& mdr, MMDSSlaveRequest *ack)
   }
 
   // removed auth pins?
-  map<MDSCacheObject*,int>::iterator p = mdr->remote_auth_pins.begin();
+  map<MDSCacheObject*, mds_rank_t>::iterator p = mdr->remote_auth_pins.begin();
   while (p != mdr->remote_auth_pins.end()) {
     MDSCacheObject* object = p->first;
     if (p->second == from && pinned.count(object) == 0) {
@@ -2372,7 +2372,7 @@ CDir* Server::try_open_auth_dirfrag(CInode *diri, frag_t fg, MDRequestRef& mdr)
 
   // not open and inode not mine?
   if (!dir && !diri->is_auth()) {
-    int inauth = diri->authority().first;
+    mds_rank_t inauth = diri->authority().first;
     dout(7) << "try_open_auth_dirfrag: not open, not inode auth, fw to mds." << inauth << dendl;
     mdcache->request_forward(mdr, inauth);
     return 0;
@@ -2392,7 +2392,7 @@ CDir* Server::try_open_auth_dirfrag(CInode *diri, frag_t fg, MDRequestRef& mdr)
  
   // am i auth for the dirfrag?
   if (!dir->is_auth()) {
-    int auth = dir->authority().first;
+    mds_rank_t auth = dir->authority().first;
     dout(7) << "try_open_auth_dirfrag: not auth for " << *dir
            << ", fw to mds." << auth << dendl;
     mdcache->request_forward(mdr, auth);
@@ -2526,11 +2526,14 @@ void Server::_lookup_ino_2(MDRequestRef& mdr, int r)
 {
   inodeno_t ino = mdr->client_request->get_filepath().get_ino();
   dout(10) << "_lookup_ino_2 " << mdr.get() << " ino " << ino << " r=" << r << dendl;
+
+  // `r` is a rank if >=0, else an error code
   if (r >= 0) {
-    if (r == mds->get_nodeid())
+    mds_rank_t dest_rank(r);
+    if (dest_rank == mds->get_nodeid())
       dispatch_client_request(mdr);
     else
-      mdcache->request_forward(mdr, r);
+      mdcache->request_forward(mdr, dest_rank);
     return;
   }
 
@@ -4433,7 +4436,7 @@ void Server::_link_remote(MDRequestRef& mdr, bool inc, CDentry *dn, CInode *targ
           << *dn << " to " << *targeti << dendl;
 
   // 1. send LinkPrepare to dest (journal nlink++ prepare)
-  int linkauth = targeti->authority().first;
+  mds_rank_t linkauth = targeti->authority().first;
   if (mdr->more()->witnessed.count(linkauth) == 0) {
     if (!mds->mdsmap->is_clientreplay_or_active_or_stopping(linkauth)) {
       dout(10) << " targeti auth mds." << linkauth << " is not active" << dendl;
@@ -4711,7 +4714,7 @@ struct C_MDS_LoggedLinkRollback : public ServerContext {
   }
 };
 
-void Server::do_link_rollback(bufferlist &rbl, int master, MDRequestRef& mdr)
+void Server::do_link_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr)
 {
   link_rollback rollback;
   bufferlist::iterator p = rbl.begin();
@@ -4793,7 +4796,7 @@ void Server::handle_slave_link_prep_ack(MDRequestRef& mdr, MMDSSlaveRequest *m)
 {
   dout(10) << "handle_slave_link_prep_ack " << *mdr 
           << " " << *m << dendl;
-  int from = m->get_source().num();
+  mds_rank_t from = mds_rank_t(m->get_source().num());
 
   assert(g_conf->mds_kill_link_at != 11);
 
@@ -4928,11 +4931,11 @@ void Server::handle_client_unlink(MDRequestRef& mdr)
   // yay!
   if (in->is_dir() && in->has_subtree_root_dirfrag()) {
     // subtree root auths need to be witnesses
-    set<int> witnesses;
+    set<mds_rank_t> witnesses;
     in->list_replicas(witnesses);
     dout(10) << " witnesses " << witnesses << ", have " << mdr->more()->witnessed << dendl;
 
-    for (set<int>::iterator p = witnesses.begin();
+    for (set<mds_rank_t>::iterator p = witnesses.begin();
         p != witnesses.end();
         ++p) {
       if (mdr->more()->witnessed.count(*p)) {
@@ -5100,7 +5103,7 @@ void Server::_unlink_local_finish(MDRequestRef& mdr,
   dn->get_dir()->try_remove_unlinked_dn(dn);
 }
 
-bool Server::_rmdir_prepare_witness(MDRequestRef& mdr, int who, CDentry *dn, CDentry *straydn)
+bool Server::_rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, CDentry *dn, CDentry *straydn)
 {
   if (!mds->mdsmap->is_clientreplay_or_active_or_stopping(who)) {
     dout(10) << "_rmdir_prepare_witness mds." << who << " is not active" << dendl;
@@ -5261,7 +5264,7 @@ void Server::handle_slave_rmdir_prep_ack(MDRequestRef& mdr, MMDSSlaveRequest *ac
   dout(10) << "handle_slave_rmdir_prep_ack " << *mdr 
           << " " << *ack << dendl;
 
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   mdr->more()->slaves.insert(from);
   mdr->more()->witnessed.insert(from);
@@ -5314,7 +5317,7 @@ struct C_MDS_LoggedRmdirRollback : public ServerContext {
   }
 };
 
-void Server::do_rmdir_rollback(bufferlist &rbl, int master, MDRequestRef& mdr)
+void Server::do_rmdir_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr)
 {
   // unlink the other rollback methods, the rmdir rollback is only
   // needed to record the subtree changes in the journal for inode
@@ -5681,7 +5684,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
    * (currently, it can ignore rename effects, because the resolve
    * stage will sort them out.)
    */
-  set<int> witnesses = mdr->more()->extra_witnesses;
+  set<mds_rank_t> witnesses = mdr->more()->extra_witnesses;
   if (srcdn->is_auth())
     srcdn->list_replicas(witnesses);
   else
@@ -5697,13 +5700,13 @@ void Server::handle_client_rename(MDRequestRef& mdr)
 
 
   // -- locks --
-  map<SimpleLock*, int> remote_wrlocks;
+  map<SimpleLock*, mds_rank_t> remote_wrlocks;
 
   // srctrace items.  this mirrors locks taken in rdlock_path_xlock_dentry
   for (int i=0; i<(int)srctrace.size(); i++) 
     rdlocks.insert(&srctrace[i]->lock);
   xlocks.insert(&srcdn->lock);
-  int srcdirauth = srcdn->get_dir()->authority().first;
+  mds_rank_t srcdirauth = srcdn->get_dir()->authority().first;
   if (srcdirauth != mds->whoami) {
     dout(10) << " will remote_wrlock srcdir scatterlocks on mds." << srcdirauth << dendl;
     remote_wrlocks[&srcdn->get_dir()->inode->filelock] = srcdirauth;
@@ -5817,7 +5820,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
   // -- prepare witnesses --
 
   // do srcdn auth last
-  int last = -1;
+  mds_rank_t last = MDS_RANK_NONE;
   if (!srcdn->is_auth()) {
     last = srcdn->authority().first;
     mdr->more()->srcdn_auth_mds = last;
@@ -5831,7 +5834,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
     }
   }
   
-  for (set<int>::iterator p = witnesses.begin();
+  for (set<mds_rank_t>::iterator p = witnesses.begin();
        p != witnesses.end();
        ++p) {
     if (*p == last) continue;  // do it last!
@@ -5847,7 +5850,7 @@ void Server::handle_client_rename(MDRequestRef& mdr)
   if (!mdr->more()->waiting_on_slave.empty())
     return;  // we're waiting for a witness.
 
-  if (last >= 0 && mdr->more()->witnessed.count(last) == 0) {
+  if (last != MDS_RANK_NONE && mdr->more()->witnessed.count(last) == 0) {
     dout(10) << " preparing last witness (srcdn auth)" << dendl;
     assert(mdr->more()->waiting_on_slave.count(last) == 0);
     _rename_prepare_witness(mdr, last, witnesses, srcdn, destdn, straydn);
@@ -5937,7 +5940,7 @@ void Server::_rename_finish(MDRequestRef& mdr, CDentry *srcdn, CDentry *destdn,
 
 // helpers
 
-bool Server::_rename_prepare_witness(MDRequestRef& mdr, int who, set<int> &witnesse,
+bool Server::_rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set<mds_rank_t> &witnesse,
                                     CDentry *srcdn, CDentry *destdn, CDentry *straydn)
 {
   if (!mds->mdsmap->is_clientreplay_or_active_or_stopping(who)) {
@@ -6550,7 +6553,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
 
   // am i srcdn auth?
   if (srcdn->is_auth()) {
-    set<int> srcdnrep;
+    set<mds_rank_t> srcdnrep;
     srcdn->list_replicas(srcdnrep);
 
     bool reply_witness = false;
@@ -6590,7 +6593,7 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
       }
 
       // make sure bystanders have received all lock related messages
-      for (set<int>::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) {
+      for (set<mds_rank_t>::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) {
        if (*p == mdr->slave_to_mds ||
            !mds->mdsmap->is_clientreplay_or_active_or_stopping(*p))
          continue;
@@ -6607,14 +6610,14 @@ void Server::handle_slave_rename_prep(MDRequestRef& mdr)
       MDSGatherBuilder gather(g_ceph_context);
       flush_client_sessions(export_client_set, gather);
       if (gather.has_subs()) {
-       mdr->more()->waiting_on_slave.insert(-1);
+       mdr->more()->waiting_on_slave.insert(MDS_RANK_NONE);
        gather.set_finisher(new C_MDS_SlaveRenameSessionsFlushed(this, mdr));
        gather.activate();
       }
     }
 
     // is witness list sufficient?
-    for (set<int>::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) {
+    for (set<mds_rank_t>::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) {
       if (*p == mdr->slave_to_mds ||
          mdr->slave_request->witnesses.count(*p)) continue;
       dout(10) << " witness list insufficient; providing srcdn replica list" << dendl;
@@ -6922,7 +6925,7 @@ struct C_MDS_LoggedRenameRollback : public ServerContext {
   }
 };
 
-void Server::do_rename_rollback(bufferlist &rbl, int master, MDRequestRef& mdr,
+void Server::do_rename_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr,
                                bool finish_mdr)
 {
   rename_rollback rollback;
@@ -6998,7 +7001,7 @@ void Server::do_rename_rollback(bufferlist &rbl, int master, MDRequestRef& mdr,
     target = mds->mdcache->get_inode(rollback.orig_dest.remote_ino);
 
   // can't use is_auth() in the resolve stage
-  int whoami = mds->get_nodeid();
+  mds_rank_t whoami = mds->get_nodeid();
   // slave
   assert(!destdn || destdn->authority().first != whoami);
   assert(!straydn || straydn->authority().first != whoami);
@@ -7232,7 +7235,7 @@ void Server::handle_slave_rename_prep_ack(MDRequestRef& mdr, MMDSSlaveRequest *a
   dout(10) << "handle_slave_rename_prep_ack " << *mdr 
           << " witnessed by " << ack->get_source()
           << " " << *ack << dendl;
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   // note slave
   mdr->more()->slaves.insert(from);
@@ -7271,7 +7274,7 @@ void Server::handle_slave_rename_notify_ack(MDRequestRef& mdr, MMDSSlaveRequest
   dout(10) << "handle_slave_rename_notify_ack " << *mdr << " from mds."
           << ack->get_source() << dendl;
   assert(mdr->is_slave());
-  int from = ack->get_source().num();
+  mds_rank_t from = mds_rank_t(ack->get_source().num());
 
   if (mdr->more()->waiting_on_slave.count(from)) {
     mdr->more()->waiting_on_slave.erase(from);
@@ -7289,8 +7292,8 @@ void Server::_slave_rename_sessions_flushed(MDRequestRef& mdr)
 {
   dout(10) << "_slave_rename_sessions_flushed " << *mdr << dendl;
 
-  if (mdr->more()->waiting_on_slave.count(-1)) {
-    mdr->more()->waiting_on_slave.erase(-1);
+  if (mdr->more()->waiting_on_slave.count(MDS_RANK_NONE)) {
+    mdr->more()->waiting_on_slave.erase(MDS_RANK_NONE);
 
     if (mdr->more()->waiting_on_slave.empty()) {
       if (mdr->slave_request)
index 11ac54e12a3a0e759e816506504c76b927808324..fd93158d8bce77bca978a170c848702aff97765e 100644 (file)
@@ -208,7 +208,7 @@ public:
   void _commit_slave_link(MDRequestRef& mdr, int r, CInode *targeti);
   void _committed_slave(MDRequestRef& mdr);  // use for rename, too
   void handle_slave_link_prep_ack(MDRequestRef& mdr, MMDSSlaveRequest *m);
-  void do_link_rollback(bufferlist &rbl, int master, MDRequestRef& mdr);
+  void do_link_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr);
   void _link_rollback_finish(MutationRef& mut, MDRequestRef& mdr);
 
   // unlink
@@ -219,12 +219,12 @@ public:
   void _unlink_local_finish(MDRequestRef& mdr,
                            CDentry *dn, CDentry *straydn,
                            version_t);
-  bool _rmdir_prepare_witness(MDRequestRef& mdr, int who, CDentry *dn, CDentry *straydn);
+  bool _rmdir_prepare_witness(MDRequestRef& mdr, mds_rank_t who, CDentry *dn, CDentry *straydn);
   void handle_slave_rmdir_prep(MDRequestRef& mdr);
   void _logged_slave_rmdir(MDRequestRef& mdr, CDentry *srcdn, CDentry *straydn);
   void _commit_slave_rmdir(MDRequestRef& mdr, int r);
   void handle_slave_rmdir_prep_ack(MDRequestRef& mdr, MMDSSlaveRequest *ack);
-  void do_rmdir_rollback(bufferlist &rbl, int master, MDRequestRef& mdr);
+  void do_rmdir_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr);
   void _rmdir_rollback_finish(MDRequestRef& mdr, metareqid_t reqid, CDentry *dn, CDentry *straydn);
 
   // rename
@@ -239,7 +239,7 @@ public:
   void _rmsnap_finish(MDRequestRef& mdr, CInode *diri, snapid_t snapid);
 
   // helpers
-  bool _rename_prepare_witness(MDRequestRef& mdr, int who, set<int> &witnesse,
+  bool _rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set<mds_rank_t> &witnesse,
                               CDentry *srcdn, CDentry *destdn, CDentry *straydn);
   version_t _rename_prepare_import(MDRequestRef& mdr, CDentry *srcdn, bufferlist *client_map_bl);
   bool _need_force_journal(CInode *diri, bool empty);
@@ -258,7 +258,7 @@ public:
   void _slave_rename_sessions_flushed(MDRequestRef& mdr);
   void _logged_slave_rename(MDRequestRef& mdr, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
   void _commit_slave_rename(MDRequestRef& mdr, int r, CDentry *srcdn, CDentry *destdn, CDentry *straydn);
-  void do_rename_rollback(bufferlist &rbl, int master, MDRequestRef& mdr, bool finish_mdr=false);
+  void do_rename_rollback(bufferlist &rbl, mds_rank_t master, MDRequestRef& mdr, bool finish_mdr=false);
   void _rename_rollback_finish(MutationRef& mut, MDRequestRef& mdr, CDentry *srcdn, version_t srcdnpv,
                               CDentry *destdn, CDentry *staydn, bool finish_mdr);
 
index 289e80ac02b2c096d7872b56c44485098414226f..2f703efc87a37200fd564a28fad44e7a54ca6453 100644 (file)
@@ -63,7 +63,7 @@ void SessionMap::dump()
 object_t SessionMap::get_object_name()
 {
   char s[30];
-  snprintf(s, sizeof(s), "mds%d_sessionmap", mds->whoami);
+  snprintf(s, sizeof(s), "mds%d_sessionmap", int(mds->whoami));
   return object_t(s);
 }
 
index 06811975eb0a047af2c29e840f42f903a516d4a5..28bb75ab5c8f35722d06378fdaef6a87f3e62284 100644 (file)
@@ -359,14 +359,15 @@ public:
   }
 
   // gather set
-  static set<int> empty_gather_set;
+  static set<int32_t> empty_gather_set;
 
-  const set<int>& get_gather_set() const {
+  // int32_t: <0 is client, >=0 is MDS rank
+  const set<int32_t>& get_gather_set() const {
     return have_more() ? more()->gather_set : empty_gather_set;
   }
 
   void init_gather() {
-    for (map<int,unsigned>::const_iterator p = parent->replicas_begin();
+    for (map<mds_rank_t,unsigned>::const_iterator p = parent->replicas_begin();
         p != parent->replicas_end(); 
         ++p)
       more()->gather_set.insert(p->first);
@@ -374,14 +375,14 @@ public:
   bool is_gathering() const {
     return have_more() && !more()->gather_set.empty();
   }
-  bool is_gathering(int i) const {
+  bool is_gathering(int32_t i) const {
     return have_more() && more()->gather_set.count(i);
   }
   void clear_gather() {
     if (have_more())
       more()->gather_set.clear();
   }
-  void remove_gather(int i) {
+  void remove_gather(int32_t i) {
     if (have_more())
       more()->gather_set.erase(i);
   }
@@ -552,7 +553,7 @@ public:
   void decode(bufferlist::iterator& p) {
     DECODE_START(2, p);
     ::decode(state, p);
-    set<int> g;
+    set<__s32> g;
     ::decode(g, p);
     if (!g.empty())
       more()->gather_set.swap(g);
index adbccd037294cf7994bc08fc941c49be83f1a91e..2e211d9f894015c987a4e5c91fc3d4897f09370f 100644 (file)
@@ -42,7 +42,7 @@ void SnapServer::reset_state()
 
 // SERVER
 
-void SnapServer::_prepare(bufferlist &bl, uint64_t reqid, int bymds)
+void SnapServer::_prepare(bufferlist &bl, uint64_t reqid, mds_rank_t bymds)
 {
   bufferlist::iterator p = bl.begin();
   __u32 op;
index 95e15080df00cdcef2bff254d5786c1e95e1ba40..13669fccd3a21c6853f4c1c37d76fd3e0221fb0f 100644 (file)
@@ -79,7 +79,7 @@ public:
   static void generate_test_instances(list<SnapServer*>& ls);
 
   // server bits
-  void _prepare(bufferlist &bl, uint64_t reqid, int bymds);
+  void _prepare(bufferlist &bl, uint64_t reqid, mds_rank_t bymds);
   bool _is_prepared(version_t tid);
   bool _commit(version_t tid, MMDSTableRequest *req=NULL);
   void _rollback(version_t tid);
index 9745139339ad4bfd42ca7756b7dc9579080a046c..bfac1216d397991141dedbdff04288fa330344d1 100644 (file)
@@ -113,7 +113,7 @@ public:
   bufferlist rollback;
   string type;
   metareqid_t reqid;
-  __s32 master;
+  mds_rank_t master;
   __u8 op;  // prepare, commit, abort
   __u8 origop; // link | rename
 
index 132d3b6a6c90c8586e9b91d96b33c6cb669298bf..6dff2eb798aaaa30f38520a36ae60a5f79a7860b 100644 (file)
@@ -25,14 +25,14 @@ struct ETableServer : public LogEvent {
   __u16 table;
   __s16 op;
   uint64_t reqid;
-  __s32 bymds;
+  mds_rank_t bymds;
   bufferlist mutation;
   version_t tid;
   version_t version;
 
   ETableServer() : LogEvent(EVENT_TABLESERVER), table(0), op(0),
-                  reqid(0), bymds(0), tid(0), version(0) { }
-  ETableServer(int t, int o, uint64_t ri, int m, version_t ti, version_t v) :
+                  reqid(0), bymds(MDS_RANK_NONE), tid(0), version(0) { }
+  ETableServer(int t, int o, uint64_t ri, mds_rank_t m, version_t ti, version_t v) :
     LogEvent(EVENT_TABLESERVER),
     table(t), op(o), reqid(ri), bymds(m), tid(ti), version(v) { }
 
index 41e36ad6b3c27a9856812e1187db30984e70da00..c0530bc87076c6d5eeba5ce2ecd89f5edc1b0252 100644 (file)
@@ -2017,7 +2017,7 @@ void EUpdate::replay(MDS *mds)
   if (had_slaves) {
     dout(10) << "EUpdate.replay " << reqid << " had slaves, expecting a matching ECommitted" << dendl;
     _segment->uncommitted_masters.insert(reqid);
-    set<int> slaves;
+    set<mds_rank_t> slaves;
     mds->mdcache->add_uncommitted_master(reqid, _segment, slaves, true);
   }
   
@@ -2599,7 +2599,7 @@ void ESubtreeMap::replay(MDS *mds)
       // ambiguous!
       mds->mdcache->add_ambiguous_import(p->first, p->second);
       mds->mdcache->adjust_bounded_subtree_auth(dir, p->second,
-                                               pair<int,int>(mds->get_nodeid(), mds->get_nodeid()));
+                                               mds_authority_t(mds->get_nodeid(), mds->get_nodeid()));
     } else {
       // not ambiguous
       mds->mdcache->adjust_bounded_subtree_auth(dir, p->second, mds->get_nodeid());
@@ -2838,7 +2838,7 @@ void EImportStart::replay(MDS *mds)
   }
 
   mds->mdcache->adjust_bounded_subtree_auth(dir, realbounds,
-                                           pair<int,int>(mds->get_nodeid(), mds->get_nodeid()));
+                                           mds_authority_t(mds->get_nodeid(), mds->get_nodeid()));
 
   // open client sessions?
   if (mds->sessionmap.version >= cmapv) {
index eb1ae77d655c1064c3f2a0fb667a48541543cdae..0944f61672f8e18c020f1567bc75a21e1b93469f 100644 (file)
@@ -4,6 +4,9 @@
 #include "mdstypes.h"
 #include "common/Formatter.h"
 
+const mds_gid_t MDS_GID_NONE = mds_gid_t(0);
+const mds_rank_t MDS_RANK_NONE = mds_rank_t(-1);
+
 void dump(const ceph_file_layout& l, Formatter *f)
 {
   f->dump_unsigned("stripe_unit", l.fl_stripe_unit);
index d7c2665058b63c2dd5ac58a990884d0949ae892c..56ce23399e55f57593a73d75ead0c74c91642432 100644 (file)
@@ -24,6 +24,7 @@
 #include <boost/pool/pool.hpp>
 #include "include/assert.h"
 #include "include/hash_namespace.h"
+#include <boost/serialization/strong_typedef.hpp>
 
 
 #define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011"
 #define MDS_TRAVERSE_DISCOVERXLOCK 3    // succeeds on (foreign?) null, xlocked dentries.
 
 
+BOOST_STRONG_TYPEDEF(int32_t, mds_rank_t)
+BOOST_STRONG_TYPEDEF(uint64_t, mds_gid_t)
+extern const mds_gid_t MDS_GID_NONE;
+extern const mds_rank_t MDS_RANK_NONE;
+
+
 extern long g_num_ino, g_num_dir, g_num_dn, g_num_cap;
 extern long g_num_inoa, g_num_dira, g_num_dna, g_num_capa;
 extern long g_num_inos, g_num_dirs, g_num_dns, g_num_caps;
@@ -1040,16 +1047,18 @@ class SimpleLock;
 
 class MDSCacheObject;
 
+typedef std::pair<mds_rank_t, mds_rank_t> mds_authority_t;
 // -- authority delegation --
 // directory authority types
 //  >= 0 is the auth mds
-#define CDIR_AUTH_PARENT   -1   // default
-#define CDIR_AUTH_UNKNOWN  -2
-#define CDIR_AUTH_DEFAULT   pair<int,int>(-1, -2)
-#define CDIR_AUTH_UNDEF     pair<int,int>(-2, -2)
+#define CDIR_AUTH_PARENT   mds_rank_t(-1)   // default
+#define CDIR_AUTH_UNKNOWN  mds_rank_t(-2)
+#define CDIR_AUTH_DEFAULT   mds_authority_t(CDIR_AUTH_PARENT, CDIR_AUTH_UNKNOWN)
+#define CDIR_AUTH_UNDEF     mds_authority_t(CDIR_AUTH_UNKNOWN, CDIR_AUTH_UNKNOWN)
 //#define CDIR_AUTH_ROOTINODE pair<int,int>( 0, -2)
 
 
+
 /*
  * for metadata leases to clients
  */
@@ -1181,7 +1190,7 @@ class MDSCacheObject {
 
   // --------------------------------------------
   // authority
-  virtual pair<int,int> authority() = 0;
+  virtual mds_authority_t authority() = 0;
   bool is_ambiguous_auth() {
     return authority().second != CDIR_AUTH_UNKNOWN;
   }
@@ -1294,29 +1303,29 @@ protected:
   // replication (across mds cluster)
  protected:
   unsigned             replica_nonce; // [replica] defined on replica
-  std::map<int,unsigned>       replica_map;   // [auth] mds -> nonce
+  std::map<mds_rank_t,unsigned>        replica_map;   // [auth] mds -> nonce
 
  public:
   bool is_replicated() { return !replica_map.empty(); }
-  bool is_replica(int mds) { return replica_map.count(mds); }
+  bool is_replica(mds_rank_t mds) { return replica_map.count(mds); }
   int num_replicas() { return replica_map.size(); }
-  unsigned add_replica(int mds) {
+  unsigned add_replica(mds_rank_t 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, unsigned nonce) {
+  void add_replica(mds_rank_t mds, unsigned nonce) {
     if (replica_map.empty()) 
       get(PIN_REPLICATED);
     replica_map[mds] = nonce;
   }
-  unsigned get_replica_nonce(int mds) {
+  unsigned get_replica_nonce(mds_rank_t mds) {
     assert(replica_map.count(mds));
     return replica_map[mds];
   }
-  void remove_replica(int mds) {
+  void remove_replica(mds_rank_t mds) {
     assert(replica_map.count(mds));
     replica_map.erase(mds);
     if (replica_map.empty())
@@ -1327,11 +1336,11 @@ protected:
       put(PIN_REPLICATED);
     replica_map.clear();
   }
-  std::map<int,unsigned>::iterator replicas_begin() { return replica_map.begin(); }
-  std::map<int,unsigned>::iterator replicas_end() { return replica_map.end(); }
-  const std::map<int,unsigned>& get_replicas() { return replica_map; }
-  void list_replicas(std::set<int>& ls) {
-    for (std::map<int,unsigned>::const_iterator p = replica_map.begin();
+  std::map<mds_rank_t,unsigned>::iterator replicas_begin() { return replica_map.begin(); }
+  std::map<mds_rank_t,unsigned>::iterator replicas_end() { return replica_map.end(); }
+  const std::map<mds_rank_t,unsigned>& get_replicas() { return replica_map; }
+  void list_replicas(std::set<mds_rank_t>& ls) {
+    for (std::map<mds_rank_t,unsigned>::const_iterator p = replica_map.begin();
         p != replica_map.end();
         ++p) 
       ls.insert(p->first);
index 445cd828cfe9823a7de54aa981040ebbb6fbcccb..8f461630dfaf7f2ec51ed735309ff48006a4b504 100644 (file)
@@ -19,7 +19,7 @@
 #include "msg/Message.h"
 
 class MDirUpdate : public Message {
-  int32_t from_mds;
+  mds_rank_t from_mds;
   dirfrag_t dirfrag;
   int32_t dir_rep;
   int32_t discover;
@@ -27,7 +27,7 @@ class MDirUpdate : public Message {
   filepath path;
 
  public:
-  int get_source_mds() const { return from_mds; }
+  mds_rank_t get_source_mds() const { return from_mds; }
   dirfrag_t get_dirfrag() const { return dirfrag; }
   int get_dir_rep() const { return dir_rep; }
   const set<int>& get_dir_rep_by() const { return dir_rep_by; } 
@@ -39,7 +39,7 @@ class MDirUpdate : public Message {
   }
 
   MDirUpdate() : Message(MSG_MDS_DIRUPDATE) {}
-  MDirUpdate(int f, 
+  MDirUpdate(mds_rank_t f, 
             dirfrag_t dirfrag,
              int dir_rep,
              set<int>& dir_rep_by,
index 4c2527802b974d683af37110e424b4da3a879c30..dfb27606dcaeeea8b719c3e94a55c485ac60a853 100644 (file)
@@ -80,7 +80,7 @@ class MDiscoverReply : public Message {
   std::string error_dentry;   // dentry that was not found (to trigger waiters on asker)
   bool unsolicited;
 
-  __s32 dir_auth_hint;
+  mds_rank_t dir_auth_hint;
 
  public:
   __u8 starts_with;
@@ -101,7 +101,7 @@ class MDiscoverReply : public Message {
 
   int get_starts_with() { return starts_with; }
 
-  int get_dir_auth_hint() { return dir_auth_hint; }
+  mds_rank_t get_dir_auth_hint() const { return dir_auth_hint; }
 
   bool is_unsolicited() { return unsolicited; }
   void mark_unsolicited() { unsolicited = true; }
index 0b29daf14f54c50f6368a2b15cdb4b6022b76695..c5bbcebd68b2cc0f0dd32d33511ec304d1286798 100644 (file)
 #include "include/types.h"
 
 class MExportDirDiscover : public Message {
-  int32_t from;
+  mds_rank_t from;
   dirfrag_t dirfrag;
   filepath path;
 
  public:
-  int get_source_mds() { return from; }
+  mds_rank_t get_source_mds() { return from; }
   inodeno_t get_ino() { return dirfrag.ino; }
   dirfrag_t get_dirfrag() { return dirfrag; }
   filepath& get_path() { return path; }
@@ -34,7 +34,7 @@ class MExportDirDiscover : public Message {
   MExportDirDiscover() :     
     Message(MSG_MDS_EXPORTDIRDISCOVER),
     started(false) { }
-  MExportDirDiscover(dirfrag_t df, filepath& p, int f, uint64_t tid) :
+  MExportDirDiscover(dirfrag_t df, filepath& p, mds_rank_t f, uint64_t tid) :
     Message(MSG_MDS_EXPORTDIRDISCOVER),
     from(f), dirfrag(df), path(p), started(false) {
     set_tid(tid);
index 791a98abc18f63015e1f864a23d09658f1727c9a..23da166a3201c3d9c979216d65d8f44626394c0e 100644 (file)
@@ -26,13 +26,13 @@ class MExportDirPrep : public Message {
   list<dirfrag_t> bounds;
   list<bufferlist> traces;
 private:
-  set<__s32> bystanders;
+  set<mds_rank_t> bystanders;
   bool b_did_assim;
 
 public:
   dirfrag_t get_dirfrag() { return dirfrag; }
   list<dirfrag_t>& get_bounds() { return bounds; }
-  set<__s32> &get_bystanders() { return bystanders; }
+  set<mds_rank_t> &get_bystanders() { return bystanders; }
 
   bool did_assim() { return b_did_assim; }
   void mark_assim() { b_did_assim = true; }
@@ -60,7 +60,7 @@ public:
   void add_trace(bufferlist& bl) {
     traces.push_back(bl);
   }
-  void add_bystander(int who) {
+  void add_bystander(mds_rank_t who) {
     bystanders.insert(who);
   }
 
index b6cfcfaf0106e7edfea05d5afdafcf1db4809ef7..802e9661530baa9f9f7f8014c2e165f25c8ad32d 100644 (file)
 class MHeartbeat : public Message {
   mds_load_t load;
   __s32        beat;
-  map<__s32, float> import_map;
+  map<mds_rank_t, float> import_map;
 
  public:
   mds_load_t& get_load() { return load; }
   int get_beat() { return beat; }
 
-  map<__s32, float>& get_import_map() {
+  map<mds_rank_t, float>& get_import_map() {
     return import_map;
   }
 
index af62e439627ee13e9730566cd6bc61c0e6be74f8..48d5d04e561146537d464437ea36b686a6c00eb9 100644 (file)
@@ -124,12 +124,12 @@ class MMDSBeacon : public PaxosServiceMessage {
   static const int COMPAT_VERSION = 2;
 
   uuid_d fsid;
-  uint64_t global_id;
+  mds_gid_t global_id;
   string name;
 
   MDSMap::DaemonState state;
   version_t seq;
-  __s32 standby_for_rank;
+  mds_rank_t standby_for_rank;
   string standby_for_name;
 
   CompatSet compat;
@@ -138,23 +138,23 @@ class MMDSBeacon : public PaxosServiceMessage {
 
  public:
   MMDSBeacon() : PaxosServiceMessage(MSG_MDS_BEACON, 0, HEAD_VERSION, COMPAT_VERSION) { }
-  MMDSBeacon(const uuid_d &f, uint64_t g, string& n, epoch_t les, MDSMap::DaemonState st, version_t se) : 
+  MMDSBeacon(const uuid_d &f, mds_gid_t g, string& n, epoch_t les, MDSMap::DaemonState st, version_t se) : 
     PaxosServiceMessage(MSG_MDS_BEACON, les, HEAD_VERSION, COMPAT_VERSION),
     fsid(f), global_id(g), name(n), state(st), seq(se),
-    standby_for_rank(-1) {
+    standby_for_rank(MDS_RANK_NONE) {
   }
 private:
   ~MMDSBeacon() {}
 
 public:
   uuid_d& get_fsid() { return fsid; }
-  uint64_t get_global_id() { return global_id; }
+  mds_gid_t get_global_id() { return global_id; }
   string& get_name() { return name; }
   epoch_t get_last_epoch_seen() { return version; }
   MDSMap::DaemonState get_state() { return state; }
   version_t get_seq() { return seq; }
   const char *get_type_name() const { return "mdsbeacon"; }
-  int get_standby_for_rank() { return standby_for_rank; }
+  mds_rank_t get_standby_for_rank() { return standby_for_rank; }
   const string& get_standby_for_name() { return standby_for_name; }
 
   CompatSet const& get_compat() const { return compat; }
@@ -163,7 +163,7 @@ public:
   MDSHealth const& get_health() const { return health; }
   void set_health(const MDSHealth &h) { health = h; }
 
-  void set_standby_for_rank(int r) { standby_for_rank = r; }
+  void set_standby_for_rank(mds_rank_t r) { standby_for_rank = r; }
   void set_standby_for_name(string& n) { standby_for_name = n; }
   void set_standby_for_name(const char* c) { standby_for_name.assign(c); }
 
index 4022f32e36b3a419a7635d3ad9325ab916ddddf8..d559581a1065b8ee1a9a14eb78d1f9b0852e3f2e 100644 (file)
@@ -24,12 +24,12 @@ using std::map;
 
 class MMDSLoadTargets : public PaxosServiceMessage {
  public:
-  uint64_t global_id;
-  set<int32_t> targets;
+  mds_gid_t global_id;
+  set<mds_rank_t> targets;
 
   MMDSLoadTargets() : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0) {}
 
-  MMDSLoadTargets(uint64_t g, set<int32_t>& mds_targets) :
+  MMDSLoadTargets(mds_gid_t g, set<mds_rank_t>& mds_targets) :
     PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0),
     global_id(g), targets(mds_targets) {}
 private:
index 5204d3c792b7f4fceb9fc5d0ccb24961294fccc4..1bf41b88268f0dc24281a4628dec8ec0b7ef5b4e 100644 (file)
 struct MMDSOpenInoReply : public Message {
   inodeno_t ino;
   vector<inode_backpointer_t> ancestors;
-  int32_t hint;
+  mds_rank_t hint;
   int32_t error;
 
   MMDSOpenInoReply() : Message(MSG_MDS_OPENINOREPLY) {}
-  MMDSOpenInoReply(ceph_tid_t t, inodeno_t i, int h=-1, int e=0) :
+  MMDSOpenInoReply(ceph_tid_t t, inodeno_t i, mds_rank_t h=MDS_RANK_NONE, int e=0) :
     Message(MSG_MDS_OPENINOREPLY), ino(i), hint(h), error(e) {
     header.tid = t;
   }
index f64089ea8364f4b6d3bf1feaa417c7b20a8f8c60..a11337c91910face3e480aad97094f19577701c7 100644 (file)
@@ -111,7 +111,7 @@ class MMDSSlaveRequest : public Message {
   // for rename prep
   filepath srcdnpath;
   filepath destdnpath;
-  set<__s32> witnesses;
+  set<mds_rank_t> witnesses;
   bufferlist inode_export;
   version_t inode_export_v;
   bufferlist srci_replica;
index fe6fe23d97430da4c48ee26879c41c895b54a1cf..d8050a8cc0c3ab08b1dd0e40cb765ddf216a7d42 100644 (file)
@@ -205,7 +205,7 @@ bool MDSMonitor::preprocess_query(PaxosServiceMessage *m)
 
 void MDSMonitor::_note_beacon(MMDSBeacon *m)
 {
-  uint64_t gid = m->get_global_id();
+  mds_gid_t gid = mds_gid_t(m->get_global_id());
   version_t seq = m->get_seq();
 
   dout(15) << "_note_beacon " << *m << " noting time" << dendl;
@@ -216,7 +216,7 @@ void MDSMonitor::_note_beacon(MMDSBeacon *m)
 bool MDSMonitor::preprocess_beacon(MMDSBeacon *m)
 {
   MDSMap::DaemonState state = m->get_state();
-  uint64_t gid = m->get_global_id();
+  mds_gid_t gid = m->get_global_id();
   version_t seq = m->get_seq();
   MDSMap::mds_info_t info;
 
@@ -343,7 +343,7 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m)
 bool MDSMonitor::preprocess_offload_targets(MMDSLoadTargets* m)
 {
   dout(10) << "preprocess_offload_targets " << *m << " from " << m->get_orig_source() << dendl;
-  uint64_t gid;
+  mds_gid_t gid;
   
   // check privileges, ignore message if fails
   MonSession *session = m->get_session();
@@ -398,7 +398,7 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m)
   // -- this is an update --
   dout(12) << "prepare_beacon " << *m << " from " << m->get_orig_source_inst() << dendl;
   entity_addr_t addr = m->get_orig_source_inst().addr;
-  uint64_t gid = m->get_global_id();
+  mds_gid_t gid = m->get_global_id();
   MDSMap::DaemonState state = m->get_state();
   version_t seq = m->get_seq();
 
@@ -417,7 +417,7 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m)
     // zap previous instance of this name?
     if (g_conf->mds_enforce_unique_name) {
       bool failed_mds = false;
-      while (uint64_t existing = pending_mdsmap.find_mds_gid_by_name(m->get_name())) {
+      while (mds_gid_t existing = pending_mdsmap.find_mds_gid_by_name(m->get_name())) {
         if (!mon->osdmon()->is_writeable()) {
           mon->osdmon()->wait_for_writeable(new C_RetryMessage(this, m));
           return false;
@@ -531,7 +531,7 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m)
 
 bool MDSMonitor::prepare_offload_targets(MMDSLoadTargets *m)
 {
-  uint64_t gid = m->global_id;
+  mds_gid_t gid = m->global_id;
   if (pending_mdsmap.mds_info.count(gid)) {
     dout(10) << "prepare_offload_targets " << gid << " " << m->targets << dendl;
     pending_mdsmap.mds_info[gid].export_targets = m->targets;
@@ -577,7 +577,7 @@ void MDSMonitor::get_health(list<pair<health_status_t, string> >& summary,
   mdsmap.get_health(summary, detail);
 
   // For each MDS GID...
-  for (std::map<uint64_t, MDSMap::mds_info_t>::const_iterator i = pending_mdsmap.mds_info.begin();
+  for (std::map<mds_gid_t, MDSMap::mds_info_t>::const_iterator i = pending_mdsmap.mds_info.begin();
       i != pending_mdsmap.mds_info.end(); ++i) {
     // Decode MDSHealth
     bufferlist bl;
@@ -733,8 +733,8 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
 
     if (whostr == "*") {
       r = -ENOENT;
-      const map<uint64_t, MDSMap::mds_info_t> mds_info = mdsmap.get_mds_info();
-      for (map<uint64_t, MDSMap::mds_info_t>::const_iterator i = mds_info.begin();
+      const map<mds_gid_t, MDSMap::mds_info_t> mds_info = mdsmap.get_mds_info();
+      for (map<mds_gid_t, MDSMap::mds_info_t>::const_iterator i = mds_info.begin();
           i != mds_info.end();
           ++i) {
        m->cmd = args_vec;
@@ -748,8 +748,9 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
       }
     } else {
       errno = 0;
-      long who = strtol(whostr.c_str(), 0, 10);
-      if (!errno && who >= 0) {
+      long who_l = strtol(whostr.c_str(), 0, 10);
+      if (!errno && who_l >= 0) {
+        mds_rank_t who = mds_rank_t(who_l);
        if (mdsmap.is_up(who)) {
          m->cmd = args_vec;
          mon->send_command(mdsmap.get_inst(who), m->cmd);
@@ -837,7 +838,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m)
     return false;
 }
 
-void MDSMonitor::fail_mds_gid(uint64_t gid)
+void MDSMonitor::fail_mds_gid(mds_gid_t gid)
 {
   assert(pending_mdsmap.mds_info.count(gid));
   MDSMap::mds_info_t& info = pending_mdsmap.mds_info[gid];
@@ -868,7 +869,7 @@ void MDSMonitor::fail_mds_gid(uint64_t gid)
 int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg)
 {
   std::string err;
-  int w = strict_strtoll(arg.c_str(), 10, &err);
+  unsigned long long rank_or_gid = strict_strtoll(arg.c_str(), 10, &err);
   if (!err.empty()) {
     // Try to interpret the arg as an MDS name
     const MDSMap::mds_info_t *mds_info = mdsmap.find_by_name(arg);
@@ -876,7 +877,7 @@ int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg)
       ss << "Can't find any MDS named '" << arg << "'";
       return -ENOENT;
     }
-    w = mds_info->rank;
+    rank_or_gid = (unsigned long long)(mds_info->rank);
   }
 
   if (!mon->osdmon()->is_writeable()) {
@@ -884,17 +885,17 @@ int MDSMonitor::fail_mds(std::ostream &ss, const std::string &arg)
  }
 
   bool failed_mds_gid = false;
-  if (pending_mdsmap.up.count(w)) {
-    uint64_t gid = pending_mdsmap.up[w];
+  if (pending_mdsmap.up.count(mds_rank_t(rank_or_gid))) {
+    mds_gid_t gid = pending_mdsmap.up[mds_rank_t(rank_or_gid)];
     if (pending_mdsmap.mds_info.count(gid)) {
       fail_mds_gid(gid);
       failed_mds_gid = true;
     }
-    ss << "failed mds." << w;
-  } else if (pending_mdsmap.mds_info.count(w)) {
-    fail_mds_gid(w);
+    ss << "failed mds." << rank_or_gid;
+  } else if (pending_mdsmap.mds_info.count(mds_gid_t(rank_or_gid))) {
+    fail_mds_gid(mds_gid_t(rank_or_gid));
     failed_mds_gid = true;
-    ss << "failed mds gid " << w;
+    ss << "failed mds gid " << rank_or_gid;
   }
 
   if (failed_mds_gid) {
@@ -1208,10 +1209,12 @@ bool MDSMonitor::filesystem_command(
   cmd_getval(g_ceph_context, cmdmap, "who", whostr);
   if (prefix == "mds stop" ||
       prefix == "mds deactivate") {
-    int who = parse_pos_long(whostr.c_str(), &ss);
-    if (who < 0) {
+
+    int who_i = parse_pos_long(whostr.c_str(), &ss);
+    if (who_i < 0) {
       return true;
     }
+    mds_rank_t who = mds_rank_t(who_i);
     if (!pending_mdsmap.is_active(who)) {
       r = -EEXIST;
       ss << "mds." << who << " not active (" 
@@ -1223,12 +1226,12 @@ bool MDSMonitor::filesystem_command(
       ss << "can't tell the root (" << pending_mdsmap.get_root()
         << ") or tableserver (" << pending_mdsmap.get_tableserver()
         << " to deactivate unless it is the last mds in the cluster";
-    } else if (pending_mdsmap.get_num_in_mds() <= pending_mdsmap.get_max_mds()) {
+    } else if (pending_mdsmap.get_num_in_mds() <= size_t(pending_mdsmap.get_max_mds())) {
       r = -EBUSY;
       ss << "must decrease max_mds or else MDS will immediately reactivate";
     } else {
       r = 0;
-      uint64_t gid = pending_mdsmap.up[who];
+      mds_gid_t gid = pending_mdsmap.up[who];
       ss << "telling mds." << who << " " << pending_mdsmap.mds_info[gid].addr << " to deactivate";
       pending_mdsmap.mds_info[gid].state = MDSMap::STATE_STOPPING;
     }
@@ -1337,7 +1340,7 @@ bool MDSMonitor::filesystem_command(
     }
 
   } else if (prefix == "mds set_state") {
-    int64_t gid;
+    mds_gid_t gid;
     if (!cmd_getval(g_ceph_context, cmdmap, "gid", gid)) {
       ss << "error parsing 'gid' value '"
          << cmd_vartype_stringify(cmdmap["gid"]) << "'";
@@ -1370,7 +1373,7 @@ bool MDSMonitor::filesystem_command(
     }
 
   } else if (prefix == "mds rm") {
-    int64_t gid;
+    mds_gid_t gid;
     if (!cmd_getval(g_ceph_context, cmdmap, "gid", gid)) {
       ss << "error parsing 'gid' value '"
          << cmd_vartype_stringify(cmdmap["gid"]) << "'";
@@ -1393,16 +1396,17 @@ bool MDSMonitor::filesystem_command(
       return true;
     }
   } else if (prefix == "mds rmfailed") {
-    int64_t w;
-    if (!cmd_getval(g_ceph_context, cmdmap, "who", w)) {
+    int w_i;
+    if (!cmd_getval(g_ceph_context, cmdmap, "who", w_i)) {
       ss << "error parsing 'who' value '"
          << cmd_vartype_stringify(cmdmap["who"]) << "'";
       r = -EINVAL;
       return true;
     }
-    pending_mdsmap.failed.erase(w);
+    mds_rank_t who = mds_rank_t(w_i);
+    pending_mdsmap.failed.erase(who);
     stringstream ss;
-    ss << "removed failed mds." << w;
+    ss << "removed failed mds." << who;
     r = 0;
     return true;
   } else if (prefix == "mds cluster_down") {
@@ -1556,13 +1560,13 @@ void MDSMonitor::tick()
   if (!mon->is_leader()) return;
 
   // expand mds cluster (add new nodes to @in)?
-  while (pending_mdsmap.get_num_in_mds() < pending_mdsmap.get_max_mds() &&
+  while (pending_mdsmap.get_num_in_mds() < size_t(pending_mdsmap.get_max_mds()) &&
         !pending_mdsmap.is_degraded()) {
-    int mds = 0;
+    mds_rank_t mds = mds_rank_t(0);
     string name;
     while (pending_mdsmap.is_in(mds))
       mds++;
-    uint64_t newgid = pending_mdsmap.find_replacement_for(mds, name);
+    mds_gid_t newgid = pending_mdsmap.find_replacement_for(mds, name);
     if (!newgid)
       break;
 
@@ -1587,7 +1591,7 @@ void MDSMonitor::tick()
   cutoff -= g_conf->mds_beacon_grace;
 
   // make sure last_beacon is fully populated
-  for (map<uint64_t,MDSMap::mds_info_t>::iterator p = pending_mdsmap.mds_info.begin();
+  for (map<mds_gid_t,MDSMap::mds_info_t>::iterator p = pending_mdsmap.mds_info.begin();
        p != pending_mdsmap.mds_info.end();
        ++p) {
     if (last_beacon.count(p->first) == 0) {
@@ -1604,9 +1608,9 @@ void MDSMonitor::tick()
 
     bool propose_osdmap = false;
 
-    map<uint64_t, beacon_info_t>::iterator p = last_beacon.begin();
+    map<mds_gid_t, beacon_info_t>::iterator p = last_beacon.begin();
     while (p != last_beacon.end()) {
-      uint64_t gid = p->first;
+      mds_gid_t gid = p->first;
       utime_t since = p->second.stamp;
       uint64_t seq = p->second.seq;
       ++p;
@@ -1628,11 +1632,11 @@ void MDSMonitor::tick()
       
       // are we in?
       // and is there a non-laggy standby that can take over for us?
-      uint64_t sgid;
+      mds_gid_t sgid;
       if (info.rank >= 0 &&
          info.state != MDSMap::STATE_STANDBY &&
          info.state != MDSMap::STATE_STANDBY_REPLAY &&
-         (sgid = pending_mdsmap.find_replacement_for(info.rank, info.name)) != 0) {
+         (sgid = pending_mdsmap.find_replacement_for(info.rank, info.name)) != MDS_GID_NONE) {
        MDSMap::mds_info_t& si = pending_mdsmap.mds_info[sgid];
        dout(10) << " replacing " << gid << " " << info.addr << " mds." << info.rank << "." << info.inc
                 << " " << ceph_mds_state_name(info.state)
@@ -1711,15 +1715,14 @@ void MDSMonitor::tick()
   }
 
   // have a standby take over?
-  set<int> failed;
+  set<mds_rank_t> failed;
   pending_mdsmap.get_failed_mds_set(failed);
   if (!failed.empty()) {
-    set<int>::iterator p = failed.begin();
+    set<mds_rank_t>::iterator p = failed.begin();
     while (p != failed.end()) {
-      int f = *p++;
-      uint64_t sgid;
+      mds_rank_t f = *p++;
       string name;  // FIXME
-      sgid = pending_mdsmap.find_replacement_for(f, name);
+      mds_gid_t sgid = pending_mdsmap.find_replacement_for(f, name);
       if (sgid) {
        MDSMap::mds_info_t& si = pending_mdsmap.mds_info[sgid];
        dout(0) << " taking over failed mds." << f << " with " << sgid << "/" << si.name << " " << si.addr << dendl;
@@ -1736,7 +1739,7 @@ void MDSMonitor::tick()
 
   // have a standby follow someone?
   if (failed.empty()) {
-    for (map<uint64_t,MDSMap::mds_info_t>::iterator j = pending_mdsmap.mds_info.begin();
+    for (map<mds_gid_t,MDSMap::mds_info_t>::iterator j = pending_mdsmap.mds_info.begin();
         j != pending_mdsmap.mds_info.end();
         ++j) {
       MDSMap::mds_info_t& info = j->second;
@@ -1759,7 +1762,7 @@ void MDSMonitor::tick()
       }
 
       // check everyone
-      for (map<uint64_t,MDSMap::mds_info_t>::iterator i = pending_mdsmap.mds_info.begin();
+      for (map<mds_gid_t,MDSMap::mds_info_t>::iterator i = pending_mdsmap.mds_info.begin();
           i != pending_mdsmap.mds_info.end();
           ++i) {
        if (i->second.rank >= 0 && pending_mdsmap.is_followable(i->second.rank)) {
@@ -1785,7 +1788,7 @@ void MDSMonitor::tick()
 bool MDSMonitor::try_standby_replay(MDSMap::mds_info_t& finfo, MDSMap::mds_info_t& ainfo)
 {
   // someone else already following?
-  uint64_t lgid = pending_mdsmap.find_standby_for(ainfo.rank, ainfo.name);
+  mds_gid_t lgid = pending_mdsmap.find_standby_for(ainfo.rank, ainfo.name);
   if (lgid) {
     MDSMap::mds_info_t& sinfo = pending_mdsmap.mds_info[lgid];
     dout(20) << " mds." << ainfo.rank
index 305730fe605edcc9a2b0c3fc278d977782f2ec09..da6239648ff7e0c7ce5399aa61ec02cf98d718db 100644 (file)
@@ -97,7 +97,7 @@ class MDSMonitor : public PaxosService {
   void get_health(list<pair<health_status_t,string> >& summary,
                  list<pair<health_status_t,string> > *detail) const;
   int fail_mds(std::ostream &ss, const std::string &arg);
-  void fail_mds_gid(uint64_t gid);
+  void fail_mds_gid(mds_gid_t gid);
 
   bool preprocess_command(MMonCommand *m);
   bool prepare_command(MMonCommand *m);
@@ -118,7 +118,7 @@ class MDSMonitor : public PaxosService {
     utime_t stamp;
     uint64_t seq;
   };
-  map<uint64_t, beacon_info_t> last_beacon;
+  map<mds_gid_t, beacon_info_t> last_beacon;
 
   bool try_standby_replay(MDSMap::mds_info_t& finfo, MDSMap::mds_info_t& ainfo);