From e6ad4d4a44c1a575a601363c839cc0e1fa5d1b8f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 18 Dec 2013 11:23:50 -0800 Subject: [PATCH] osd: make obc copyfrom blocking generic Signed-off-by: Sage Weil --- src/osd/ReplicatedPG.cc | 6 +++--- src/osd/osd_types.h | 14 +++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index d79aaf5e667..9a154cb07e9 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4531,7 +4531,7 @@ void ReplicatedPG::start_copy(CopyCallback *cb, ObjectContextRef obc, CopyOpRef cop(new CopyOp(cb, obc, src, oloc, version, flags, temp_dest_oid)); copy_ops[dest] = cop; - ++obc->copyfrom_readside; + obc->start_block(); _copy_some(obc, cop); } @@ -4621,7 +4621,7 @@ void ReplicatedPG::process_copy_chunk(hobject_t oid, tid_t tid, int r) cop->cb->complete(results); copy_ops.erase(cobc->obs.oi.soid); - --cobc->copyfrom_readside; + cobc->stop_block(); kick_object_context_blocked(cobc); } @@ -4774,7 +4774,7 @@ void ReplicatedPG::cancel_copy(CopyOpRef cop, bool requeue) } copy_ops.erase(cop->obc->obs.oi.soid); - --cop->obc->copyfrom_readside; + cop->obc->stop_block(); kick_object_context_blocked(cop->obc); cop->results->should_requeue = requeue; diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 12913cc3c0b..7a0ac4d0d1b 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2274,7 +2274,7 @@ public: int unstable_writes, readers, writers_waiting, readers_waiting; /// in-progress copyfrom ops for this object - int copyfrom_readside; + bool blocked; // set if writes for this object are blocked on another objects recovery ObjectContextRef blocked_by; // object blocking our writes @@ -2422,7 +2422,7 @@ public: destructor_callback(0), lock("ReplicatedPG::ObjectContext::lock"), unstable_writes(0), readers(0), writers_waiting(0), readers_waiting(0), - copyfrom_readside(0) {} + blocked(false) {} ~ObjectContext() { assert(rwstate.empty()); @@ -2430,8 +2430,16 @@ public: destructor_callback->complete(0); } + void start_block() { + assert(!blocked); + blocked = true; + } + void stop_block() { + assert(blocked); + blocked = false; + } bool is_blocked() const { - return copyfrom_readside > 0; + return blocked; } // do simple synchronous mutual exclusion, for now. now waitqueues or anything fancy.