Skip to content

Commit

Permalink
client: fix fuse client hang because its pipe to mds is not ok
Browse files Browse the repository at this point in the history
If fuse client session had been killed by mds and the mds daemon restart
or hot-standby switch happens right away but the client did not receive
any message from monitor due to network or other whatever reason untill
the mds become active again.Thus cause client didn't do closed_mds_session
lead the seession still is STATE_OPEN but client can't send any message to
mds because its pipe is not ok.So we should close the stale session so that
it can be reopened again.

Fixes: http://tracker.ceph.com/issues/36079
Signed-off-by: Guan yunfei <yunfei.guan@xtaotech.com>
  • Loading branch information
IvanGuan committed Jan 1, 2019
1 parent 7591ccd commit 7d10350
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/client/Client.cc
Expand Up @@ -2614,6 +2614,7 @@ void Client::handle_fs_map_user(MFSMapUser *m)

void Client::handle_mds_map(MMDSMap* m)
{
int old_inc = 0, new_inc = 0;
if (m->get_epoch() <= mdsmap->get_epoch()) {
ldout(cct, 1) << __func__ << " epoch " << m->get_epoch()
<< " is identical to or older than our "
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
*/
int 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 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

0 comments on commit 7d10350

Please sign in to comment.