From: Sage Weil Date: Tue, 11 May 2010 20:28:53 +0000 (-0700) Subject: mds: drop 'closed' bit from MClientReconnect X-Git-Tag: v0.22~548 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=12f7c0b4009782c5f8228f3be31d1d2a56fbfddf;p=ceph.git mds: drop 'closed' bit from MClientReconnect --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 4f34fb2a5c90..e78be951aafa 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -1337,7 +1337,8 @@ void Client::handle_mds_map(MMDSMap* m) } else if (oldstate == newstate) continue; // no change - if (newstate == MDSMap::STATE_RECONNECT) + if (newstate == MDSMap::STATE_RECONNECT && + mds_sessions.count(p->first)) send_reconnect(p->first); if (oldstate < MDSMap::STATE_ACTIVE && @@ -1364,56 +1365,53 @@ void Client::send_reconnect(int mds) MClientReconnect *m = new MClientReconnect; - if (mds_sessions.count(mds)) { - // i have an open session. - hash_set did_snaprealm; - for (hash_map::iterator p = inode_map.begin(); - p != inode_map.end(); - p++) { - Inode *in = p->second; - if (in->caps.count(mds)) { - dout(10) << " caps on " << p->first - << " " << ccap_string(in->caps[mds]->issued) - << " wants " << ccap_string(in->caps_wanted()) - << dendl; - filepath path; - in->make_long_path(path); - dout(10) << " path " << path << dendl; - - in->caps[mds]->seq = 0; // reset seq. - in->caps[mds]->issue_seq = 0; // reset seq. - m->add_cap(p->first.ino, - in->caps[mds]->cap_id, - path.get_ino(), path.get_path(), // ino - in->caps_wanted(), // wanted - in->caps[mds]->issued, // issued - in->size, in->mtime, in->atime, in->snaprealm->ino); - - if (did_snaprealm.count(in->snaprealm->ino) == 0) { - dout(10) << " snaprealm " << *in->snaprealm << dendl; - m->add_snaprealm(in->snaprealm->ino, in->snaprealm->seq, in->snaprealm->parent); - did_snaprealm.insert(in->snaprealm->ino); - } - } - if (in->exporting_mds == mds) { - dout(10) << " clearing exporting_caps on " << p->first << dendl; - in->exporting_mds = -1; - in->exporting_issued = 0; - in->exporting_mseq = 0; - } - } - - // reset my cap seq number - mds_sessions[mds].seq = 0; + assert(mds_sessions.count(mds)); - //connect to the mds' offload targets - connect_mds_targets(mds); - //make sure unsafe requests get saved - resend_unsafe_requests(mds); - } else { - dout(10) << " i had no session with this mds" << dendl; - m->closed = true; + // i have an open session. + hash_set did_snaprealm; + for (hash_map::iterator p = inode_map.begin(); + p != inode_map.end(); + p++) { + Inode *in = p->second; + if (in->caps.count(mds)) { + dout(10) << " caps on " << p->first + << " " << ccap_string(in->caps[mds]->issued) + << " wants " << ccap_string(in->caps_wanted()) + << dendl; + filepath path; + in->make_long_path(path); + dout(10) << " path " << path << dendl; + + in->caps[mds]->seq = 0; // reset seq. + in->caps[mds]->issue_seq = 0; // reset seq. + m->add_cap(p->first.ino, + in->caps[mds]->cap_id, + path.get_ino(), path.get_path(), // ino + in->caps_wanted(), // wanted + in->caps[mds]->issued, // issued + in->size, in->mtime, in->atime, in->snaprealm->ino); + + if (did_snaprealm.count(in->snaprealm->ino) == 0) { + dout(10) << " snaprealm " << *in->snaprealm << dendl; + m->add_snaprealm(in->snaprealm->ino, in->snaprealm->seq, in->snaprealm->parent); + did_snaprealm.insert(in->snaprealm->ino); + } + } + if (in->exporting_mds == mds) { + dout(10) << " clearing exporting_caps on " << p->first << dendl; + in->exporting_mds = -1; + in->exporting_issued = 0; + in->exporting_mseq = 0; + } } + + // reset my cap seq number + mds_sessions[mds].seq = 0; + + //connect to the mds' offload targets + connect_mds_targets(mds); + //make sure unsafe requests get saved + resend_unsafe_requests(mds); messenger->send_message(m, mdsmap->get_inst(mds)); } diff --git a/src/mds/Server.cc b/src/mds/Server.cc index d4bd176eb5d3..21186ec3fef4 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -539,100 +539,89 @@ void Server::handle_client_reconnect(MClientReconnect *m) return; } - if (m->closed) { - dout(7) << " client had no session, removing from session map" << dendl; - assert(session); // ? + // notify client of success with an OPEN + mds->messenger->send_message(new MClientSession(CEPH_SESSION_OPEN), m->get_connection()); + + if (session->is_closed()) { + dout(10) << " session is closed, will make best effort to reconnect " + << m->get_source_inst() << dendl; + mds->sessionmap.set_state(session, Session::STATE_OPENING); version_t pv = ++mds->sessionmap.projected; uint64_t sseq = session->get_state_seq(); - mdlog->start_submit_entry(new ESession(session->inst, false, pv), - new C_MDS_session_finish(mds, session, sseq, false, pv)); + mdlog->start_submit_entry(new ESession(session->inst, true, pv), + new C_MDS_session_finish(mds, session, sseq, true, pv)); mdlog->flush(); - // no need to respond to client: they're telling us they have no session + ss << "reconnect by new " << session->inst << " after " << delay; } else { - // notify client of success with an OPEN - mds->messenger->send_message(new MClientSession(CEPH_SESSION_OPEN), m->get_connection()); - - if (session->is_closed()) { - dout(10) << " session is closed, will make best effort to reconnect " - << m->get_source_inst() << dendl; - mds->sessionmap.set_state(session, Session::STATE_OPENING); - version_t pv = ++mds->sessionmap.projected; - uint64_t sseq = session->get_state_seq(); - mdlog->start_submit_entry(new ESession(session->inst, true, pv), - new C_MDS_session_finish(mds, session, sseq, true, pv)); - mdlog->flush(); - ss << "reconnect by new " << session->inst << " after " << delay; - } else { - ss << "reconnect by " << session->inst << " after " << delay; - } - mds->logclient.log(LOG_DEBUG, ss); - - // snaprealms - for (vector::iterator p = m->realms.begin(); - p != m->realms.end(); - p++) { - CInode *in = mdcache->get_inode(inodeno_t(p->ino)); - if (in && in->state_test(CInode::STATE_PURGING)) - continue; - if (in) { - assert(in->snaprealm); - if (in->snaprealm->have_past_parents_open()) { - dout(15) << "open snaprealm (w/ past parents) on " << *in << dendl; - mdcache->finish_snaprealm_reconnect(from, in->snaprealm, snapid_t(p->seq)); - } else { - dout(15) << "open snaprealm (w/o past parents) on " << *in << dendl; - mdcache->add_reconnected_snaprealm(from, inodeno_t(p->ino), snapid_t(p->seq)); - } + ss << "reconnect by " << session->inst << " after " << delay; + } + mds->logclient.log(LOG_DEBUG, ss); + + // snaprealms + for (vector::iterator p = m->realms.begin(); + p != m->realms.end(); + p++) { + CInode *in = mdcache->get_inode(inodeno_t(p->ino)); + if (in && in->state_test(CInode::STATE_PURGING)) + continue; + if (in) { + assert(in->snaprealm); + if (in->snaprealm->have_past_parents_open()) { + dout(15) << "open snaprealm (w/ past parents) on " << *in << dendl; + mdcache->finish_snaprealm_reconnect(from, in->snaprealm, snapid_t(p->seq)); } else { - dout(15) << "open snaprealm (w/o inode) on " << inodeno_t(p->ino) - << " seq " << p->seq << dendl; + dout(15) << "open snaprealm (w/o past parents) on " << *in << dendl; mdcache->add_reconnected_snaprealm(from, inodeno_t(p->ino), snapid_t(p->seq)); } + } else { + dout(15) << "open snaprealm (w/o inode) on " << inodeno_t(p->ino) + << " seq " << p->seq << dendl; + mdcache->add_reconnected_snaprealm(from, inodeno_t(p->ino), snapid_t(p->seq)); } + } - // caps - for (map::iterator p = m->caps.begin(); - p != m->caps.end(); - ++p) { - // make sure our last_cap_id is MAX over all issued caps - if (p->second.capinfo.cap_id > mdcache->last_cap_id) - mdcache->last_cap_id = p->second.capinfo.cap_id; - - CInode *in = mdcache->get_inode(p->first); - if (in && in->state_test(CInode::STATE_PURGING)) - continue; - if (in && in->is_auth()) { - // we recovered it, and it's ours. take note. - dout(15) << "open cap realm " << inodeno_t(p->second.capinfo.snaprealm) - << " on " << *in << dendl; - in->reconnect_cap(from, p->second.capinfo, session); - mds->mdcache->add_reconnected_cap(in, from, inodeno_t(p->second.capinfo.snaprealm)); - continue; - } + // caps + for (map::iterator p = m->caps.begin(); + p != m->caps.end(); + ++p) { + // make sure our last_cap_id is MAX over all issued caps + if (p->second.capinfo.cap_id > mdcache->last_cap_id) + mdcache->last_cap_id = p->second.capinfo.cap_id; + + CInode *in = mdcache->get_inode(p->first); + if (in && in->state_test(CInode::STATE_PURGING)) + continue; + if (in && in->is_auth()) { + // we recovered it, and it's ours. take note. + dout(15) << "open cap realm " << inodeno_t(p->second.capinfo.snaprealm) + << " on " << *in << dendl; + in->reconnect_cap(from, p->second.capinfo, session); + mds->mdcache->add_reconnected_cap(in, from, inodeno_t(p->second.capinfo.snaprealm)); + continue; + } - filepath path(p->second.path, (uint64_t)p->second.capinfo.pathbase); - if ((in && !in->is_auth()) || - !mds->mdcache->path_is_mine(path)) { - // not mine. - dout(0) << "non-auth " << p->first << " " << path - << ", will pass off to authority" << dendl; - - // mark client caps stale. - inode_t fake_inode; - fake_inode.ino = p->first; - MClientCaps *stale = new MClientCaps(CEPH_CAP_OP_EXPORT, p->first, 0, 0, 0); - //stale->head.migrate_seq = 0; // FIXME ****** - mds->send_message_client_counted(stale, m->get_connection()); - - // add to cap export list. - mdcache->rejoin_export_caps(p->first, from, p->second); - } else { - // mine. fetch later. - dout(0) << "missing " << p->first << " " << path - << " (mine), will load later" << dendl; - mdcache->rejoin_recovered_caps(p->first, from, p->second, - -1); // "from" me. - } + filepath path(p->second.path, (uint64_t)p->second.capinfo.pathbase); + if ((in && !in->is_auth()) || + !mds->mdcache->path_is_mine(path)) { + // not mine. + dout(0) << "non-auth " << p->first << " " << path + << ", will pass off to authority" << dendl; + + // mark client caps stale. + inode_t fake_inode; + fake_inode.ino = p->first; + MClientCaps *stale = new MClientCaps(CEPH_CAP_OP_EXPORT, p->first, 0, 0, 0); + //stale->head.migrate_seq = 0; // FIXME ****** + mds->send_message_client_counted(stale, m->get_connection()); + + // add to cap export list. + mdcache->rejoin_export_caps(p->first, from, p->second); + } else { + // mine. fetch later. + dout(0) << "missing " << p->first << " " << path + << " (mine), will load later" << dendl; + mdcache->rejoin_recovered_caps(p->first, from, p->second, + -1); // "from" me. } } diff --git a/src/messages/MClientReconnect.h b/src/messages/MClientReconnect.h index 36fdcaa0b58b..771e5aa620d1 100644 --- a/src/messages/MClientReconnect.h +++ b/src/messages/MClientReconnect.h @@ -20,12 +20,10 @@ class MClientReconnect : public Message { public: - bool closed; // true if this session was closed by the client. map caps; // only head inodes vector realms; - MClientReconnect() : Message(CEPH_MSG_CLIENT_RECONNECT), - closed(false) { } + MClientReconnect() : Message(CEPH_MSG_CLIENT_RECONNECT) {} private: ~MClientReconnect() {} @@ -33,7 +31,6 @@ public: const char *get_type_name() { return "client_reconnect"; } void print(ostream& out) { out << "client_reconnect(" - << (closed ? "closed":"") << caps.size() << " caps)"; } @@ -52,22 +49,15 @@ public: } void encode_payload() { - if (!closed) { - ::encode(caps, data); - ::encode_nohead(realms, data); - } + ::encode(caps, data); + ::encode_nohead(realms, data); } void decode_payload() { bufferlist::iterator p = data.begin(); - if (p.end()) { - closed = true; - } else { - closed = false; - ::decode(caps, p); - while (p.end()) { - realms.push_back(ceph_mds_snaprealm_reconnect()); - ::decode(realms.back(), p); - } + ::decode(caps, p); + while (p.end()) { + realms.push_back(ceph_mds_snaprealm_reconnect()); + ::decode(realms.back(), p); } }