diff options
author | Venky Shankar <vshankar@redhat.com> | 2024-08-08 07:44:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-08 07:44:41 +0200 |
commit | 5ba8c92b978cfb311a630097ef43883219a2cb6d (patch) | |
tree | 2e1ef7bd2f35f338ce28e7d9a3de7d0a668b5c3b /src/mds/CDentry.cc | |
parent | Merge pull request #58983 from cyx1231st/wip-seastore-cleanup-cache (diff) | |
parent | mds: use intrusive set for ClientLease tracking (diff) | |
download | ceph-5ba8c92b978cfb311a630097ef43883219a2cb6d.tar.xz ceph-5ba8c92b978cfb311a630097ef43883219a2cb6d.zip |
Merge pull request #57911 from gardran/wip-gdran-mds-better-clease-handling
mds: some optimizations around client Capability and Lease tracking
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'src/mds/CDentry.cc')
-rw-r--r-- | src/mds/CDentry.cc | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index b9a232798d8..942bd9a9ec6 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -500,22 +500,30 @@ void CDentry::decode_lock_state(int type, const bufferlist& bl) } -ClientLease *CDentry::add_client_lease(client_t c, Session *session) -{ - ClientLease *l; - if (client_lease_map.count(c)) - l = client_lease_map[c]; - else { - dout(20) << __func__ << " client." << c << " on " << lock << dendl; - if (client_lease_map.empty()) { +MEMPOOL_DEFINE_OBJECT_FACTORY(ClientLease, mds_client_lease, mds_co); + +client_t ClientLease::get_client() const +{ + return session->get_client(); +} + +ClientLease *CDentry::add_client_lease(Session *session) +{ + client_t client = session->get_client(); + ClientLease* l = nullptr; + auto it = client_leases.lower_bound(client); + if (it == client_leases.end() || it->get_client() != client) { + l = new ClientLease(this, session); + dout(20) << __func__ << " client." << client << " on " << lock << dendl; + if (client_leases.empty()) { get(PIN_CLIENTLEASE); lock.get_client_lease(); } - l = client_lease_map[c] = new ClientLease(c, this); + client_leases.insert_before(it, *l); l->seq = ++session->lease_seq; - + } else { + l = &(*it); } - return l; } @@ -524,15 +532,14 @@ void CDentry::remove_client_lease(ClientLease *l, Locker *locker) ceph_assert(l->parent == this); bool gather = false; + dout(20) << __func__ << " client." << l->get_client() << " on " << lock << dendl; - dout(20) << __func__ << " client." << l->client << " on " << lock << dendl; - - client_lease_map.erase(l->client); l->item_lease.remove_myself(); l->item_session_lease.remove_myself(); + client_leases.erase(client_leases.iterator_to(*l)); delete l; - if (client_lease_map.empty()) { + if (client_leases.empty()) { gather = !lock.is_stable(); lock.put_client_lease(); put(PIN_CLIENTLEASE); @@ -544,8 +551,8 @@ void CDentry::remove_client_lease(ClientLease *l, Locker *locker) void CDentry::remove_client_leases(Locker *locker) { - while (!client_lease_map.empty()) - remove_client_lease(client_lease_map.begin()->second, locker); + while (!client_leases.empty()) + remove_client_lease(&(*client_leases.begin()), locker); } void CDentry::_put() |