mirror of
https://github.com/ceph/ceph
synced 2025-03-11 02:39:05 +00:00
client regularly renews caps
This commit is contained in:
parent
08f0e3e977
commit
65261037ff
@ -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<int,version_t>::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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user