Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client: fix fuse client hang because its pipe to mds is not ok #24172

Merged
merged 1 commit into from Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/client/Client.cc
Expand Up @@ -2614,13 +2614,14 @@ void Client::handle_fs_map_user(MFSMapUser *m)

void Client::handle_mds_map(MMDSMap* m)
{
mds_gid_t old_inc, new_inc;
if (m->get_epoch() <= mdsmap->get_epoch()) {
ldout(cct, 1) << __func__ << " epoch " << m->get_epoch()
<< " is identical to or older than our "
<< mdsmap->get_epoch() << dendl;
m->put();
return;
}
}

ldout(cct, 1) << __func__ << " epoch " << m->get_epoch() << dendl;

Expand Down Expand Up @@ -2666,6 +2667,13 @@ void Client::handle_mds_map(MMDSMap* m)
if (!mdsmap->is_up(mds)) {
session->con->mark_down();
} else if (mdsmap->get_addrs(mds) != session->addrs) {
old_inc = oldmap->get_incarnation(mds);
new_inc = mdsmap->get_incarnation(mds);
if (old_inc != new_inc) {
ldout(cct, 1) << "mds incarnation changed from "
<< old_inc << " to " << new_inc << dendl;
oldstate = MDSMap::STATE_NULL;
}
session->con->mark_down();
session->addrs = mdsmap->get_addrs(mds);
// When new MDS starts to take over, notify kernel to trim unused entries
Expand All @@ -2676,6 +2684,11 @@ void Client::handle_mds_map(MMDSMap* m)
continue; // no change

session->mds_state = newstate;
if (old_inc != new_inc && newstate > MDSMap::STATE_RECONNECT) {
// missed reconnect close the session so that it can be reopened
_closed_mds_session(session);
continue;
}
if (newstate == MDSMap::STATE_RECONNECT) {
session->con = messenger->connect_to_mds(session->addrs);
send_reconnect(session);
Expand Down
10 changes: 10 additions & 0 deletions src/mds/MDSMap.h
Expand Up @@ -616,6 +616,16 @@ class MDSMap {
}
}

/**
* Get MDS rank incarnation if the rank is up, else -1
*/
mds_gid_t get_incarnation(mds_rank_t m) const {
std::map<mds_rank_t, mds_gid_t>::const_iterator u = up.find(m);
if (u == up.end())
return MDS_GID_NONE;
return (mds_gid_t)get_inc_gid(u->second);
}

int get_inc_gid(mds_gid_t gid) const {
auto mds_info_entry = mds_info.find(gid);
if (mds_info_entry != mds_info.end())
Expand Down