]> 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>
Fri, 1 Aug 2014 23:39:19 +0000 (16:39 -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>
(cherry picked from commit 09626501d7a0ff964027fd7a534465b76bad23cb)

src/osd/osd_types.h

index b70951cf57a93cf5667e8739439092c8a4e00955..6173c2fdb98a16b0df5428e90574fc69cd8125e3 100644 (file)
@@ -2762,19 +2762,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:
@@ -2823,7 +2825,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()) {