From: Haomai Wang Date: Mon, 15 Feb 2016 09:31:12 +0000 (+0800) Subject: librados: support aio_unwatch api X-Git-Tag: v10.1.0~321^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=28ac263865ff554c8f1430bf9288c21129bba595;p=ceph.git librados: support aio_unwatch api Signed-off-by: Haomai Wang --- diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 17e19c9d9568..51f4a1dbce0a 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -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 * diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 6d42e2a5c684..73c24638e863 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -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 * diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index 51c4478ab817..ead3a237c838 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -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(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, diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 4e530b3f9c69..2bc554bf654e 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -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, diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 1d12f407a518..fffb787627e7 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -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);