summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-08-17 17:01:53 -0700
committerSage Weil <sage@inktank.com>2013-08-26 16:17:10 -0700
commitab8d43b380727a83dd9d728d49fdae4bdbecea64 (patch)
treef6a802dee20702ec562b85c864d7df57982a7f72
parentdea45a9a1c3c73d8add88c7fd807305a6c8607e3 (diff)
downloadceph-ab8d43b380727a83dd9d728d49fdae4bdbecea64.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.cc26
-rw-r--r--src/osdc/Objecter.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc
index c66f5a275b7..78f22fabe37 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 1276972cc4b..16d0e5011f5 100644
--- a/src/osdc/Objecter.h
+++ b/src/osdc/Objecter.h
@@ -1254,6 +1254,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) {