1
0
mirror of https://github.com/ceph/ceph synced 2025-04-01 23:02:17 +00:00

mds: dont issue dentry lease if dir-wide lease will do

This commit is contained in:
Sage Weil 2008-03-28 10:34:59 -07:00
parent 9c9d441e34
commit d9f87357b4
4 changed files with 29 additions and 2 deletions

View File

@ -415,6 +415,7 @@ Inode* Client::insert_dentry_inode(Dir *dir, const string& dname, LeaseStat *dle
utime_t ttl = from;
ttl += (float)dlease->duration_ms * 1000.0;
if (ttl > dn->lease_ttl) {
dout(10) << "got dentry lease on " << dname << " ttl " << ttl << dendl;
dn->lease_ttl = ttl;
dn->lease_mds = from;
}

View File

@ -360,6 +360,11 @@ public:
return client_caps[client];
return 0;
}
int get_client_cap_pending(int client) {
Capability *c = get_client_cap(client);
if (c) return c->pending();
return 0;
}
Capability *add_client_cap(int client, CInode *in) {
if (client_caps.empty())
get(PIN_CAPS);

View File

@ -1055,8 +1055,15 @@ int Locker::issue_client_lease(CDentry *dn, int client,
bufferlist &bl, utime_t now, Session *session)
{
int pool = 1; // fixme.. do something smart!
// is it necessary?
// -> dont issue per-dentry lease if a dir lease is possible, or
// if the client is holding EXCL|RDCACHE caps.
int mask = 0;
if (dn->lock.can_lease()) mask |= CEPH_LOCK_DN;
CInode *diri = dn->get_dir()->get_inode();
if (!diri->dirlock.can_lease() &&
(diri->get_client_cap_pending(client) & (CEPH_CAP_EXCL|CEPH_CAP_RDCACHE)) == 0)
mask |= CEPH_LOCK_DN;
_issue_client_lease(dn, mask, pool, client, bl, now, session);
return mask;
@ -1077,8 +1084,15 @@ void Locker::revoke_client_leases(SimpleLock *lock)
n++;
if (lock->get_type() == CEPH_LOCK_DN) {
CDentry *dn = (CDentry*)lock->get_parent();
int mask = CEPH_LOCK_DN;
// i should also revoke the dir ICONTENT lease, if they have it!
CInode *diri = dn->get_dir()->get_inode();
if (diri->get_client_lease_mask(l->client) & CEPH_LOCK_ICONTENT)
mask |= CEPH_LOCK_ICONTENT;
mds->send_message_client(new MClientLease(CEPH_MDS_LEASE_REVOKE,
lock->get_type(),
mask,
dn->get_dir()->ino(),
dn->get_name()),
l->client);

View File

@ -622,6 +622,13 @@ protected:
return client_lease_map[c];
return 0;
}
int get_client_lease_mask(int c) {
ClientLease *l = get_client_lease(c);
if (l)
return l->mask;
else
return 0;
}
ClientLease *add_client_lease(int c, int mask);
int remove_client_lease(ClientLease *r, int mask, class Locker *locker); // returns remaining mask (if any), and kicks locker eval_gathers