]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fcntl locks can efficiently remove all locks from one client.
authorGreg Farnum <gregf@hq.newdream.net>
Fri, 30 Apr 2010 17:13:20 +0000 (10:13 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Mon, 2 Aug 2010 17:39:55 +0000 (10:39 -0700)
src/mds/mdstypes.h

index 459bca3a74831886052048acfae2abe9e69b7a1f..cbd9387957c1faf2f06288ed870d8c1b8286ef11 100644 (file)
@@ -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) {