From ced8e97a04e7b56717da0adbecbcf407d8a22aa9 Mon Sep 17 00:00:00 2001 From: sageweil Date: Thu, 21 Jun 2007 00:20:12 +0000 Subject: [PATCH] * client mount timeout/retry; but we need a general approach to mon query retries git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1434 29311d96-e01e-0410-9327-a35deaab8ce9 --- branches/sage/mon2/client/Client.cc | 37 ++++++++++++++++++++++++----- branches/sage/mon2/client/Client.h | 18 ++++++++++++++ branches/sage/mon2/config.cc | 2 ++ branches/sage/mon2/config.h | 2 ++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/branches/sage/mon2/client/Client.cc b/branches/sage/mon2/client/Client.cc index 9b4401ef8e2bc..570ac76d2cafd 100644 --- a/branches/sage/mon2/client/Client.cc +++ b/branches/sage/mon2/client/Client.cc @@ -95,13 +95,14 @@ public: // cons/des -Client::Client(Messenger *m, MonMap *mm) +Client::Client(Messenger *m, MonMap *mm) : timer(client_lock) { // which client am i? whoami = m->get_myname().num(); monmap = mm; mounted = false; + mount_timeout_event = 0; unmounting = false; last_tid = 0; @@ -1250,7 +1251,28 @@ void Client::update_caps_wanted(Inode *in) // ------------------- -// fs ops +// MOUNT + +void Client::_try_mount() +{ + dout(10) << "_try_mount" << endl; + int mon = monmap->pick_mon(); + dout(2) << "sending client_mount to mon" << mon << endl; + messenger->send_message(new MClientMount(messenger->get_myaddr()), + monmap->get_inst(mon)); + + // schedule timeout + assert(mount_timeout_event == 0); + mount_timeout_event = new C_MountTimeout(this); + timer.add_event_after(g_conf.client_mount_timeout, mount_timeout_event); +} + +void Client::_mount_timeout() +{ + dout(10) << "_mount_timeout" << endl; + mount_timeout_event = 0; + _try_mount(); +} int Client::mount() { @@ -1258,15 +1280,15 @@ int Client::mount() assert(!mounted); // caller is confused? assert(!mdsmap); - int mon = monmap->pick_mon(); - dout(2) << "sending client_mount to mon" << mon << endl; - messenger->send_message(new MClientMount(messenger->get_myaddr()), - monmap->get_inst(mon)); + _try_mount(); while (!mdsmap || !osdmap || osdmap->get_epoch() == 0) mount_cond.Wait(client_lock); + + timer.cancel_event(mount_timeout_event); + mount_timeout_event = 0; mounted = true; @@ -1290,6 +1312,9 @@ int Client::mount() } +// UNMOUNT + + int Client::unmount() { client_lock.Lock(); diff --git a/branches/sage/mon2/client/Client.h b/branches/sage/mon2/client/Client.h index 6b1eb75298c63..d00833505df6f 100644 --- a/branches/sage/mon2/client/Client.h +++ b/branches/sage/mon2/client/Client.h @@ -34,9 +34,11 @@ #include "include/interval_set.h" #include "common/Mutex.h" +#include "common/Timer.h" #include "FileCache.h" + // stl #include #include @@ -328,6 +330,7 @@ class Client : public Dispatcher { MDSMap *mdsmap; OSDMap *osdmap; + SafeTimer timer; protected: Messenger *messenger; @@ -569,6 +572,21 @@ protected: // ---------------------- // fs ops. +private: + void _try_mount(); + void _mount_timeout(); + Context *mount_timeout_event; + + class C_MountTimeout : public Context { + Client *client; + public: + C_MountTimeout(Client *c) : client(c) { } + void finish(int r) { + if (r >= 0) client->_mount_timeout(); + } + }; + +public: int mount(); int unmount(); diff --git a/branches/sage/mon2/config.cc b/branches/sage/mon2/config.cc index a92ea5a3cab71..e9385a2646cce 100644 --- a/branches/sage/mon2/config.cc +++ b/branches/sage/mon2/config.cc @@ -147,6 +147,8 @@ md_config_t g_conf = { client_oc_max_dirty: 1024*1024* 5, // MB * n client_oc_max_sync_write: 128*1024, // writes >= this use wrlock + client_mount_timeout: 10.0, // retry every N seconds + client_trace: 0, fuse_direct_io: 0, diff --git a/branches/sage/mon2/config.h b/branches/sage/mon2/config.h index ccf130533818a..bf0d27aeb9d89 100644 --- a/branches/sage/mon2/config.h +++ b/branches/sage/mon2/config.h @@ -135,6 +135,8 @@ struct md_config_t { int client_oc_max_dirty; size_t client_oc_max_sync_write; + double client_mount_timeout; + /* -- 2.39.5