]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fnctl. finish remove_locks so it'll activate whichever locks it can.
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 27 Apr 2010 00:33:19 +0000 (17:33 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Mon, 2 Aug 2010 17:39:55 +0000 (10:39 -0700)
This is lazy but it should work.

src/mds/mdstypes.h

index cc4c23e1e3ba4911a06f54606abaa059dcbc8308..8ddacddda21e95d5b9d915ddad5707074d7ab4ce 100644 (file)
@@ -388,7 +388,8 @@ struct ceph_lock_state_t {
    * Remove lock(s) described in old_lock. This may involve splitting a
    * previous lock or making a previous lock smaller.
    */
-  void remove_lock(ceph_filelock removal_lock) {
+  void remove_lock(ceph_filelock removal_lock,
+                  list<ceph_filelock>& activated_locks) {
     list<ceph_filelock*> overlapping_locks, self_overlapping_locks,
       crossed_waiting_locks;
     if (get_overlapping_locks(removal_lock, overlapping_locks)) {
@@ -433,6 +434,27 @@ struct ceph_lock_state_t {
        } else held_locks.erase(find_specific_elem(old_lock, held_locks));
       }
     }
+
+    /* okay, we've removed the locks, but removing them might allow some
+     * other waiting locks to come through */
+    if (get_waiting_overlaps(removal_lock, crossed_waiting_locks)) {
+      /*let's do this the SUPER lazy way for now. Should work out something
+       that's slightly less slow and wasteful, though.
+       1) Remove lock from waiting_locks.
+       2) attempt to insert lock via add_lock
+       3) Add to success list if we get back "true"
+
+       In the future, should probably set this up to detect some
+       guaranteed blocks and do fewer map lookups.
+       */
+      for (list<ceph_filelock*>::iterator iter = crossed_waiting_locks.begin();
+          iter != crossed_waiting_locks.end();
+          ++iter) {
+       ceph_filelock cur_lock = *(*iter);
+       waiting_locks.erase(find_specific_elem(*iter, waiting_locks));
+       if(add_lock(cur_lock, true)) activated_locks.push_back(cur_lock);
+      }
+    }
   }
 
 private: