]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: support aio_unwatch api
authorHaomai Wang <haomai@xsky.com>
Mon, 15 Feb 2016 09:31:12 +0000 (17:31 +0800)
committerHaomai Wang <haomai@xsky.com>
Sat, 20 Feb 2016 06:22:44 +0000 (14:22 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados/IoCtxImpl.cc
src/librados/IoCtxImpl.h
src/librados/librados.cc

index 17e19c9d9568538ac7a891b07b0b185ceaf86fc7..51f4a1dbce0ae3b435bd336b06db94ce8cb1b021 100644 (file)
@@ -2155,6 +2155,20 @@ CEPH_RADOS_API int rados_unwatch(rados_ioctx_t io, const char *o, uint64_t cooki
  */
 CEPH_RADOS_API int rados_unwatch2(rados_ioctx_t io, uint64_t cookie);
 
+/**
+ * Asynchronous unregister an interest in an object
+ *
+ * Once this completes, no more notifies will be sent to us for this
+ * watch. This should be called to clean up unneeded watchers.
+ *
+ * @param io the pool the object is in
+ * @param completion what to do when operation has been attempted
+ * @param cookie which watch to unregister
+ * @returns 0 on success, negative error code on failure
+ */
+CEPH_RADOS_API int rados_aio_unwatch(rados_ioctx_t io, uint64_t cookie,
+                                     rados_completion_t completion);
+
 /**
  * Sychronously notify watchers of an object
  *
index 6d42e2a5c684fe62eba1d70d729c80a313d8eb35..73c24638e863a3d92b1c07d2bf7eddf61d40555d 100644 (file)
@@ -992,6 +992,7 @@ namespace librados
     int aio_watch(const std::string& o, AioCompletion *c, uint64_t *handle,
               librados::WatchCtx2 *ctx);
     int unwatch2(uint64_t handle);
+    int aio_unwatch(uint64_t handle, AioCompletion *c);
     /**
      * Send a notify event ot watchers
      *
index 51c4478ab817383be32bc4aa06dca5d133499670..ead3a237c838e5a343a6e1c4d6a8c291b98d5a2d 100644 (file)
@@ -1327,6 +1327,22 @@ int librados::IoCtxImpl::unwatch(uint64_t cookie)
   return r;
 }
 
+int librados::IoCtxImpl::aio_unwatch(uint64_t cookie, AioCompletionImpl *c)
+{
+  c->io = this;
+  Objecter::LingerOp *linger_op = reinterpret_cast<Objecter::LingerOp*>(cookie);
+  Context *oncomplete = new C_aio_linger_Complete(c, linger_op, true);
+  version_t ver = 0;
+
+  ::ObjectOperation wr;
+  prepare_assert_ops(&wr);
+  wr.watch(cookie, CEPH_OSD_WATCH_OP_UNWATCH);
+  objecter->mutate(linger_op->target.base_oid, oloc, wr,
+                  snapc, ceph::real_clock::now(client->cct), 0, NULL,
+                  oncomplete, &ver);
+  return 0;
+}
+
 int librados::IoCtxImpl::notify(const object_t& oid, bufferlist& bl,
                                uint64_t timeout_ms,
                                bufferlist *preply_bl,
index 4e530b3f9c6993d51b44375a744ef4d06a4075eb..2bc554bf654e6be705c05950e11a1fb08f438375 100644 (file)
@@ -213,6 +213,7 @@ struct librados::IoCtxImpl {
                 librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2);
   int watch_check(uint64_t cookie);
   int unwatch(uint64_t cookie);
+  int aio_unwatch(uint64_t cookie, AioCompletionImpl *c);
   int notify(const object_t& oid, bufferlist& bl, uint64_t timeout_ms,
             bufferlist *preplybl, char **preply_buf, size_t *preply_buf_len);
   int notify_ack(const object_t& oid, uint64_t notify_id, uint64_t cookie,
index 1d12f407a518808cbbf48948652564fd7a0951c5..fffb787627e7d7b1e73f722f2a8dbd52645cc944 100644 (file)
@@ -1818,6 +1818,11 @@ int librados::IoCtx::unwatch2(uint64_t handle)
   return io_ctx_impl->unwatch(handle);
 }
 
+int librados::IoCtx::aio_unwatch(uint64_t handle, AioCompletion *c)
+{
+  return io_ctx_impl->aio_unwatch(handle, c->pc);
+}
+
 int librados::IoCtx::watch_check(uint64_t handle)
 {
   return io_ctx_impl->watch_check(handle);