Version 2.8.7
[lttng-modules.git] / lttng-abi.c
index e046520e5f2a34357dbbffed484afc2ca978da9d..6a255ae55a95f7177fe9c5e0873c4fbf7f1b8f7f 100644 (file)
@@ -681,6 +681,7 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
                 */
                return -ENOSYS;
        }
+       case RING_BUFFER_FLUSH_EMPTY:   /* Fall-through. */
        case RING_BUFFER_FLUSH:
        {
                struct lttng_metadata_stream *stream = filp->private_data;
@@ -757,6 +758,28 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
                 */
                return -ENOSYS;
        }
+       case RING_BUFFER_FLUSH_EMPTY:   /* Fall-through. */
+       case RING_BUFFER_FLUSH:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+               struct lib_ring_buffer *buf = stream->priv;
+               struct channel *chan = buf->backend.chan;
+
+               /*
+                * Before doing the actual ring buffer flush, write up to one
+                * packet of metadata in the ring buffer.
+                */
+               ret = lttng_metadata_output_channel(stream, chan);
+               if (ret < 0)
+                       goto err;
+               break;
+       }
+       case RING_BUFFER_GET_METADATA_VERSION:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+
+               return put_u64(stream->version, arg);
+       }
        default:
                break;
        }
@@ -774,12 +797,6 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
                                cmd, arg);
                break;
        }
-       case RING_BUFFER_GET_METADATA_VERSION:
-       {
-               struct lttng_metadata_stream *stream = filp->private_data;
-
-               return put_u64(stream->version, arg);
-       }
        default:
                break;
        }
@@ -957,8 +974,11 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
                goto notransport;
        }
 
-       if (!lttng_kref_get(&session->metadata_cache->refcount))
+       if (!lttng_kref_get(&session->metadata_cache->refcount)) {
+               ret = -EOVERFLOW;
                goto kref_error;
+       }
+
        ret = lttng_abi_create_stream_fd(channel_file, stream_priv,
                        &lttng_metadata_ring_buffer_file_operations);
        if (ret < 0)
@@ -1017,6 +1037,7 @@ int lttng_abi_create_event(struct file *channel_file,
        /* The event holds a reference on the channel */
        if (atomic_long_add_unless(&channel_file->f_count,
                1, INT_MAX) == INT_MAX) {
+               ret = -EOVERFLOW;
                goto refcount_error;
        }
        if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT
This page took 0.022983 seconds and 4 git commands to generate.