From afdc3ccded50bd7d6c2fc12e35c001b32a210743 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Fri, 19 Feb 2016 11:39:28 +0800 Subject: [PATCH] librados: add async_watch_flush api Signed-off-by: Haomai Wang --- src/include/rados/librados.h | 15 +++++++++++++++ src/include/rados/librados.hpp | 1 + src/librados/librados.cc | 17 +++++++++++++++++ src/tracing/librados.tp | 18 ++++++++++++++++++ 4 files changed, 51 insertions(+) diff --git a/src/include/rados/librados.h b/src/include/rados/librados.h index 51f4a1dbce0..776ae9fe094 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 73c24638e86..d52e4a469e3 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 0c23e896a78..3b76c406afc 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 89ab0a67d32..1ffebdd7a74 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, -- 2.47.3