From 65261037ffa78f6cadf1f714f5bdd98eaf564e03 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 3 Jan 2008 12:09:21 -0800 Subject: [PATCH] client regularly renews caps --- src/client/Client.cc | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/client/Client.h | 7 +++++++ src/config.cc | 1 + src/config.h | 1 + 4 files changed, 54 insertions(+) diff --git a/src/client/Client.cc b/src/client/Client.cc index 6f040c4351f3b..654f061ac0733 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -109,6 +109,8 @@ Client::Client(Messenger *m, MonMap *mm) : timer(client_lock) whoami = m->get_myname().num(); monmap = mm; + tick_event = 0; + mounted = false; mounters = 0; mount_timeout_event = 0; @@ -271,6 +273,7 @@ void Client::init() } client_logger_lock.Unlock(); + tick(); } void Client::shutdown() @@ -780,6 +783,10 @@ void Client::handle_client_session(MClientSession *m) // FIXME: kick requests (hard) so that they are redirected. or fail. break; + case CEPH_SESSION_RENEWCAPS: + last_cap_renew = g_clock.now(); + break; + default: assert(0); } @@ -1614,6 +1621,44 @@ void Client::handle_unmount(Message* m) } +class C_C_Tick : public Context { + Client *client; +public: + C_C_Tick(Client *c) : client(c) {} + void finish(int r) { + client->tick(); + } +}; + +void Client::tick() +{ + dout(10) << "tick" << dendl; + tick_event = new C_C_Tick(this); + timer.add_event_after(g_conf.client_tick_interval, tick_event); + + utime_t now = g_clock.now(); + utime_t el = now - last_cap_renew_request; + if (el > g_conf.mds_cap_timeout / 3.0) { + renew_caps(); + } + +} + +void Client::renew_caps() +{ + dout(10) << "renew_caps" << dendl; + last_cap_renew_request = g_clock.now(); + + for (map::iterator p = mds_sessions.begin(); + p != mds_sessions.end(); + p++) { + dout(15) << "renew_caps requesting from mds" << p->first << dendl; + messenger->send_message(new MClientSession(CEPH_SESSION_REQUEST_RENEWCAPS), + mdsmap->get_inst(p->first)); + } +} + + // =============================================================== // high level (POSIXy) interface diff --git a/src/client/Client.h b/src/client/Client.h index 7881c56e5ac5d..c02e754eaae15 100644 --- a/src/client/Client.h +++ b/src/client/Client.h @@ -417,6 +417,13 @@ class Client : public Dispatcher { SafeTimer timer; + Context *tick_event; + utime_t last_cap_renew_request; + utime_t last_cap_renew; + void renew_caps(); +public: + void tick(); + protected: Messenger *messenger; int whoami; diff --git a/src/config.cc b/src/config.cc index 1bfe265eb3798..88a2592db3e05 100644 --- a/src/config.cc +++ b/src/config.cc @@ -188,6 +188,7 @@ md_config_t g_conf = { client_cache_readdir_ttl: 1, // 1 second only client_use_random_mds: false, client_mount_timeout: 10.0, // retry every N seconds + client_tick_interval: 1.0, client_hack_balance_reads: false, client_trace: 0, fuse_direct_io: 0, diff --git a/src/config.h b/src/config.h index a404510842286..165b9baef20a7 100644 --- a/src/config.h +++ b/src/config.h @@ -143,6 +143,7 @@ struct md_config_t { int client_cache_readdir_ttl; bool client_use_random_mds; // debug flag double client_mount_timeout; + double client_tick_interval; bool client_hack_balance_reads; const char *client_trace; int fuse_direct_io; -- 2.39.5