Version 2.6.6
[lttng-modules.git] / lttng-abi.c
index 381a73904dfe60e6e6d0a8bc66a0cecf5fd65bf8..0f01d3d7df558b3ad6515edddc5006d865693d8b 100644 (file)
@@ -49,6 +49,7 @@
 #include "wrapper/ringbuffer/backend.h"
 #include "wrapper/ringbuffer/frontend.h"
 #include "wrapper/poll.h"
+#include "wrapper/file.h"
 #include "lttng-abi.h"
 #include "lttng-abi-old.h"
 #include "lttng-events.h"
@@ -83,7 +84,7 @@ int lttng_abi_create_session(void)
        session = lttng_session_create();
        if (!session)
                return -ENOMEM;
-       session_fd = get_unused_fd();
+       session_fd = lttng_get_unused_fd();
        if (session_fd < 0) {
                ret = session_fd;
                goto fd_error;
@@ -112,7 +113,7 @@ int lttng_abi_tracepoint_list(void)
        struct file *tracepoint_list_file;
        int file_fd, ret;
 
-       file_fd = get_unused_fd();
+       file_fd = lttng_get_unused_fd();
        if (file_fd < 0) {
                ret = file_fd;
                goto fd_error;
@@ -332,7 +333,7 @@ int lttng_abi_create_channel(struct file *session_file,
        int chan_fd;
        int ret = 0;
 
-       chan_fd = get_unused_fd();
+       chan_fd = lttng_get_unused_fd();
        if (chan_fd < 0) {
                ret = chan_fd;
                goto fd_error;
@@ -564,9 +565,11 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp,
                if (finalized)
                        mask |= POLLHUP;
 
+               mutex_lock(&stream->metadata_cache->lock);
                if (stream->metadata_cache->metadata_written >
                                stream->metadata_out)
                        mask |= POLLIN;
+               mutex_unlock(&stream->metadata_cache->lock);
        }
 
        return mask;
@@ -626,6 +629,18 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
                        goto err;
                break;
        }
+       case RING_BUFFER_SNAPSHOT:
+       {
+               /*
+                * Force the buffer to quiescent so the ring buffer
+                * don't attempt to perform a SWITCH_FLUSH, which would
+                * desynchronize the client accounting of the amount of
+                * data available in the buffer from the ring buffer
+                * view.
+                */
+               buf->quiescent = true;
+               break;
+       }
        default:
                break;
        }
@@ -681,6 +696,33 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
                 */
                return -ENOSYS;
        }
+       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_SNAPSHOT:
+       {
+               /*
+                * Force the buffer to quiescent so the ring buffer
+                * don't attempt to perform a SWITCH_FLUSH, which would
+                * desynchronize the client accounting of the amount of
+                * data available in the buffer from the ring buffer
+                * view.
+                */
+               buf->quiescent = true;
+               break;
+       }
        default:
                break;
        }
@@ -783,7 +825,7 @@ int lttng_abi_create_stream_fd(struct file *channel_file, void *stream_priv,
        int stream_fd, ret;
        struct file *stream_file;
 
-       stream_fd = get_unused_fd();
+       stream_fd = lttng_get_unused_fd();
        if (stream_fd < 0) {
                ret = stream_fd;
                goto fd_error;
@@ -864,7 +906,6 @@ int lttng_abi_open_metadata_stream(struct file *channel_file)
        metadata_stream->priv = buf;
        stream_priv = metadata_stream;
        metadata_stream->transport = channel->transport;
-       mutex_init(&metadata_stream->lock);
 
        /*
         * Since life-time of metadata cache differs from that of
@@ -920,7 +961,7 @@ int lttng_abi_create_event(struct file *channel_file,
        }
        switch (event_param->instrumentation) {
        default:
-               event_fd = get_unused_fd();
+               event_fd = lttng_get_unused_fd();
                if (event_fd < 0) {
                        ret = event_fd;
                        goto fd_error;
@@ -1232,8 +1273,8 @@ int lttng_metadata_channel_release(struct inode *inode, struct file *file)
        struct lttng_channel *channel = file->private_data;
 
        if (channel) {
-               lttng_metadata_channel_destroy(channel);
                fput(channel->session->file);
+               lttng_metadata_channel_destroy(channel);
        }
 
        return 0;
This page took 0.027478 seconds and 4 git commands to generate.