]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: add async_watch_flush api
authorHaomai Wang <haomai@xsky.com>
Fri, 19 Feb 2016 03:39:28 +0000 (11:39 +0800)
committerHaomai Wang <haomai@xsky.com>
Sat, 20 Feb 2016 06:37:23 +0000 (14:37 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/include/rados/librados.h
src/include/rados/librados.hpp
src/librados/librados.cc
src/tracing/librados.tp

index 51f4a1dbce0ae3b435bd336b06db94ce8cb1b021..776ae9fe094f32db590b4df4f7063fda503bbfb7 100644 (file)
@@ -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 */
 
index 73c24638e863a3d92b1c07d2bf7eddf61d40555d..d52e4a469e3ff175a09a6d49901c4eb51632c810 100644 (file)
@@ -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,
index 0c23e896a7848f94534735d4d6516f2f02fe01c9..3b76c406afc9cb495dfe6466f2310a165a61e8f6 100644 (file)
@@ -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)
index 89ab0a67d323f2e630a377319e4c90e2f97762d3..1ffebdd7a742ad4f3449705886124d4422613765 100644 (file)
@@ -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,