From f44cffdb8ccc8cf258b418146dbbfc20a9b685f9 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 12 Jul 2011 16:49:25 -0700 Subject: [PATCH] mds: verify deferred messages aren't stale We may defer processing of some messages because we are laggy (in hearing from the monitor). When we eventually get to those messages, make sure they haven't since become stale (i.e., the source mds isn't now down). Signed-off-by: Sage Weil --- src/mds/MDS.cc | 25 +++++++++++++++++++------ src/mds/MDS.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 70f952d51fe8d..66e9f0c30e72d 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -1778,9 +1778,7 @@ bool MDS::handle_deferrable_message(Message *m) return true; } -/* If this function returns true, it has put the message. If it returns false, - * it has not put the message. */ -bool MDS::_dispatch(Message *m) +bool MDS::is_stale_message(Message *m) { // from bad mds? if (m->get_source().is_mds()) { @@ -1799,11 +1797,21 @@ bool MDS::_dispatch(Message *m) } else { dout(5) << "got " << *m << " from down/old/bad/imposter mds " << m->get_source() << ", dropping" << dendl; - m->put(); return true; } } } + return false; +} + +/* If this function returns true, it has put the message. If it returns false, + * it has not put the message. */ +bool MDS::_dispatch(Message *m) +{ + if (is_stale_message(m)) { + m->put(); + return true; + } // core if (!handle_core_message(m)) { @@ -1845,8 +1853,13 @@ bool MDS::_dispatch(Message *m) Message *m = waiting_for_nolaggy.front(); waiting_for_nolaggy.pop_front(); - dout(7) << " processing laggy deferred " << *m << dendl; - handle_deferrable_message(m); + + if (is_stale_message(m)) { + m->put(); + } else { + dout(7) << " processing laggy deferred " << *m << dendl; + handle_deferrable_message(m); + } // give other threads (beacon!) a chance mds_lock.Unlock(); diff --git a/src/mds/MDS.h b/src/mds/MDS.h index 172645839e089..f95d25a5d0195 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -393,6 +393,8 @@ class MDS : public Dispatcher { // messages bool _dispatch(Message *m); + bool is_stale_message(Message *m); + bool handle_core_message(Message *m); bool handle_deferrable_message(Message *m); -- 2.39.5