From: John Spray Date: Thu, 18 Sep 2014 18:31:43 +0000 (+0100) Subject: mds: typedefs for rank and gid in MDSMap X-Git-Tag: v0.88~97^2~18 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f93bf3853f5edbdd0392a80e6cb5ffe37de5f484;p=ceph.git mds: typedefs for rank and gid in MDSMap Make it clearer what these numbers are where they appear. Signed-off-by: John Spray --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 94f6652307ea..b0092d8816ea 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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::const_iterator q = info.export_targets.begin(); + for (set::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::const_iterator p = mds_sessions.begin(); p != mds_sessions.end(); ++p) { + for (map::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 <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::iterator p = mds_sessions.begin(); + for (map::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::iterator p = mds_sessions.begin(); + for (map::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::iterator it = in->caps.begin(); + map::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::iterator it = in->caps.begin(); it != in->caps.end(); ++it) { + for (map::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::iterator p = mds_sessions.begin(); + for (map::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::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::iterator it = in->caps.begin(); it != in->caps.end(); ++it) { + for (map::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::iterator p = mds_sessions.begin(); + for (map::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::iterator p = mds_sessions.begin(); + for (map::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::iterator p = mds_sessions.begin(); + for (map::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::iterator iter = in->caps.begin(); iter != in->caps.end(); ++iter) { + for (map::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::iterator p = mds_sessions.begin(); + for (map::iterator p = mds_sessions.begin(); p != mds_sessions.end(); ++p) { if (mdsmap->get_addr(p->first) == con->get_peer_addr()) { diff --git a/src/client/Client.h b/src/client/Client.h index 1f7c53631d7d..1e0bcc7f2de8 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -239,15 +239,15 @@ public: client_t whoami; // mds sessions - map mds_sessions; // mds -> push seq + map mds_sessions; // mds -> push seq list waiting_for_mdsmap; void get_session_metadata(std::map *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 mds_requests; - set 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); diff --git a/src/client/Dentry.h b/src/client/Dentry.h index 8dc48803b6e6..aad6343f8179 100644 --- a/src/client/Dentry.h +++ b/src/client/Dentry.h @@ -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; diff --git a/src/client/Inode.cc b/src/client/Inode.cc index 3f3de6a41dc2..7ed61d71e25d 100644 --- a/src/client/Inode.cc +++ b/src/client/Inode.cc @@ -20,7 +20,7 @@ ostream& operator<<(ostream &out, Inode &in) << " caps=" << ccap_string(in.caps_issued()); if (!in.caps.empty()) { out << "("; - for (map::iterator p = in.caps.begin(); p != in.caps.end(); ++p) { + for (map::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::iterator it = caps.begin(); + for (map::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::iterator it = caps.begin(); + for (map::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::iterator it = caps.begin(); + for (map::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::const_iterator p = caps.begin(); p != caps.end(); ++p) { + for (map::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) diff --git a/src/client/Inode.h b/src/client/Inode.h index 0e6cec078808..2edeba8c4e6a 100644 --- a/src/client/Inode.h +++ b/src/client/Inode.h @@ -140,7 +140,7 @@ struct Inode { bool dir_hashed, dir_replicated; // per-mds caps - map caps; // mds -> Cap + map 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(); diff --git a/src/client/MetaRequest.h b/src/client/MetaRequest.h index fb7f5b1aa809..b73b67bf7dcd 100644 --- a/src/client/MetaRequest.h +++ b/src/client/MetaRequest.h @@ -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 diff --git a/src/client/MetaSession.h b/src/client/MetaSession.h index b6fd8f354a47..6eb813cb22d4 100644 --- a/src/client/MetaSession.h +++ b/src/client/MetaSession.h @@ -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; diff --git a/src/mds/Beacon.cc b/src/mds/Beacon.cc index 6f7d1288dcb2..6a6a5c8c2b15 100644 --- a/src/mds/Beacon.cc +++ b/src/mds/Beacon.cc @@ -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, diff --git a/src/mds/Beacon.h b/src/mds/Beacon.h index 9148366d94f5..4336d1a0b3be 100644 --- a/src/mds/Beacon.h +++ b/src/mds/Beacon.h @@ -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(); diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 4bcb9d3a132b..ca87a21940a6 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -137,7 +137,7 @@ inodeno_t CDentry::get_ino() } */ -pair CDentry::authority() +mds_authority_t CDentry::authority() { return dir->authority(); } diff --git a/src/mds/CDentry.h b/src/mds/CDentry.h index 0de626a29658..309643964173 100644 --- a/src/mds/CDentry.h +++ b/src/mds/CDentry.h @@ -283,7 +283,7 @@ public: version_t get_projected_version() { return projected_version; } void set_projected_version(version_t v) { projected_version = v; } - pair 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(); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index e5a1f5109c1f..ba1a3eaced8a 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -91,7 +91,7 @@ ostream& operator<<(ostream& out, CDir& dir) out << " cv=" << dir.get_committing_version(); out << "/" << dir.get_committed_version(); } else { - pair 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& subs, list& waiters, bool steal_dentry(dir->items.begin()->second); // merge replica map - for (map::iterator p = dir->replicas_begin(); + for (map::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 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 a) +void CDir::set_dir_auth(mds_authority_t a) { dout(10) << "setting dir_auth=" << a << " from " << dir_auth diff --git a/src/mds/CDir.h b/src/mds/CDir.h index 0e035d8743b1..4617f5573d73 100644 --- a/src/mds/CDir.h +++ b/src/mds/CDir.h @@ -389,13 +389,13 @@ private: * ambiguous: subtree_root * subtree_root */ - pair dir_auth; + mds_authority_t dir_auth; public: - pair authority(); - pair get_dir_auth() { return dir_auth; } - void set_dir_auth(pair a); - void set_dir_auth(int a) { set_dir_auth(pair(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& ls, int auth) { + void get_dist_spec(std::set& ls, mds_rank_t auth) { if (is_rep()) { - for (std::map::iterator p = replicas_begin(); + for (std::map::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 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); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index c2bd0761a6ea..80aec74e81a4 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -111,7 +111,7 @@ ostream& operator<<(ostream& out, CInode& in) if (in.is_replicated()) out << in.get_replicas(); } else { - pair 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 CInode::authority() +mds_authority_t CInode::authority() { if (inode_auth.first >= 0) return inode_auth; diff --git a/src/mds/CInode.h b/src/mds/CInode.h index 2162820ed247..ff19bd6b57df 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -388,7 +388,7 @@ public: std::list projected_parent; // for in-progress rename, (un)link, etc. - pair 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 authority(); + mds_authority_t authority(); // -- auth pins -- diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index ba92196583a6..4474140e60ea 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -128,7 +128,7 @@ void Locker::tick() void Locker::send_lock_message(SimpleLock *lock, int msg) { - for (map::iterator it = lock->get_parent()->replicas_begin(); + for (map::iterator it = lock->get_parent()->replicas_begin(); it != lock->get_parent()->replicas_end(); ++it) { if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN) @@ -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::iterator it = lock->get_parent()->replicas_begin(); + for (map::iterator it = lock->get_parent()->replicas_begin(); it != lock->get_parent()->replicas_end(); ++it) { if (mds->mdsmap->get_state(it->first) < MDSMap::STATE_REJOIN) @@ -209,7 +209,7 @@ bool Locker::acquire_locks(MDRequestRef& mdr, set &rdlocks, set &wrlocks, set &xlocks, - map *remote_wrlocks, + map *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::iterator p = remote_wrlocks->begin(); p != remote_wrlocks->end(); ++p) { + for (map::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 > mustpin_remote; // mds -> (object set) + map > 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::iterator p = mdr->remote_auth_pins.begin(); + for (map::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 >::iterator q = mustpin_remote.find(p->second); + map >::iterator q = mustpin_remote.find(p->second); if (q != mustpin_remote.end()) q->second.insert(p->first); } } - for (map >::iterator p = mustpin_remote.begin(); + for (map >::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 *pneed_issue) void Locker::_drop_non_rdlocks(MutationImpl *mut, set *pneed_issue) { - set slaves; + set slaves; while (!mut->xlocks.empty()) { SimpleLock *lock = *mut->xlocks.begin(); @@ -619,7 +619,7 @@ void Locker::_drop_non_rdlocks(MutationImpl *mut, set *pneed_issue) } while (!mut->remote_wrlocks.empty()) { - map::iterator p = mut->remote_wrlocks.begin(); + map::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 *pneed_issue) pneed_issue->insert(static_cast(p)); } - for (set::iterator p = slaves.begin(); p != slaves.end(); ++p) { + for (set::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, listget_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); diff --git a/src/mds/Locker.h b/src/mds/Locker.h index 6df00c4a75df..6322f65bd8cf 100644 --- a/src/mds/Locker.h +++ b/src/mds/Locker.h @@ -88,7 +88,7 @@ public: set &rdlocks, set &wrlocks, set &xlocks, - map *remote_wrlocks=NULL, + map *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); diff --git a/src/mds/MDBalancer.cc b/src/mds/MDBalancer.cc index 969a5cb467c9..921969146aa5 100644 --- a/src/mds/MDBalancer.cc +++ b/src/mds/MDBalancer.cc @@ -190,18 +190,18 @@ void MDBalancer::send_heartbeat() // my load mds_load_t load = get_load(now); - map::value_type val(mds->get_nodeid(), load); + map::value_type val(mds->get_nodeid(), load); mds_load.insert(val); // import_map -- how much do i import from whom - map import_map; + map import_map; set authsubs; mds->mdcache->get_auth_subtrees(authsubs); for (set::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::iterator it = import_map.begin(); + for (map::iterator it = import_map.begin(); it != import_map.end(); ++it) { dout(5) << " import_map from " << it->first << " -> " << it->second << dendl; } - set up; + set up; mds->get_mds_map()->get_mds_set(up); - for (set::iterator p = up.begin(); p != up.end(); ++p) { + for (set::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 mds_load_map_t; + typedef map 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 up_mds; + set up_mds; mds->get_mds_map()->get_up_mds_set(up_mds); - for (set::iterator i = up_mds.begin(); + for (set::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::iterator m = mds_load.find(whoami); + map::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 load_map; - for (int i=0; i::value_type val(i, mds_load_t(ceph_clock_now(g_ceph_context))); - std::pair < map::iterator, bool > r(mds_load.insert(val)); + multimap load_map; + for (mds_rank_t i=mds_rank_t(0); i < mds_rank_t(cluster_size); i++) { + map::value_type val(i, mds_load_t(ceph_clock_now(g_ceph_context))); + std::pair < map::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( l, i )); + load_map.insert(pair( l, i )); } // target load @@ -506,21 +506,21 @@ void MDBalancer::prep_rebalance(int beat) // first separate exporters and importers - multimap importers; - multimap exporters; - set importer_set; - set exporter_set; + multimap importers; + multimap exporters; + set importer_set; + set exporter_set; - for (multimap::iterator it = load_map.begin(); + for (multimap::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(it->first,it->second)); + importers.insert(pair(it->first,it->second)); importer_set.insert(it->second); } else { dout(15) << " mds." << it->second << " is exporter" << dendl; - exporters.insert(pair(it->first,it->second)); + exporters.insert(pair(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::reverse_iterator ex = exporters.rbegin(); + for (multimap::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::iterator im = mds_import_map[ex->second].begin(); + for (map::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::reverse_iterator ex = exporters.rbegin(); - multimap::iterator im = importers.begin(); + multimap::reverse_iterator ex = exporters.rbegin(); + multimap::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::iterator ex = exporters.begin(); - multimap::iterator im = importers.begin(); + multimap::iterator ex = exporters.begin(); + multimap::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 import_pop_map; - multimap import_from_map; + multimap import_from_map; set 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(from, im)); + import_from_map.insert(pair(from, im)); } @@ -641,10 +641,10 @@ void MDBalancer::try_rebalance() // do my exports! set already_exporting; - for (map::iterator it = my_targets.begin(); + for (map::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::iterator, multimap::iterator> p = + pair::iterator, multimap::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::iterator plast = p.first++; + multimap::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& map_targets = mds->mdsmap->get_mds_info(mds->whoami).export_targets; + const set& 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::iterator p = map_targets.begin(); p != map_targets.end(); ++p) { + for (set::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 need_targets; - for (map::iterator i = my_targets.begin(); + set need_targets; + for (map::iterator i = my_targets.begin(); i != my_targets.end(); ++i) { need_targets.insert(i->first); @@ -786,8 +786,8 @@ bool MDBalancer::check_targets() } } - set want_targets = need_targets; - map::iterator p = old_prev_targets.begin(); + set want_targets = need_targets; + map::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; diff --git a/src/mds/MDBalancer.h b/src/mds/MDBalancer.h index dacbf3ceb39e..696e2ca82177 100644 --- a/src/mds/MDBalancer.h +++ b/src/mds/MDBalancer.h @@ -50,25 +50,25 @@ class MDBalancer { set split_queue, merge_queue; // per-epoch scatter/gathered info - map mds_load; - map mds_meta_load; - map > mds_import_map; + map mds_load; + map mds_meta_load; + map > mds_import_map; // per-epoch state double my_load, target_load; - map my_targets; - map imported; - map exported; + map my_targets; + map imported; + map exported; - map old_prev_targets; // # iterations they _haven't_ been targets + map 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]; } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 6b9d6c717782..5166abb25155 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -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(mds->whoami, CDIR_AUTH_UNKNOWN); + in->inode_auth = mds_authority_t(mds->whoami, CDIR_AUTH_UNKNOWN); else - in->inode_auth = pair(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& 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 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& bounds, pair auth) +void MDCache::adjust_bounded_subtree_auth(CDir *dir, set& 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& bounds, pair 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& dfs, set& bo } } -void MDCache::adjust_bounded_subtree_auth(CDir *dir, vector& bound_dfs, pair auth) +void MDCache::adjust_bounded_subtree_auth(CDir *dir, vector& 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 resolves; + map resolves; if (mds->is_resolve()) { - for (map >::iterator p = uncommitted_slave_updates.begin(); + for (map >::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 resolve_set; + set resolve_set; mds->mdsmap->get_mds_set(resolve_set, MDSMap::STATE_RESOLVE); for (ceph::unordered_map::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::iterator p = resolves.begin(); + for (map::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 resolves; - for (set::iterator p = recovery_set.begin(); + map resolves; + for (set::iterator p = recovery_set.begin(); p != recovery_set.end(); ++p) { if (*p == mds->whoami) @@ -2598,14 +2598,14 @@ void MDCache::send_subtree_resolves() vector dfls; for (set::iterator q = bounds.begin(); q != bounds.end(); ++q) dfls.push_back((*q)->dirfrag()); - for (map::iterator q = resolves.begin(); + for (map::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::iterator q = resolves.begin(); + for (map::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::iterator r = resolves.begin(); + for (map::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 >::iterator p = my_ambiguous_imports.begin(); p != my_ambiguous_imports.end(); ++p) { - for (map::iterator q = resolves.begin(); + for (map::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::iterator p = resolves.begin(); + for (map::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& s) +void MDCache::set_recovery_set(set& s) { dout(7) << "set_recovery_set " << s << dendl; recovery_set = s; @@ -2886,7 +2886,7 @@ void MDCache::set_recovery_set(set& 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 tmp; + map tmp; tmp.swap(delayed_resolve); - for (map::iterator p = tmp.begin(); p != tmp.end(); ++p) + for (map::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 > >::iterator p = other_ambiguous_imports.begin(); + for (map > >::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 >::iterator q = p->second.begin(); @@ -3303,7 +3303,7 @@ void MDCache::disambiguate_imports() other_ambiguous_imports.clear(); // my ambiguous imports - pair me_ambig(mds->whoami, mds->whoami); + mds_authority_t me_ambig(mds->whoami, mds->whoami); while (!my_ambiguous_imports.empty()) { map >::iterator q = my_ambiguous_imports.begin(); @@ -3642,12 +3642,12 @@ void MDCache::rejoin_send_rejoins() return; } - map rejoins; + map rejoins; // if i am rejoining, send a rejoin to everyone. // otherwise, just send to others who are rejoining. - for (set::iterator p = recovery_set.begin(); + for (set::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_exports; + map > client_exports; for (map >::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 >::iterator p = client_exports.begin(); + for (map >::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::iterator q = p->second.begin(); q != p->second.end(); ++q) + for (set::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::iterator p = rejoins.begin(); + for (map::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::iterator q = mdr->remote_auth_pins.begin(); + for (map::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::iterator q = mdr->remote_wrlocks.begin(); + for (map::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::iterator p = rejoins.begin(); + for (map::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& acked_inodes, set& 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 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(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 > >::iterator p; + map > >::iterator p; p = cap_imports.find(ino); assert(p != cap_imports.end()); - for (map >::iterator q = p->second.begin(); + for (map >::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 > >::iterator p = cap_imports.begin(); + for (map > >::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 > >::iterator p = rejoin_slave_exports.begin(); + for (map > >::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 > >::iterator p = cap_imports.begin(); + for (map > >::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 >::iterator q = p->second.begin(); + for (map >::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::iterator r = q->second.begin(); + for (map::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 > >::iterator p = cap_imports.begin(); + for (map > >::iterator p = cap_imports.begin(); p != cap_imports.end(); ++p) { warn_str << " ino " << p->first << "\n"; - for (map >::iterator q = p->second.begin(); + for (map >::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 >::iterator p = rejoin_unlinked_inodes.begin(); + for (map >::iterator p = rejoin_unlinked_inodes.begin(); p != rejoin_unlinked_inodes.end(); ++p) { for (set::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 ack; - for (set::iterator p = recovery_set.begin(); + map ack; + for (set::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::iterator r = dir->replicas_begin(); + for (map::iterator r = dir->replicas_begin(); r != dir->replicas_end(); ++r) { ack[r->first]->add_strong_dirfrag(dir->dirfrag(), ++r->second, dir->dir_rep); @@ -5730,7 +5730,7 @@ void MDCache::rejoin_send_acks() in = dnl->get_inode(); // dentry - for (map::iterator r = dn->replicas_begin(); + for (map::iterator r = dn->replicas_begin(); r != dn->replicas_end(); ++r) { ack[r->first]->add_strong_dentry(dir->dirfrag(), dn->name, dn->first, dn->last, @@ -5747,7 +5747,7 @@ void MDCache::rejoin_send_acks() if (!in) continue; - for (map::iterator r = in->replicas_begin(); + for (map::iterator r = in->replicas_begin(); r != in->replicas_end(); ++r) { ack[r->first]->add_inode_base(in); @@ -5764,7 +5764,7 @@ void MDCache::rejoin_send_acks() // base inodes too if (root && root->is_auth()) - for (map::iterator r = root->replicas_begin(); + for (map::iterator r = root->replicas_begin(); r != root->replicas_end(); ++r) { ack[r->first]->add_inode_base(root); @@ -5773,7 +5773,7 @@ void MDCache::rejoin_send_acks() ack[r->first]->add_inode_locks(root, ++r->second, bl); } if (myin) - for (map::iterator r = myin->replicas_begin(); + for (map::iterator r = myin->replicas_begin(); r != myin->replicas_end(); ++r) { ack[r->first]->add_inode_base(myin); @@ -5787,14 +5787,14 @@ void MDCache::rejoin_send_acks() p != rejoin_potential_updated_scatterlocks.end(); ++p) { CInode *in = *p; - for (map::iterator r = in->replicas_begin(); + for (map::iterator r = in->replicas_begin(); r != in->replicas_end(); ++r) ack[r->first]->add_inode_base(in); } // send acks - for (map::iterator p = ack.begin(); + for (map::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 expiremap; + map expiremap; bool is_standby_replay = mds->is_standby_replay(); int unexpirable = 0; list unexpirables; @@ -6190,10 +6190,10 @@ bool MDCache::trim(int max, int count) return true; } -void MDCache::send_expire_messages(map& expiremap) +void MDCache::send_expire_messages(map& expiremap) { // send expires - for (map::iterator it = expiremap.begin(); + for (map::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& expiremap) } -bool MDCache::trim_dentry(CDentry *dn, map& expiremap) +bool MDCache::trim_dentry(CDentry *dn, map& expiremap) { dout(12) << "trim_dentry " << *dn << dendl; @@ -6260,10 +6260,10 @@ bool MDCache::trim_dentry(CDentry *dn, map& expiremap) !dn->get_dir()->get_inode()->is_stray()) return true; - pair 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& expiremap) } -void MDCache::trim_dirfrag(CDir *dir, CDir *con, map& expiremap) +void MDCache::trim_dirfrag(CDir *dir, CDir *con, map& expiremap) { dout(15) << "trim_dirfrag " << *dir << dendl; @@ -6309,7 +6309,7 @@ void MDCache::trim_dirfrag(CDir *dir, CDir *con, map& expire CInode *in = dir->get_inode(); if (!dir->is_auth()) { - pair 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& 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& expire in->close_dirfrag(dir->dirfrag().frag); } -bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map& expiremap) +bool MDCache::trim_inode(CDentry *dn, CInode *in, CDir *con, map& 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 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, mapget_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::iterator p = delayed_expire[dir].begin(); + for (map::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::iterator p = delayed_expire[dir].begin(); + for (map::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& 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& gather_locks) +void MDCache::dentry_remove_replica(CDentry *dn, mds_rank_t from, set& gather_locks) { dn->remove_replica(from); @@ -7171,7 +7171,7 @@ bool MDCache::shutdown_pass() int max = 5; // throttle shutdown exports.. hack! for (list::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 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& 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 all, active; + set 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::iterator p = active.begin(); p != active.end(); ++p) + for (set::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 all, active; + set 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::iterator p = active.begin(); p != active.end(); ++p) + for (set::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::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::iterator p = mdr->more()->slaves.begin(); + for (set::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::iterator q = mdr->remote_wrlocks.begin(); + map::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::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 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& 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, listget_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 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 who; + set who; if (bcast) { mds->get_mds_map()->get_active_mds_set(who); } else { - for (map::iterator p = dir->replicas_begin(); + for (map::iterator p = dir->replicas_begin(); p != dir->replicas_end(); ++p) who.insert(p->first); @@ -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::iterator it = who.begin(); + mds_rank_t whoami = mds->get_nodeid(); + for (set::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::iterator p = dn->replicas_begin(); + for (map::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 replicas; + map replicas; replicas.insert(dn->replicas_begin(), dn->replicas_end()); if (straydn) replicas.insert(straydn->replicas_begin(), straydn->replicas_end()); - for (map::iterator it = replicas.begin(); + for (map::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 expiremap; + map 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::iterator p = first->replicas_begin(); + for (map::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; } diff --git a/src/mds/MDCache.h b/src/mds/MDCache.h index 9f02b3ba31fe..de12ced54567 100644 --- a/src/mds/MDCache.h +++ b/src/mds/MDCache.h @@ -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 > > 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& ls); - void adjust_subtree_auth(CDir *root, pair 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(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& bounds, pair auth); - void adjust_bounded_subtree_auth(CDir *dir, set& bounds, int a) { - adjust_bounded_subtree_auth(dir, bounds, pair(a, CDIR_AUTH_UNKNOWN)); + void adjust_bounded_subtree_auth(CDir *dir, set& bounds, mds_authority_t auth); + void adjust_bounded_subtree_auth(CDir *dir, set& 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& bounds, pair auth); - void adjust_bounded_subtree_auth(CDir *dir, vector& bounds, int a) { - adjust_bounded_subtree_auth(dir, bounds, pair(a, CDIR_AUTH_UNKNOWN)); + void adjust_bounded_subtree_auth(CDir *dir, vector& bounds, mds_authority_t auth); + void adjust_bounded_subtree_auth(CDir *dir, vector& bounds, mds_rank_t a) { + adjust_bounded_subtree_auth(dir, bounds, mds_authority_t(a, CDIR_AUTH_UNKNOWN)); } void map_dirfrag_set(list& dfs, set& result); void try_subtree_merge(CDir *root); @@ -233,7 +233,7 @@ public: protected: // delayed cache expire - map > delayed_expire; // subtree root -> expire msg + map > 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& 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 &slaves, bool safe=false) { + void add_uncommitted_master(metareqid_t reqid, LogSegment *ls, set &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 recovery_set; + set recovery_set; public: - void set_recovery_set(set& s); - void handle_mds_failure(int who); - void handle_mds_recovery(int who); + void set_recovery_set(set& 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 > my_ambiguous_imports; // from MMDSResolves - map > > other_ambiguous_imports; + map > > other_ambiguous_imports; - map > uncommitted_slave_updates; // slave: for replay. + map > uncommitted_slave_updates; // slave: for replay. map uncommitted_slave_rename_olddir; // slave: preserve the non-auth dir until seeing commit. map uncommitted_slave_unlink; // slave: preserve the unlinked inode until seeing commit. // track master requests whose slaves haven't acknowledged commit struct umaster { - set slaves; + set slaves; LogSegment *ls; list waiters; bool safe; @@ -338,40 +338,40 @@ protected: friend class ECommitted; bool resolves_pending; - set resolve_gather; // nodes i need resolves from - set resolve_ack_gather; // nodes i need a resolve_ack from - map need_resolve_rollback; // rollbacks i'm writing to the journal - map delayed_resolve; + set resolve_gather; // nodes i need resolves from + set resolve_ack_gather; // nodes i need a resolve_ack from + map need_resolve_rollback; // rollbacks i'm writing to the journal + map 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 rejoin_gather; // nodes from whom i need a rejoin - set rejoin_sent; // nodes i sent a rejoin to - set rejoin_ack_gather; // nodes from whom i need a rejoin ack - map > > rejoin_imported_caps; - map > > rejoin_slave_exports; + set rejoin_gather; // nodes from whom i need a rejoin + set rejoin_sent; // nodes i sent a rejoin to + set rejoin_ack_gather; // nodes from whom i need a rejoin ack + map > > rejoin_imported_caps; + map > > rejoin_slave_exports; map rejoin_client_map; map > cap_exports; // ino -> client -> capex - map cap_export_targets; // ino -> auth mds + map cap_export_targets; // ino -> auth mds - map > > cap_imports; // ino -> client -> frommds -> capex + map > > cap_imports; // ino -> client -> frommds -> capex map cap_import_paths; set cap_imports_missing; int cap_imports_num_opening; @@ -425,7 +425,7 @@ protected: set rejoin_undef_inodes; set rejoin_potential_updated_scatterlocks; set rejoin_undef_dirfrags; - map > rejoin_unlinked_inodes; + map > rejoin_unlinked_inodes; vector rejoin_recover_q, rejoin_check_q; list 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& acked_inodes, set& 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& splits); void do_realm_invalidate_and_update_notify(CInode *in, int snapop, bool nosend=false); void send_snaps(map& 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& expiremap); + bool trim_dentry(CDentry *dn, map& expiremap); void trim_dirfrag(CDir *dir, CDir *con, - map& expiremap); + map& expiremap); bool trim_inode(CDentry *dn, CInode *in, CDir *con, - map& expiremap); - void send_expire_messages(map& expiremap); + map& expiremap); + void send_expire_messages(map& 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& gather_locks); - void dentry_remove_replica(CDentry *dn, int rep, set& gather_locks); + void dentry_remove_replica(CDentry *dn, mds_rank_t rep, set& gather_locks); void rename_file(CDentry *srcdn, CDentry *destdn); @@ -783,9 +783,9 @@ public: protected: struct open_ino_info_t { vector ancestors; - set checked; - int checking; - int auth_hint; + set 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 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& 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 checked; + mds_rank_t hint; + mds_rank_t checking; + set 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 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& 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& finished); + CDir* forge_replica_dir(CInode *diri, frag_t fg, mds_rank_t from); CDentry *add_replica_dentry(bufferlist::iterator& p, CDir *dir, list& finished); CInode *add_replica_inode(bufferlist::iterator& p, CDentry *dn, list& 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: diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 74719cdd97e1..54971e069115 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -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::const_iterator p = oldmap->get_mds_info().begin(); + for (map::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 resolve; + set 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 olddis, dis; + set 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::iterator p = dis.begin(); p != dis.end(); ++p) + for (set::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 oldactive, active; + set 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::iterator p = active.begin(); p != active.end(); ++p) + for (set::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 oldfailed, failed; + set oldfailed, failed; oldmap->get_failed_mds_set(oldfailed); mdsmap->get_failed_mds_set(failed); - for (set::iterator p = failed.begin(); p != failed.end(); ++p) + for (set::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 up; + set up; mdsmap->get_up_mds_set(up); - for (set::iterator p = up.begin(); p != up.end(); ++p) + for (set::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 oldstopped, stopped; + set oldstopped, stopped; oldmap->get_stopped_mds_set(oldstopped); mdsmap->get_stopped_mds_set(stopped); - for (set::iterator p = stopped.begin(); p != stopped.end(); ++p) + for (set::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 rs; + set 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 active; + set 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; imds_thrash_exports; i++) { - set s; + set 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::iterator p = s.begin(); + set::iterator p = s.begin(); while (k--) ++p; dest = *p; } while (dest == whoami); diff --git a/src/mds/MDS.h b/src/mds/MDS.h index a51a5f9b032d..1c224bfd3ffb 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -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 waiting_for_active, waiting_for_replay, waiting_for_reconnect, waiting_for_resolve; list replay_queue; - map > waiting_for_active_peer; + map > waiting_for_active_peer; list waiting_for_nolaggy; map > waiting_for_mdsmap; - map peer_mdsmap_epoch; + map 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(); diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 54ebf16fb9e6..831e236b67d0 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -19,6 +19,11 @@ 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::iterator p = export_targets.begin(); + for (set::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::const_iterator p = in.begin(); p != in.end(); ++p) + for (set::const_iterator p = in.begin(); p != in.end(); ++p) f->dump_int("mds", *p); f->close_section(); f->open_object_section("up"); - for (map::const_iterator p = up.begin(); p != up.end(); ++p) { + for (map::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::const_iterator p = failed.begin(); p != failed.end(); ++p) + for (set::const_iterator p = failed.begin(); p != failed.end(); ++p) f->dump_int("mds", *p); f->close_section(); f->open_array_section("stopped"); - for (set::const_iterator p = stopped.begin(); p != stopped.end(); ++p) + for (set::const_iterator p = stopped.begin(); p != stopped.end(); ++p) f->dump_int("mds", *p); f->close_section(); f->open_object_section("info"); - for (map::const_iterator p = mds_info.begin(); p != mds_info.end(); ++p) { + for (map::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, uint64_t > foo; - for (map::iterator p = mds_info.begin(); + multimap< pair, mds_gid_t > foo; + for (map::iterator p = mds_info.begin(); p != mds_info.end(); ++p) - foo.insert(pair,uint64_t>(pair(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, uint64_t >::iterator p = foo.begin(); + for (multimap< pair, 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 by_rank; + map by_rank; map 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::iterator p = mds_info.begin(); + for (map::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 >& summary, << " failed"; summary.push_back(make_pair(HEALTH_ERR, oss.str())); if (detail) { - for (set::const_iterator p = failed.begin(); p != failed.end(); ++p) { + for (set::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 >& 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::const_iterator info = mds_info.find(gid); + mds_gid_t gid = up.find(i)->second; + map::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 >& summary, } } - map::const_iterator u = up.begin(); - map::const_iterator u_end = up.end(); - map::const_iterator m_end = mds_info.end(); + map::const_iterator u = up.begin(); + map::const_iterator u_end = up.end(); + map::const_iterator m_end = mds_info.end(); set laggy; for (; u != u_end; ++u) { - map::const_iterator m = mds_info.find(u->second); + map::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::const_iterator i = mds_info.begin(); + for (map::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::const_iterator i = mds_info.begin(); + for (map::const_iterator i = mds_info.begin(); i != mds_info.end(); ++i) { ::encode(i->first, bl); ::encode(i->second, bl, features); diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index 84ba4d42059d..0e36c14557e3 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -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 export_targets; + std::set 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 in; // currently defined cluster - std::map inc; // most recent incarnation. - std::set failed, stopped; // which roles are failed or stopped - std::map up; // who is in those roles - std::map mds_info; + std::set in; // currently defined cluster + std::map inc; // most recent incarnation. + std::set failed, stopped; // which roles are failed or stopped + std::map up; // who is in those roles + std::map 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 &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& get_mds_info() { return mds_info; } - const mds_info_t& get_mds_info_gid(uint64_t gid) { + const std::map& 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::const_iterator p = mds_info.begin(); + mds_gid_t find_mds_gid_by_name(const std::string& s) { + for (std::map::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::const_iterator p = mds_info.begin(); + for (std::map::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& s) { + void get_mds_set(std::set& s) { s = in; } - void get_up_mds_set(std::set& s) { - for (std::map::const_iterator p = up.begin(); + void get_up_mds_set(std::set& s) { + for (std::map::const_iterator p = up.begin(); p != up.end(); ++p) s.insert(p->first); } - void get_active_mds_set(std::set& s) { + void get_active_mds_set(std::set& s) { get_mds_set(s, MDSMap::STATE_ACTIVE); } - void get_failed_mds_set(std::set& s) { + void get_failed_mds_set(std::set& s) { s = failed; } int get_failed() { if (!failed.empty()) return *failed.begin(); return -1; } - void get_stopped_mds_set(std::set& s) { + void get_stopped_mds_set(std::set& s) { s = stopped; } - void get_recovery_mds_set(std::set& s) { + void get_recovery_mds_set(std::set& s) { s = failed; - for (std::map::const_iterator p = mds_info.begin(); + for (std::map::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& s) { - for (std::map::const_iterator p = mds_info.begin(); + void get_clientreplay_or_active_or_stopping_mds_set(std::set& s) { + for (std::map::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& s, DaemonState state) { - for (std::map::const_iterator p = mds_info.begin(); + void get_mds_set(std::set& s, DaemonState state) { + for (std::map::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::iterator p = up.begin(); + std::map::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::const_iterator p = mds_info.begin(); + for (std::map::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::const_iterator generic_standby + mds_gid_t find_standby_for(mds_rank_t mds, std::string& name) { + std::map::const_iterator generic_standby = mds_info.end(); - for (std::map::const_iterator p = mds_info.begin(); + for (std::map::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::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::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 > *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::const_iterator u = up.find(m); + DaemonState get_state(mds_rank_t m) const { + std::map::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::const_iterator i = mds_info.find(gid); + DaemonState get_state_gid(mds_gid_t gid) const { + std::map::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::const_iterator p = mds_info.find(gid); + std::map::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::const_iterator p = mds_info.begin(); + for (std::map::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; diff --git a/src/mds/MDSTable.cc b/src/mds/MDSTable.cc index 323740fbb0d2..36c2d0a7b110 100644 --- a/src/mds/MDSTable.cc +++ b/src/mds/MDSTable.cc @@ -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); diff --git a/src/mds/MDSTableClient.cc b/src/mds/MDSTableClient.cc index 2ba4f499f594..e06f92bea5a0 100644 --- a/src/mds/MDSTableClient.cc +++ b/src/mds/MDSTableClient.cc @@ -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. diff --git a/src/mds/MDSTableClient.h b/src/mds/MDSTableClient.h index 064cc2892533..a5671d0538e8 100644 --- a/src/mds/MDSTableClient.h +++ b/src/mds/MDSTableClient.h @@ -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; diff --git a/src/mds/MDSTableServer.cc b/src/mds/MDSTableServer.cc index fc6221c3b49c..42f421351796 100644 --- a/src/mds/MDSTableServer.cc +++ b/src/mds/MDSTableServer.cc @@ -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& active) +void MDSTableServer::finish_recovery(set& active) { dout(7) << "finish_recovery" << dendl; - for (set::iterator p = active.begin(); p != active.end(); ++p) + for (set::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; diff --git a/src/mds/MDSTableServer.h b/src/mds/MDSTableServer.h index 8d54693cd6e9..b70c260a4340 100644 --- a/src/mds/MDSTableServer.h +++ b/src/mds/MDSTableServer.h @@ -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& active); - void handle_mds_recovery(int who); + void finish_recovery(set& active); + void handle_mds_recovery(mds_rank_t who); }; #endif diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 81a7565cd42c..b95f861de18b 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -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(dir->dirfrag(), dest)); + export_queue.push_back(pair(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& 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::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::iterator p = dir->replicas_begin(); + for (map::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::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::iterator p = dir->replicas_begin(); + for (map::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(mds->get_nodeid(),CDIR_AUTH_UNKNOWN), - pair(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::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& 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& peer_imported, list& 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 >& peer_imported, list& finished, int *num_dentries) { @@ -1595,7 +1595,7 @@ void Migrator::export_notify_abort(CDir *dir, set& bounds) export_state_t& stat = export_state[dir]; - for (set::iterator p = stat.notify_ack_waiting.begin(); + for (set::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 bounds; cache->get_subtree_bounds(dir, bounds); - for (set::iterator p = stat.notify_ack_waiting.begin(); + for (set::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 imported_client_map; map 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& bounds) dout(7) << "import_notify_finish " << *dir << dendl; import_state_t& stat = import_state[dir->dirfrag()]; - for (set::iterator p = stat.bystanders.begin(); + for (set::iterator p = stat.bystanders.begin(); p != stat.bystanders.end(); ++p) { MExportDirNotify *notify = @@ -2471,13 +2472,13 @@ void Migrator::import_notify_abort(CDir *dir, set& bounds) dout(7) << "import_notify_abort " << *dir << dendl; import_state_t& stat = import_state[dir->dirfrag()]; - for (set::iterator p = stat.bystanders.begin(); + for (set::iterator p = stat.bystanders.begin(); p != stat.bystanders.end(); ++p) { MExportDirNotify *notify = new MExportDirNotify(dir->dirfrag(), stat.tid, true, - pair(stat.peer, mds->get_nodeid()), - pair(stat.peer, CDIR_AUTH_UNKNOWN)); + mds_authority_t(stat.peer, mds->get_nodeid()), + mds_authority_t(stat.peer, CDIR_AUTH_UNKNOWN)); for (set::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& imported_client_map, map& sseqmap) { @@ -2548,8 +2549,8 @@ void Migrator::import_logged_start(dirfrag_t df, CDir *dir, int from, for (map >::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 >& peer_exports, list& 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 &export_map, map &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 old_auth = m->get_old_auth(); - pair 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 > peer_exports; map client_map; map 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 >& peer_exports, map& client_map, map& sseqmap) diff --git a/src/mds/Migrator.h b/src/mds/Migrator.h index 01f3abc12576..49c8e6ff1a9f 100644 --- a/src/mds/Migrator.h +++ b/src/mds/Migrator.h @@ -83,10 +83,10 @@ protected: // export fun struct export_state_t { int state; - int peer; + mds_rank_t peer; uint64_t tid; - set warning_ack_waiting; - set notify_ack_waiting; + set warning_ack_waiting; + set notify_ack_waiting; map > peer_imported; list waiting_for_finish; MutationRef mut; @@ -100,7 +100,7 @@ protected: map export_state; - list > export_queue; + list > 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 bystanders; + set bystanders; list bound_ls; list updated_scatterlocks; map 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::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::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& exported_client_map); void encode_export_inode_caps(CInode *in, bool auth_cap, bufferlist& bl, map& 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& peer_imported, list& finished); - void finish_export_inode_caps(CInode *in, int target, + void finish_export_inode_caps(CInode *in, mds_rank_t target, map& peer_imported); @@ -255,7 +255,7 @@ public: CDir *dir, map& 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 >& peer_imported, list& 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 >& cap_imports, list& updated_scatterlocks); void decode_import_inode_caps(CInode *in, bool auth_cap, bufferlist::iterator &blp, map >& 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 &export_map, map &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& bounds); void import_notify_finish(CDir *dir, set& 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 &imported_client_map, map& 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 >& cap_imports, map& client_map, map& sseqmap); diff --git a/src/mds/Mutation.h b/src/mds/Mutation.h index bcc1efe300bb..507f9a5b45ba 100644 --- a/src/mds/Mutation.h +++ b/src/mds/Mutation.h @@ -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 stickydirs; // auth pins - map remote_auth_pins; + map 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 slaves; // mds nodes that have slave requests to me (implies client_request) - set waiting_on_slave; // peers i'm waiting for slavereq replies from. + set slaves; // mds nodes that have slave requests to me (implies client_request) + set waiting_on_slave; // peers i'm waiting for slavereq replies from. // for rename/link/unlink - set witnessed; // nodes who have journaled a RenamePrepare + set witnessed; // nodes who have journaled a RenamePrepare map pvmap; bool has_journaled_slaves; bool slave_update_journaled; // for rename - set extra_witnesses; // replica list from srcdn auth (rename) - int srcdn_auth_mds; + set 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), diff --git a/src/mds/Server.cc b/src/mds/Server.cc index a8c14b1b6a28..84f59faebc8a 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -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 pinned; @@ -1852,7 +1852,7 @@ void Server::handle_slave_auth_pin_ack(MDRequestRef& mdr, MMDSSlaveRequest *ack) } // removed auth pins? - map::iterator p = mdr->remote_auth_pins.begin(); + map::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 witnesses; + set witnesses; in->list_replicas(witnesses); dout(10) << " witnesses " << witnesses << ", have " << mdr->more()->witnessed << dendl; - for (set::iterator p = witnesses.begin(); + for (set::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 witnesses = mdr->more()->extra_witnesses; + set 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 remote_wrlocks; + map 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::iterator p = witnesses.begin(); + for (set::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 &witnesse, +bool Server::_rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set &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 srcdnrep; + set 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::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) { + for (set::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::iterator p = srcdnrep.begin(); p != srcdnrep.end(); ++p) { + for (set::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) diff --git a/src/mds/Server.h b/src/mds/Server.h index 11ac54e12a3a..fd93158d8bce 100644 --- a/src/mds/Server.h +++ b/src/mds/Server.h @@ -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 &witnesse, + bool _rename_prepare_witness(MDRequestRef& mdr, mds_rank_t who, set &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); diff --git a/src/mds/SessionMap.cc b/src/mds/SessionMap.cc index 289e80ac02b2..2f703efc87a3 100644 --- a/src/mds/SessionMap.cc +++ b/src/mds/SessionMap.cc @@ -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); } diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index 06811975eb0a..28bb75ab5c8f 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -359,14 +359,15 @@ public: } // gather set - static set empty_gather_set; + static set empty_gather_set; - const set& get_gather_set() const { + // int32_t: <0 is client, >=0 is MDS rank + const set& get_gather_set() const { return have_more() ? more()->gather_set : empty_gather_set; } void init_gather() { - for (map::const_iterator p = parent->replicas_begin(); + for (map::const_iterator p = parent->replicas_begin(); p != parent->replicas_end(); ++p) more()->gather_set.insert(p->first); @@ -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 g; + set<__s32> g; ::decode(g, p); if (!g.empty()) more()->gather_set.swap(g); diff --git a/src/mds/SnapServer.cc b/src/mds/SnapServer.cc index adbccd037294..2e211d9f8940 100644 --- a/src/mds/SnapServer.cc +++ b/src/mds/SnapServer.cc @@ -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; diff --git a/src/mds/SnapServer.h b/src/mds/SnapServer.h index 95e15080df00..13669fccd3a2 100644 --- a/src/mds/SnapServer.h +++ b/src/mds/SnapServer.h @@ -79,7 +79,7 @@ public: static void generate_test_instances(list& 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); diff --git a/src/mds/events/ESlaveUpdate.h b/src/mds/events/ESlaveUpdate.h index 9745139339ad..bfac1216d397 100644 --- a/src/mds/events/ESlaveUpdate.h +++ b/src/mds/events/ESlaveUpdate.h @@ -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 diff --git a/src/mds/events/ETableServer.h b/src/mds/events/ETableServer.h index 132d3b6a6c90..6dff2eb798aa 100644 --- a/src/mds/events/ETableServer.h +++ b/src/mds/events/ETableServer.h @@ -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) { } diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 41e36ad6b3c2..c0530bc87076 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -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 slaves; + set 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(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(mds->get_nodeid(), mds->get_nodeid())); + mds_authority_t(mds->get_nodeid(), mds->get_nodeid())); // open client sessions? if (mds->sessionmap.version >= cmapv) { diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index eb1ae77d655c..0944f61672f8 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -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); diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index d7c2665058b6..56ce23399e55 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -24,6 +24,7 @@ #include #include "include/assert.h" #include "include/hash_namespace.h" +#include #define CEPH_FS_ONDISK_MAGIC "ceph fs volume v011" @@ -70,6 +71,12 @@ #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_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(-1, -2) -#define CDIR_AUTH_UNDEF pair(-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( 0, -2) + /* * for metadata leases to clients */ @@ -1181,7 +1190,7 @@ class MDSCacheObject { // -------------------------------------------- // authority - virtual pair 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 replica_map; // [auth] mds -> nonce + std::map 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::iterator replicas_begin() { return replica_map.begin(); } - std::map::iterator replicas_end() { return replica_map.end(); } - const std::map& get_replicas() { return replica_map; } - void list_replicas(std::set& ls) { - for (std::map::const_iterator p = replica_map.begin(); + std::map::iterator replicas_begin() { return replica_map.begin(); } + std::map::iterator replicas_end() { return replica_map.end(); } + const std::map& get_replicas() { return replica_map; } + void list_replicas(std::set& ls) { + for (std::map::const_iterator p = replica_map.begin(); p != replica_map.end(); ++p) ls.insert(p->first); diff --git a/src/messages/MDirUpdate.h b/src/messages/MDirUpdate.h index 445cd828cfe9..8f461630dfaf 100644 --- a/src/messages/MDirUpdate.h +++ b/src/messages/MDirUpdate.h @@ -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& 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& dir_rep_by, diff --git a/src/messages/MDiscoverReply.h b/src/messages/MDiscoverReply.h index 4c2527802b97..dfb27606dcae 100644 --- a/src/messages/MDiscoverReply.h +++ b/src/messages/MDiscoverReply.h @@ -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; } diff --git a/src/messages/MExportDirDiscover.h b/src/messages/MExportDirDiscover.h index 0b29daf14f54..c5bbcebd68b2 100644 --- a/src/messages/MExportDirDiscover.h +++ b/src/messages/MExportDirDiscover.h @@ -19,12 +19,12 @@ #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); diff --git a/src/messages/MExportDirPrep.h b/src/messages/MExportDirPrep.h index 791a98abc18f..23da166a3201 100644 --- a/src/messages/MExportDirPrep.h +++ b/src/messages/MExportDirPrep.h @@ -26,13 +26,13 @@ class MExportDirPrep : public Message { list bounds; list traces; private: - set<__s32> bystanders; + set bystanders; bool b_did_assim; public: dirfrag_t get_dirfrag() { return dirfrag; } list& get_bounds() { return bounds; } - set<__s32> &get_bystanders() { return bystanders; } + set &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); } diff --git a/src/messages/MHeartbeat.h b/src/messages/MHeartbeat.h index b6cfcfaf0106..802e9661530b 100644 --- a/src/messages/MHeartbeat.h +++ b/src/messages/MHeartbeat.h @@ -22,13 +22,13 @@ class MHeartbeat : public Message { mds_load_t load; __s32 beat; - map<__s32, float> import_map; + map import_map; public: mds_load_t& get_load() { return load; } int get_beat() { return beat; } - map<__s32, float>& get_import_map() { + map& get_import_map() { return import_map; } diff --git a/src/messages/MMDSBeacon.h b/src/messages/MMDSBeacon.h index af62e439627e..48d5d04e5611 100644 --- a/src/messages/MMDSBeacon.h +++ b/src/messages/MMDSBeacon.h @@ -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); } diff --git a/src/messages/MMDSLoadTargets.h b/src/messages/MMDSLoadTargets.h index 4022f32e36b3..d559581a1065 100644 --- a/src/messages/MMDSLoadTargets.h +++ b/src/messages/MMDSLoadTargets.h @@ -24,12 +24,12 @@ using std::map; class MMDSLoadTargets : public PaxosServiceMessage { public: - uint64_t global_id; - set targets; + mds_gid_t global_id; + set targets; MMDSLoadTargets() : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0) {} - MMDSLoadTargets(uint64_t g, set& mds_targets) : + MMDSLoadTargets(mds_gid_t g, set& mds_targets) : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0), global_id(g), targets(mds_targets) {} private: diff --git a/src/messages/MMDSOpenInoReply.h b/src/messages/MMDSOpenInoReply.h index 5204d3c792b7..1bf41b88268f 100644 --- a/src/messages/MMDSOpenInoReply.h +++ b/src/messages/MMDSOpenInoReply.h @@ -20,11 +20,11 @@ struct MMDSOpenInoReply : public Message { inodeno_t ino; vector 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; } diff --git a/src/messages/MMDSSlaveRequest.h b/src/messages/MMDSSlaveRequest.h index f64089ea8364..a11337c91910 100644 --- a/src/messages/MMDSSlaveRequest.h +++ b/src/messages/MMDSSlaveRequest.h @@ -111,7 +111,7 @@ class MMDSSlaveRequest : public Message { // for rename prep filepath srcdnpath; filepath destdnpath; - set<__s32> witnesses; + set witnesses; bufferlist inode_export; version_t inode_export_v; bufferlist srci_replica; diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index fe6fe23d9743..d8050a8cc0c3 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -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 >& summary, mdsmap.get_health(summary, detail); // For each MDS GID... - for (std::map::const_iterator i = pending_mdsmap.mds_info.begin(); + for (std::map::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 mds_info = mdsmap.get_mds_info(); - for (map::const_iterator i = mds_info.begin(); + const map mds_info = mdsmap.get_mds_info(); + for (map::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::iterator p = pending_mdsmap.mds_info.begin(); + for (map::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::iterator p = last_beacon.begin(); + map::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 failed; + set failed; pending_mdsmap.get_failed_mds_set(failed); if (!failed.empty()) { - set::iterator p = failed.begin(); + set::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::iterator j = pending_mdsmap.mds_info.begin(); + for (map::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::iterator i = pending_mdsmap.mds_info.begin(); + for (map::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 diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index 305730fe605e..da6239648ff7 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -97,7 +97,7 @@ class MDSMonitor : public PaxosService { void get_health(list >& summary, list > *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 last_beacon; + map last_beacon; bool try_standby_replay(MDSMap::mds_info_t& finfo, MDSMap::mds_info_t& ainfo);