]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: allow ops to be canceled
authorSage Weil <sage@inktank.com>
Sun, 18 Aug 2013 00:01:53 +0000 (17:01 -0700)
committerSage Weil <sage@inktank.com>
Fri, 30 Aug 2013 23:54:16 +0000 (16:54 -0700)
This is useful in general, and specifically will be useful for the
rados COPY operation.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osdc/Objecter.cc
src/osdc/Objecter.h

index af6ebd6ae179e25466c5cf8b5ce326d66fe466f9..75292d13ac3ad14baa7ddc3a6994127e1a10816f 100644 (file)
@@ -1281,6 +1281,32 @@ tid_t Objecter::_op_submit(Op *op)
   return op->tid;
 }
 
+int Objecter::op_cancel(tid_t tid)
+{
+  assert(client_lock.is_locked());
+  assert(initialized);
+
+  map<tid_t, Op*>::iterator p = ops.find(tid);
+  if (p == ops.end()) {
+    ldout(cct, 10) << __func__ << " tid " << tid << " dne" << dendl;
+    return -ENOENT;
+  }
+
+  ldout(cct, 10) << __func__ << " tid " << tid << dendl;
+  Op *op = p->second;
+  if (op->onack) {
+    op->onack->complete(-ECANCELED);
+    op->onack = NULL;
+  }
+  if (op->oncommit) {
+    op->oncommit->complete(-ECANCELED);
+    op->oncommit = NULL;
+  }
+  op_cancel_map_check(op);
+  finish_op(op);
+  return 0;
+}
+
 bool Objecter::is_pg_changed(vector<int>& o, vector<int>& n, bool any_change)
 {
   if (o.empty() && n.empty())
index 4fdaa407a58bb8e859906d60e8e50c3ba4dfb5e7..f4ef5b7629175a28c246b0aae394090e10059b00 100644 (file)
@@ -1255,6 +1255,9 @@ private:
   /** Clear the passed flags from the global op flag set */
   void clear_global_op_flag(int flags) { global_op_flags &= ~flags; }
 
+  /// cancel an in-progress request
+  int op_cancel(tid_t tid);
+
   // commands
   int osd_command(int osd, vector<string>& cmd, bufferlist& inbl, tid_t *ptid,
                    bufferlist *poutbl, string *prs, Context *onfinish) {