]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: make obc copyfrom blocking generic
authorSage Weil <sage@inktank.com>
Wed, 18 Dec 2013 19:23:50 +0000 (11:23 -0800)
committerSage Weil <sage@inktank.com>
Wed, 18 Dec 2013 19:30:18 +0000 (11:30 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/osd_types.h

index d79aaf5e6674dd2d2077baf9fbe819532b84c15d..9a154cb07e9a3238e40933dcbda6d7667c2c447c 100644 (file)
@@ -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;
index 12913cc3c0b7124bc869d566e4acda3d3c0f351e..7a0ac4d0d1ba8f2fc83c940a5ecdab77518a1fd4 100644 (file)
@@ -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.