]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: allow greedy get_write() for ObjectContext locks
authorSage Weil <sage@redhat.com>
Tue, 22 Jul 2014 20:11:42 +0000 (13:11 -0700)
committerSage Weil <sage@redhat.com>
Wed, 23 Jul 2014 01:00:09 +0000 (18:00 -0700)
There are several lockers that need to take a write lock
because there is an operation that is already in progress and
know it is safe to do so.  In particular, they need to skip
the starvation checks (op waiters, backfill waiting).

Signed-off-by: Sage Weil <sage@redhat.com>
src/osd/osd_types.h

index 7d01403fbe6406188c91c60aea7db4deb3fe004e..10ab4c9925c6e5f0fedcac2270dc762f1c52478b 100644 (file)
@@ -2780,19 +2780,21 @@ public:
       }
     }
 
-    bool get_write(OpRequestRef op) {
-      if (get_write_lock()) {
+    bool get_write(OpRequestRef op, bool greedy=false) {
+      if (get_write_lock(greedy)) {
        return true;
       } // else
       if (op)
        waiters.push_back(op);
       return false;
     }
-    bool get_write_lock() {
-      // don't starve anybody!
-      if (!waiters.empty() ||
-         backfill_read_marker) {
-       return false;
+    bool get_write_lock(bool greedy=false) {
+      if (!greedy) {
+       // don't starve anybody!
+       if (!waiters.empty() ||
+           backfill_read_marker) {
+         return false;
+       }
       }
       switch (state) {
       case RWNONE:
@@ -2841,7 +2843,10 @@ public:
     return rwstate.get_read(op);
   }
   bool get_write(OpRequestRef op) {
-    return rwstate.get_write(op);
+    return rwstate.get_write(op, false);
+  }
+  bool get_write_greedy(OpRequestRef op) {
+    return rwstate.get_write(op, true);
   }
   bool get_snaptrimmer_write() {
     if (rwstate.get_write_lock()) {