]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rados : added an asynchronous unlock to the API
authorSebastien Ponce <Sebastien.Ponce@cern.ch>
Wed, 25 May 2016 07:28:29 +0000 (09:28 +0200)
committerroot <root@lxbre43a05.cern.ch>
Tue, 1 Nov 2016 15:36:05 +0000 (16:36 +0100)
Signed-off-by: Sebastien Ponce <sebastien.ponce@cern.ch>
src/cls/lock/cls_lock_client.cc
src/cls/lock/cls_lock_client.h
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados/librados.cc
src/tracing/librados.tp

index fc2790b92d756a743ebe2f0d43c8578edb5096c0..f56bc52697f6a1d126b3778c137ea44da62a8b3a 100644 (file)
@@ -83,6 +83,15 @@ namespace rados {
         return ioctx->operate(oid, &op);
       }
 
+      int aio_unlock(IoCtx *ioctx, const string& oid,
+                    const string& name, const string& cookie,
+                    librados::AioCompletion *completion)
+      {
+        ObjectWriteOperation op;
+        unlock(&op, name, cookie);
+        return ioctx->aio_operate(oid, completion, &op);
+      }
+
       void break_lock(ObjectWriteOperation *rados_op,
                       const string& name, const string& cookie,
                       const entity_name_t& locker)
index 13fb3f154b0d3488325a30694ccc3900670494c1..e94606e3e63f559db8051f123bf02d634499c218 100644 (file)
@@ -33,6 +33,10 @@ namespace rados {
       extern int unlock(librados::IoCtx *ioctx, const std::string& oid,
                        const std::string& name, const std::string& cookie);
 
+      extern int aio_unlock(librados::IoCtx *ioctx, const std::string& oid,
+                           const std::string& name, const std::string& cookie,
+                           librados::AioCompletion *completion);
+
       extern void break_lock(librados::ObjectWriteOperation *op,
                             const std::string& name, const std::string& cookie,
                             const entity_name_t& locker);
index 126cb6a83320f24bc419c527ab258d99d205fda0..5738290f6d1dc1c60ece31f43004415ce8b959db 100644 (file)
@@ -3086,6 +3086,20 @@ CEPH_RADOS_API int rados_lock_shared(rados_ioctx_t io, const char * o,
 CEPH_RADOS_API int rados_unlock(rados_ioctx_t io, const char *o,
                                 const char *name, const char *cookie);
 
+/**
+ * Asynchronous release a shared or exclusive lock on an object.
+ *
+ * @param io the context to operate in
+ * @param o the name of the object
+ * @param name the name of the lock
+ * @param cookie user-defined identifier for the instance of the lock
+ * @param completion what to do when operation has been attempted
+ * @returns 0 on success, negative error code on failure
+ */
+CEPH_RADOS_API int rados_aio_unlock(rados_ioctx_t io, const char *o,
+                                    const char *name, const char *cookie,
+                                   rados_completion_t completion);
+
 /**
  * List clients that have locked the named object lock and information about
  * the lock.
index f4ab24dbc2e1149a98f84f6fb8b1411f5d5653d5..7ef5ae3367dba6e54acbd2b11fdc549c9da01812 100644 (file)
@@ -983,6 +983,12 @@ namespace librados
     int aio_exec(const std::string& oid, AioCompletion *c, const char *cls, const char *method,
                 bufferlist& inbl, bufferlist *outbl);
 
+    /*
+     * asynchronous version of unlock
+     */
+    int aio_unlock(const std::string &oid, const std::string &name,
+                  const std::string &cookie, AioCompletion *c);
+
     // compound object operations
     int operate(const std::string& oid, ObjectWriteOperation *op);
     int operate(const std::string& oid, ObjectReadOperation *op, bufferlist *pbl);
index 328f76a3cb6916bcd01697a7b1a93482e20d1d60..01595ea327cf411d73b3937163bd11b8fdb79518 100644 (file)
@@ -1627,6 +1627,31 @@ int librados::IoCtx::unlock(const std::string &oid, const std::string &name,
   return rados::cls::lock::unlock(this, oid, name, cookie);
 }
 
+struct AioUnlockCompletion : public librados::ObjectOperationCompletion {
+  librados::AioCompletionImpl *completion;
+  AioUnlockCompletion(librados::AioCompletion *c) : completion(c->pc) {
+    completion->get();
+  };
+  void handle_completion(int r, bufferlist& outbl) {
+    rados_callback_t cb = completion->callback_complete;
+    void *cb_arg = completion->callback_complete_arg;
+    cb(completion, cb_arg);
+    completion->lock.Lock();
+    completion->callback_complete = NULL;
+    completion->cond.Signal();
+    completion->put_unlock();
+  }
+};
+
+int librados::IoCtx::aio_unlock(const std::string &oid, const std::string &name,
+                               const std::string &cookie, AioCompletion *c)
+{
+  librados::AioCompletion *completion = librados::Rados::aio_create_completion();
+  int rc = rados::cls::lock::aio_unlock(this, oid, name, cookie, completion);
+  completion->release();
+  return rc;
+}
+
 int librados::IoCtx::break_lock(const std::string &oid, const std::string &name,
                                const std::string &client, const std::string &cookie)
 {
@@ -4809,6 +4834,19 @@ extern "C" int rados_unlock(rados_ioctx_t io, const char *o, const char *name,
   return retval;
 }
 
+extern "C" int rados_aio_unlock(rados_ioctx_t io, const char *o, const char *name,
+                               const char *cookie, rados_completion_t completion)
+{
+  tracepoint(librados, rados_aio_unlock_enter, io, o, name, cookie, completion);
+  librados::IoCtx ctx;
+  librados::IoCtx::from_rados_ioctx_t(io, ctx);
+  librados::AioCompletionImpl *comp = (librados::AioCompletionImpl*)completion;
+  librados::AioCompletion c(comp);
+  int retval = ctx.aio_unlock(o, name, cookie, &c);
+  tracepoint(librados, rados_aio_unlock_exit, retval);
+  return retval;
+}
+
 extern "C" ssize_t rados_list_lockers(rados_ioctx_t io, const char *o,
                                      const char *name, int *exclusive,
                                      char *tag, size_t *tag_len,
index 054bc6d9567844e23fa6fa3561738d45a086fd9e..837145c5dc24c1c92c8bb61f2f3540a8cffbf01a 100644 (file)
@@ -2723,6 +2723,30 @@ TRACEPOINT_EVENT(librados, rados_unlock_exit,
     )
 )
 
+TRACEPOINT_EVENT(librados, rados_aio_unlock_enter,
+    TP_ARGS(
+        rados_ioctx_t, ioctx,
+        const char*, oid,
+        const char*, name,
+        const char*, cookie,
+        rados_completion_t, completion),
+    TP_FIELDS(
+        ctf_integer_hex(rados_ioctx_t, ioctx, ioctx)
+        ctf_string(oid, oid)
+        ceph_ctf_string(name, name)
+        ceph_ctf_string(cookie, cookie)
+        ctf_integer_hex(rados_completion_t, completion, completion)
+    )
+)
+
+TRACEPOINT_EVENT(librados, rados_aio_unlock_exit,
+    TP_ARGS(
+        int, retval),
+    TP_FIELDS(
+        ctf_integer(int, retval, retval)
+    )
+)
+
 TRACEPOINT_EVENT(librados, rados_list_lockers_enter,
     TP_ARGS(
         rados_ioctx_t, ioctx,