From 96ed5b8c38c21cd772d1b61554695e27d8144717 Mon Sep 17 00:00:00 2001 From: Greg Farnum Date: Mon, 21 Oct 2013 14:02:57 -0700 Subject: [PATCH] ReplicatedPG: separate RWTracker's waitlist from getting locks This way we can try and get locks which aren't associated with an OpRequest. Signed-off-by: Greg Farnum --- src/osd/ReplicatedPG.h | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index afa0ca7902edd..7b4b04b354f12 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -502,9 +502,16 @@ protected: ObjState() : state(NONE), count(0) {} bool get_read(OpRequestRef op) { - // don't starve! + if (get_read_lock()) { + return true; + } // else + waiters.push_back(op); + return false; + } + /// this function adjusts the counts if necessary + bool get_read_lock() { + // don't starve anybody! if (!waiters.empty()) { - waiters.push_back(op); return false; } switch (state) { @@ -516,17 +523,23 @@ protected: count++; return true; case WRITE: - waiters.push_back(op); return false; default: assert(0 == "unhandled case"); return false; } } + bool get_write(OpRequestRef op) { + if (get_write_lock()) { + return true; + } // else + waiters.push_back(op); + return false; + } + bool get_write_lock() { + // don't starve anybody! if (!waiters.empty()) { - // don't starve! - waiters.push_back(op); return false; } switch (state) { @@ -538,7 +551,6 @@ protected: count++; return true; case READ: - waiters.push_back(op); return false; default: assert(0 == "unhandled case"); -- 2.39.5