summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Farnum <greg@inktank.com>2013-10-21 14:02:57 -0700
committerGreg Farnum <greg@inktank.com>2013-10-21 17:12:12 -0700
commiteb16ece1c83c8fe421824793b8168b9e3fe09121 (patch)
tree1656e630937718e91243f3b43f74882837f9f3aa
parenta4347eed4bbf1208c04c18d50619fa1e45ac5b0b (diff)
downloadceph-eb16ece1c83c8fe421824793b8168b9e3fe09121.tar.gz
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 <greg@inktank.com>
-rw-r--r--src/osd/ReplicatedPG.h24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h
index 00216170516..8130733b233 100644
--- a/src/osd/ReplicatedPG.h
+++ b/src/osd/ReplicatedPG.h
@@ -488,9 +488,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) {
@@ -502,17 +509,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) {
@@ -524,7 +537,6 @@ protected:
count++;
return true;
case READ:
- waiters.push_back(op);
return false;
default:
assert(0 == "unhandled case");