From 71cf9d6a70d593d18dce1b0f7e9b1d5ab20332f6 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Fri, 30 Apr 2010 10:13:20 -0700 Subject: [PATCH] mds: fcntl locks can efficiently remove all locks from one client. --- src/mds/mdstypes.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 459bca3a74831..cbd9387957c1f 100644 --- a/src/mds/mdstypes.h +++ b/src/mds/mdstypes.h @@ -494,6 +494,20 @@ struct ceph_lock_state_t { } } + bool remove_all_from (client_t client) { + bool cleared_any = false; + if (client_held_lock_counts.count(client)) { + remove_all_from(client, held_locks); + client_held_lock_counts[client] = 0; + cleared_any = true; + } + if (client_waiting_lock_counts.count(client)) { + remove_all_from(client, waiting_locks); + client_waiting_lock_counts[client] = 0; + } + return cleared_any; + } + private: /** * Adjust old locks owned by a single process so that process can set @@ -589,6 +603,16 @@ private: } } + //this won't reset the counter map value, do that yourself + void remove_all_from(client_t client, multimap<__u64, ceph_filelock>& locks) { + multimap<__u64, ceph_filelock>::iterator iter = locks.begin(); + while (iter != locks.end()) { + if (iter->second.client == client) { + locks.erase(iter++); + } else ++iter; + } + } + //obviously, this is a skeleton for compilation purposes. multimap<__u64, ceph_filelock>::iterator find_specific_elem(ceph_filelock *elem, multimap<__u64, ceph_filelock>& map) { -- 2.39.5