summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-02-28 09:56:43 -0800
committerYehuda Sadeh <yehuda@inktank.com>2013-02-28 09:56:43 -0800
commitf41809eb86f704cee33fa6ef6e000244dd02a601 (patch)
tree0788c74afbc1c84c445233d9ad581784a8aa3d60
parent35ce9d6374f5a6c61ddfa11c2a7a8cf1161c8df2 (diff)
downloadceph-wip-librados-exec.tar.gz
librados: add two more ObjectOperation::exec()wip-librados-exec
- one that also gets out bufferlist and ret value pointer - one that gets a callback context Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r--src/include/rados/librados.hpp9
-rw-r--r--src/librados/librados.cc30
-rw-r--r--src/osdc/Objecter.h16
3 files changed, 53 insertions, 2 deletions
diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp
index fb585d09811..d1b0d010498 100644
--- a/src/include/rados/librados.hpp
+++ b/src/include/rados/librados.hpp
@@ -115,6 +115,13 @@ namespace librados
OP_FAILOK = 2,
};
+
+ class ObjectOperationCompletion {
+ public:
+ virtual ~ObjectOperationCompletion() {}
+ virtual void handle_completion(int r, bufferlist& outbl) = 0;
+ };
+
/*
* ObjectOperation : compount object operation
* Batch multiple object operations into a single request, to be applied
@@ -136,6 +143,8 @@ namespace librados
void src_cmpxattr(const std::string& src_oid,
const char *name, int op, uint64_t v);
void exec(const char *cls, const char *method, bufferlist& inbl);
+ void exec(const char *cls, const char *method, bufferlist& inbl, bufferlist *obl, int *prval);
+ void exec(const char *cls, const char *method, bufferlist& inbl, ObjectOperationCompletion *completion);
/**
* Guard operation with a check that object version == ver
*
diff --git a/src/librados/librados.cc b/src/librados/librados.cc
index 0b7eaf97850..f5f95163081 100644
--- a/src/librados/librados.cc
+++ b/src/librados/librados.cc
@@ -133,6 +133,36 @@ void librados::ObjectOperation::exec(const char *cls, const char *method, buffer
o->call(cls, method, inbl);
}
+void librados::ObjectOperation::exec(const char *cls, const char *method, bufferlist& inbl, bufferlist *outbl, int *prval)
+{
+ ::ObjectOperation *o = (::ObjectOperation *)impl;
+ o->call(cls, method, inbl, outbl, NULL, prval);
+}
+
+class ObjectOpCompletionCtx : public Context {
+ librados::ObjectOperationCompletion *completion;
+ bufferlist bl;
+public:
+ ObjectOpCompletionCtx(librados::ObjectOperationCompletion *c) : completion(c) {}
+ void finish(int r) {
+ completion->handle_completion(r, bl);
+ delete completion;
+ }
+
+ bufferlist *outbl() {
+ return &bl;
+ }
+};
+
+void librados::ObjectOperation::exec(const char *cls, const char *method, bufferlist& inbl, librados::ObjectOperationCompletion *completion)
+{
+ ::ObjectOperation *o = (::ObjectOperation *)impl;
+
+ ObjectOpCompletionCtx *ctx = new ObjectOpCompletionCtx(completion);
+
+ o->call(cls, method, inbl, ctx->outbl(), ctx, NULL);
+}
+
void librados::ObjectReadOperation::stat(uint64_t *psize, time_t *pmtime, int *prval)
{
::ObjectOperation *o = (::ObjectOperation *)impl;
diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h
index 6cc3cb88426..5def518144e 100644
--- a/src/osdc/Objecter.h
+++ b/src/osdc/Objecter.h
@@ -120,8 +120,15 @@ struct ObjectOperation {
osd_op.indata.append(name);
osd_op.indata.append(data);
}
- void add_call(int op, const char *cname, const char *method, bufferlist &indata) {
+ void add_call(int op, const char *cname, const char *method, bufferlist &indata,
+ bufferlist *outbl, Context *ctx, int *prval) {
OSDOp& osd_op = add_op(op);
+
+ unsigned p = ops.size() - 1;
+ out_handler[p] = ctx;
+ out_bl[p] = outbl;
+ out_rval[p] = prval;
+
osd_op.op.op = op;
osd_op.op.cls.class_len = strlen(cname);
osd_op.op.cls.method_len = strlen(method);
@@ -506,7 +513,12 @@ struct ObjectOperation {
// object classes
void call(const char *cname, const char *method, bufferlist &indata) {
- add_call(CEPH_OSD_OP_CALL, cname, method, indata);
+ add_call(CEPH_OSD_OP_CALL, cname, method, indata, NULL, NULL, NULL);
+ }
+
+ void call(const char *cname, const char *method, bufferlist &indata, bufferlist *outdata,
+ Context *ctx, int *prval) {
+ add_call(CEPH_OSD_OP_CALL, cname, method, indata, outdata, ctx, prval);
}
// watch/notify