diff options
author | Sage Weil <sage@inktank.com> | 2013-08-17 17:01:53 -0700 |
---|---|---|
committer | Sage Weil <sage@inktank.com> | 2013-08-30 16:54:16 -0700 |
commit | 36d6e6fa40679be72bf8bce3f9d404dcf6ea6c10 (patch) | |
tree | 50f09b4d25fe3e7aa630d071b6010d23088cbc3f | |
parent | 42b3d55ddb2cacd138003db986baf62a9d452a3d (diff) | |
download | ceph-36d6e6fa40679be72bf8bce3f9d404dcf6ea6c10.tar.gz |
osdc/Objecter: allow ops to be canceled
This is useful in general, and specifically will be useful for the
rados COPY operation.
Signed-off-by: Sage Weil <sage@inktank.com>
-rw-r--r-- | src/osdc/Objecter.cc | 26 | ||||
-rw-r--r-- | src/osdc/Objecter.h | 3 |
2 files changed, 29 insertions, 0 deletions
diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index af6ebd6ae17..75292d13ac3 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -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()) diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 4fdaa407a58..f4ef5b76291 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -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) { |