]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: consolidate sub request msgs; cleaner api
authorSage Weil <sage@newdream.net>
Mon, 21 Sep 2009 21:55:59 +0000 (14:55 -0700)
committerSage Weil <sage@newdream.net>
Mon, 21 Sep 2009 21:55:59 +0000 (14:55 -0700)
Caller must call renew_subs() explicitly when they want to start
the subscription(s).

src/client/Client.cc
src/mds/MDS.cc
src/mon/MonClient.cc
src/mon/MonClient.h

index 9e62577f5689bc84c7106a27d3bc7ad008919501..4cc60f0e757a2ddfa8be1030b463f3a56e57c6d6 100644 (file)
@@ -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.
index 07d382605045d9ed3120d6836d8a67b8dbf638fd..8149a7a980ad154e4030baebb1df029be5959d24 100644 (file)
@@ -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();
 
index ec8e9ab94cc90bfe7b71e0e77ae0376273483baf..ac84ebc930c740f62322ac0821d4b2edf8247302 100644 (file)
@@ -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;
index 6ff016ddf3bca7b8c18fd7680d464d9c19af9027..dcde7ecb964b38849414031530146e96833287c8 100644 (file)
@@ -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"),