From: Haomai Wang Date: Fri, 19 Feb 2016 03:39:28 +0000 (+0800) Subject: librados: add async_watch_flush api X-Git-Tag: v10.1.0~321^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=afdc3ccded50bd7d6c2fc12e35c001b32a210743;p=ceph.git librados: add async_watch_flush api Signed-off-by: Haomai Wang --- diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 51f4a1dbce0a..776ae9fe094f 100644 --- a/src/include/rados/librados.h +++ b/src/include/rados/librados.h @@ -2273,6 +2273,21 @@ CEPH_RADOS_API int rados_notify_ack(rados_ioctx_t io, const char *o, * @param cluster the cluster handle */ CEPH_RADOS_API int rados_watch_flush(rados_t cluster); +/** + * Flush watch/notify callbacks + * + * This call will be nonblock, and the completion will be called + * until all pending watch/notify callbacks have been executed and + * the queue is empty. It should usually be called after shutting + * down any watches before shutting down the ioctx or + * librados to ensure that any callbacks do not misuse the ioctx (for + * example by calling rados_notify_ack after the ioctx has been + * destroyed). + * + * @param cluster the cluster handle + * @param completion what to do when operation has been attempted + */ +CEPH_RADOS_API int rados_aio_watch_flush(rados_t cluster, rados_completion_t completion); /** @} Watch/Notify */ diff --git a/src/include/rados/librados.hpp b/src/include/rados/librados.hpp index 73c24638e863..d52e4a469e3f 100644 --- a/src/include/rados/librados.hpp +++ b/src/include/rados/librados.hpp @@ -1133,6 +1133,7 @@ namespace librados int connect(); void shutdown(); int watch_flush(); + int aio_watch_flush(AioCompletion*); int conf_read_file(const char * const path) const; int conf_parse_argv(int argc, const char ** argv) const; int conf_parse_argv_remainder(int argc, const char ** argv, diff --git a/src/librados/librados.cc b/src/librados/librados.cc index 0c23e896a784..3b76c406afc9 100644 --- a/src/librados/librados.cc +++ b/src/librados/librados.cc @@ -2034,6 +2034,13 @@ int librados::Rados::watch_flush() return client->watch_flush(); } +int librados::Rados::aio_watch_flush(AioCompletion *c) +{ + if (!client) + return -EINVAL; + return client->async_watch_flush(c->pc); +} + void librados::Rados::shutdown() { if (!client) @@ -4376,6 +4383,16 @@ extern "C" int rados_watch_flush(rados_t cluster) return retval; } +extern "C" int rados_aio_watch_flush(rados_t cluster, rados_completion_t completion) +{ + tracepoint(librados, rados_aio_watch_flush_enter, cluster, completion); + librados::RadosClient *client = (librados::RadosClient *)cluster; + librados::AioCompletionImpl *c = (librados::AioCompletionImpl*)completion; + int retval = client->async_watch_flush(c); + tracepoint(librados, rados_aio_watch_flush_exit, retval); + return retval; +} + extern "C" int rados_set_alloc_hint(rados_ioctx_t io, const char *o, uint64_t expected_object_size, uint64_t expected_write_size) diff --git a/src/tracing/librados.tp b/src/tracing/librados.tp index 89ab0a67d323..1ffebdd7a742 100644 --- a/src/tracing/librados.tp +++ b/src/tracing/librados.tp @@ -2489,6 +2489,24 @@ TRACEPOINT_EVENT(librados, rados_watch_flush_exit, ) ) +TRACEPOINT_EVENT(librados, rados_aio_watch_flush_enter, + TP_ARGS( + rados_t, cluster, + rados_completion_t, completion), + TP_FIELDS( + ctf_integer_hex(rados_t, cluster, cluster) + ctf_integer_hex(rados_completion_t, completion, completion) + ) +) + +TRACEPOINT_EVENT(librados, rados_aio_watch_flush_exit, + TP_ARGS( + int, retval), + TP_FIELDS( + ctf_integer(int, retval, retval) + ) +) + TRACEPOINT_EVENT(librados, rados_set_alloc_hint_enter, TP_ARGS( rados_ioctx_t, ioctx,