Metadata flush writes data from the cache
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 16 Sep 2013 15:18:33 +0000 (11:18 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 16 Sep 2013 17:28:23 +0000 (12:28 -0500)
When doing a flush on a metadata stream we first check if we can fill
the current subbuffer with data from the cache before doing the actual
flush.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-abi.c
lttng-events.c

index 224b35284d859ce1b181c8fbb75ed06596d44f9e..a373504c26d0d7804e22cafb4e0dcac3747212a9 100644 (file)
@@ -548,23 +548,6 @@ unsigned int lttng_metadata_ring_buffer_poll(struct file *filp,
        return mask;
 }
 
-static
-int lttng_metadata_ring_buffer_ioctl_get_next_subbuf(struct file *filp,
-               unsigned int cmd, unsigned long arg)
-{
-       struct lttng_metadata_stream *stream = filp->private_data;
-       struct lib_ring_buffer *buf = stream->priv;
-       struct channel *chan = buf->backend.chan;
-       int ret;
-
-       ret = lttng_metadata_output_channel(stream, chan);
-       if (ret > 0) {
-               lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
-               ret = 0;
-       }
-       return ret;
-}
-
 static
 void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file *filp,
                unsigned int cmd, unsigned long arg)
@@ -585,9 +568,15 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
        switch (cmd) {
        case RING_BUFFER_GET_NEXT_SUBBUF:
        {
-               ret = lttng_metadata_ring_buffer_ioctl_get_next_subbuf(filp,
-                               cmd, arg);
-               if (ret < 0)
+               struct lttng_metadata_stream *stream = filp->private_data;
+               struct lib_ring_buffer *buf = stream->priv;
+               struct channel *chan = buf->backend.chan;
+
+               ret = lttng_metadata_output_channel(stream, chan);
+               if (ret > 0) {
+                       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+                       ret = 0;
+               } else if (ret < 0)
                        goto err;
                break;
        }
@@ -598,6 +587,21 @@ long lttng_metadata_ring_buffer_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;
+       }
        default:
                break;
        }
@@ -634,9 +638,15 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
        switch (cmd) {
        case RING_BUFFER_GET_NEXT_SUBBUF:
        {
-               ret = lttng_metadata_ring_buffer_ioctl_get_next_subbuf(filp,
-                               cmd, arg);
-               if (ret < 0)
+               struct lttng_metadata_stream *stream = filp->private_data;
+               struct lib_ring_buffer *buf = stream->priv;
+               struct channel *chan = buf->backend.chan;
+
+               ret = lttng_metadata_output_channel(stream, chan);
+               if (ret > 0) {
+                       lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+                       ret = 0;
+               } else if (ret < 0)
                        goto err;
                break;
        }
index 879097b4a8c7af056c0f0ec57dbef4d9376e7c57..b7e44221958d1230be181178dc3e90f5ce1990fa 100644 (file)
@@ -553,6 +553,8 @@ void _lttng_event_destroy(struct lttng_event *event)
  * sessions_mutex), so we can do racy operations such as looking for
  * remaining space left in packet and write, since mutual exclusion
  * protects us from concurrent writes.
+ * Returns the number of bytes written in the channel, 0 if no data
+ * was written and a negative value on error.
  */
 int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
                struct channel *chan)
This page took 0.028899 seconds and 4 git commands to generate.