Merge PR #24172 into master

* refs/pull/24172/head:
	client: fix fuse client hang because its pipe to mds is not ok

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
This commit is contained in:
Patrick Donnelly 2019-01-08 08:20:59 -08:00
commit 6873dfc06e
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
2 changed files with 24 additions and 1 deletions

View File

@ -2678,13 +2678,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;
@ -2730,6 +2731,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
@ -2740,6 +2748,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);

View File

@ -616,6 +616,16 @@ public:
}
}
/**
* 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())