From: Sage Weil Date: Tue, 22 Jul 2014 20:11:42 +0000 (-0700) Subject: osd: allow greedy get_write() for ObjectContext locks X-Git-Tag: v0.83~5^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09626501d7a0ff964027fd7a534465b76bad23cb;p=ceph.git osd: allow greedy get_write() for ObjectContext locks 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 --- diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 7d01403fbe64..10ab4c9925c6 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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()) {