Fix: use "flush empty" ioctl for snapshots
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
index e1de0e71561fd891b6f363b93ffb47cd55ee714f..6a256fefd00fa06b107c61aff78ea09151e63627 100644 (file)
@@ -89,10 +89,12 @@ int kernctl_create_session(int fd)
 /* open the metadata global channel */
 int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
 {
-       struct lttng_kernel_old_channel old_channel;
        struct lttng_kernel_channel channel;
 
        if (lttng_kernel_use_old_abi) {
+               struct lttng_kernel_old_channel old_channel;
+
+               memset(&old_channel, 0, sizeof(old_channel));
                old_channel.overwrite = chops->overwrite;
                old_channel.subbuf_size = chops->subbuf_size;
                old_channel.num_subbuf = chops->num_subbuf;
@@ -111,6 +113,7 @@ int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
                                &old_channel);
        }
 
+       memset(&channel, 0, sizeof(channel));
        channel.overwrite = chops->overwrite;
        channel.subbuf_size = chops->subbuf_size;
        channel.num_subbuf = chops->num_subbuf;
@@ -230,6 +233,11 @@ int kernctl_session_regenerate_metadata(int fd)
        return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_METADATA_REGEN);
 }
 
+int kernctl_session_regenerate_statedump(int fd)
+{
+       return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_STATEDUMP);
+}
+
 int kernctl_create_stream(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
@@ -241,6 +249,7 @@ int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
        if (lttng_kernel_use_old_abi) {
                struct lttng_kernel_old_event old_event;
 
+               memset(&old_event, 0, sizeof(old_event));
                memcpy(old_event.name, ev->name, sizeof(old_event.name));
                old_event.instrumentation = ev->instrumentation;
                switch (ev->instrumentation) {
@@ -278,6 +287,7 @@ int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
        if (lttng_kernel_use_old_abi) {
                struct lttng_kernel_old_context old_ctx;
 
+               memset(&old_ctx, 0, sizeof(old_ctx));
                old_ctx.ctx = ctx->ctx;
                /* only type that uses the union */
                if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER) {
@@ -393,40 +403,14 @@ int kernctl_wait_quiescent(int fd)
                        LTTNG_KERNEL_WAIT_QUIESCENT);
 }
 
-int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
+int kernctl_buffer_flush(int fd)
 {
-       int ret;
-
-       if (lttng_kernel_use_old_abi == -1) {
-               ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
-               if (!ret) {
-                       lttng_kernel_use_old_abi = 0;
-                       goto end;
-               }
-               lttng_kernel_use_old_abi = 1;
-       }
-       if (lttng_kernel_use_old_abi) {
-               struct lttng_kernel_old_calibrate old_calibrate;
-
-               old_calibrate.type = calibrate->type;
-               ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_OLD_CALIBRATE,
-                               &old_calibrate);
-               if (ret) {
-                       goto end;
-               }
-               calibrate->type = old_calibrate.type;
-       } else {
-               ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
-       }
-
-end:
-       return ret;
+       return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_FLUSH);
 }
 
-
-int kernctl_buffer_flush(int fd)
+int kernctl_buffer_flush_empty(int fd)
 {
-       return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_FLUSH);
+       return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_FLUSH_EMPTY);
 }
 
 /* returns the version of the metadata. */
@@ -496,6 +480,16 @@ int kernctl_snapshot(int fd)
        return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT);
 }
 
+/*
+ * Get a snapshot of the current ring buffer producer and consumer positions,
+ * regardless of whether or not the two positions are contained within the
+ * same sub-buffer.
+ */
+int kernctl_snapshot_sample_positions(int fd)
+{
+       return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS);
+}
+
 /* Get the consumer position (iteration start) */
 int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
 {
This page took 0.025505 seconds and 5 git commands to generate.