From: Greg Farnum Date: Fri, 30 Apr 2010 17:13:20 +0000 (-0700) Subject: mds: fcntl locks can efficiently remove all locks from one client. X-Git-Tag: v0.22~346^2~24 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71cf9d6a70d593d18dce1b0f7e9b1d5ab20332f6;p=ceph.git mds: fcntl locks can efficiently remove all locks from one client. --- diff --git a/src/mds/mdstypes.h b/src/mds/mdstypes.h index 459bca3a748..cbd9387957c 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) {