Version 2.6.6
[lttng-modules.git] / lttng-abi.c
index b83ed3d211defb747447469fc40bba06d816242b..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;
@@ -143,43 +144,6 @@ fd_error:
        return ret;
 }
 
-static
-int lttng_abi_syscall_list(void)
-{
-       struct file *syscall_list_file;
-       int file_fd, ret;
-
-       file_fd = get_unused_fd();
-       if (file_fd < 0) {
-               ret = file_fd;
-               goto fd_error;
-       }
-
-       syscall_list_file = anon_inode_getfile("[lttng_syscall_list]",
-                                         &lttng_syscall_list_fops,
-                                         NULL, O_RDWR);
-       if (IS_ERR(syscall_list_file)) {
-               ret = PTR_ERR(syscall_list_file);
-               goto file_error;
-       }
-       ret = lttng_syscall_list_fops.open(NULL, syscall_list_file);
-       if (ret < 0)
-               goto open_error;
-       fd_install(file_fd, syscall_list_file);
-       if (file_fd < 0) {
-               ret = file_fd;
-               goto fd_error;
-       }
-       return file_fd;
-
-open_error:
-       fput(syscall_list_file);
-file_error:
-       put_unused_fd(file_fd);
-fd_error:
-       return ret;
-}
-
 static
 void lttng_abi_tracer_version(struct lttng_kernel_tracer_version *v)
 {
@@ -369,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;
@@ -601,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;
@@ -663,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;
        }
@@ -718,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;
        }
@@ -820,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;
@@ -901,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
@@ -957,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;
@@ -1269,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.024685 seconds and 4 git commands to generate.