From: Sage Weil Date: Mon, 21 Sep 2009 21:55:59 +0000 (-0700) Subject: mon: consolidate sub request msgs; cleaner api X-Git-Tag: v0.15~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=84c1a14488cd1d9d7b2d44f6ecf623fe89f498fb;p=ceph.git mon: consolidate sub request msgs; cleaner api Caller must call renew_subs() explicitly when they want to start the subscription(s). --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 9e62577f568..4cc60f0e757 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -2645,15 +2645,15 @@ int Client::mount() objecter->init(); + monclient->sub_want("mdsmap", mdsmap->get_epoch()); + monclient->renew_subs(); + mounted = true; dout(2) << "mounted: have osdmap " << osdmap->get_epoch() << " and mdsmap " << mdsmap->get_epoch() << dendl; - monclient->sub_want("mdsmap", mdsmap->get_epoch()); - monclient->renew_subs(); - // hack: get+pin root inode. // fuse assumes it's always there. diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index 07d38260504..8149a7a980a 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -382,8 +382,6 @@ int MDS::init() monc->init(); monc->get_monmap(); - monc->sub_want("mdsmap", 0); - mds_lock.Lock(); // starting beacon. this will induce an MDSMap from the monitor @@ -393,7 +391,10 @@ int MDS::init() messenger->set_myname(entity_name_t::MDS(whoami)); objecter->init(); - + + monc->sub_want("mdsmap", 0); + monc->renew_subs(); + // schedule tick reset_tick(); diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index ec8e9ab94cc..ac84ebc930c 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -203,6 +203,8 @@ void MonClient::handle_monmap(MMonMap *m) bufferlist::iterator p = m->monmapbl.begin(); ::decode(monmap, p); + _sub_got("monmap", monmap.get_epoch()); + map_cond.Signal(); want_monmap = false; @@ -259,6 +261,8 @@ int MonClient::mount(double mount_timeout) if (clientid >= 0) { dout(5) << "mount success, client" << clientid << dendl; + + _sub_want("monmap", monmap.get_epoch()); } return mount_err; diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 6ff016ddf3b..dcde7ecb964 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -94,26 +94,17 @@ private: void _renew_subs(); void handle_subscribe_ack(MMonSubscribeAck* m); -public: - void renew_subs() { - Mutex::Locker l(monc_lock); - _renew_subs(); - } - void sub_want(nstring what, version_t have) { - Mutex::Locker l(monc_lock); + void _sub_want(nstring what, version_t have) { sub_have[what].have = have; sub_have[what].onetime = false; } - void sub_want_onetime(nstring what, version_t have) { - Mutex::Locker l(monc_lock); + void _sub_want_onetime(nstring what, version_t have) { if (sub_have.count(what) == 0) { sub_have[what].have = have; sub_have[what].onetime = true; - _renew_subs(); } } - void sub_got(nstring what, version_t have) { - Mutex::Locker l(monc_lock); + void _sub_got(nstring what, version_t have) { if (sub_have.count(what)) { if (sub_have[what].onetime) sub_have.erase(what); @@ -122,6 +113,25 @@ public: } } +public: + void renew_subs() { + Mutex::Locker l(monc_lock); + _renew_subs(); + } + void sub_want(nstring what, version_t have) { + Mutex::Locker l(monc_lock); + _sub_want(what, have); + } + void sub_want_onetime(nstring what, version_t have) { + Mutex::Locker l(monc_lock); + _sub_want_onetime(what, have); + } + void sub_got(nstring what, version_t have) { + Mutex::Locker l(monc_lock); + _sub_got(what, have); + } + + public: MonClient() : messenger(NULL), cur_mon(-1), monc_lock("MonClient::monc_lock"),