static struct file_operations lttng_stream_ring_buffer_file_operations;
static int put_u64(uint64_t val, unsigned long arg);
+static int put_u32(uint32_t val, unsigned long arg);
/*
* Teardown management: opened file descriptors keep a refcount on the module,
int ret;
struct lttng_metadata_stream *stream = filp->private_data;
struct lib_ring_buffer *buf = stream->priv;
+ unsigned int rb_cmd;
+ bool coherent;
+
+ if (cmd == RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK)
+ rb_cmd = RING_BUFFER_GET_NEXT_SUBBUF;
+ else
+ rb_cmd = cmd;
switch (cmd) {
case RING_BUFFER_GET_NEXT_SUBBUF:
struct lib_ring_buffer *buf = stream->priv;
struct channel *chan = buf->backend.chan;
- ret = lttng_metadata_output_channel(stream, chan);
+ ret = lttng_metadata_output_channel(stream, chan, NULL);
if (ret > 0) {
lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
ret = 0;
* 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);
+ ret = lttng_metadata_output_channel(stream, chan, NULL);
if (ret < 0)
goto err;
break;
return lttng_metadata_cache_dump(stream);
}
+ case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK:
+ {
+ 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, &coherent);
+ if (ret > 0) {
+ lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+ ret = 0;
+ } else if (ret < 0) {
+ goto err;
+ }
+ break;
+ }
default:
break;
}
/* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
/* Performing lib ring buffer ioctl after our own. */
- ret = lib_ring_buffer_ioctl(filp, cmd, arg, buf);
+ ret = lib_ring_buffer_ioctl(filp, rb_cmd, arg, buf);
if (ret < 0)
goto err;
cmd, arg);
break;
}
+ case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK:
+ {
+ return put_u32(coherent, arg);
+ }
default:
break;
}
int ret;
struct lttng_metadata_stream *stream = filp->private_data;
struct lib_ring_buffer *buf = stream->priv;
+ unsigned int rb_cmd;
+ bool coherent;
+
+ if (cmd == RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK)
+ rb_cmd = RING_BUFFER_GET_NEXT_SUBBUF;
+ else
+ rb_cmd = cmd;
switch (cmd) {
case RING_BUFFER_GET_NEXT_SUBBUF:
struct lib_ring_buffer *buf = stream->priv;
struct channel *chan = buf->backend.chan;
- ret = lttng_metadata_output_channel(stream, chan);
+ ret = lttng_metadata_output_channel(stream, chan, NULL);
if (ret > 0) {
lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
ret = 0;
* 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);
+ ret = lttng_metadata_output_channel(stream, chan, NULL);
if (ret < 0)
goto err;
break;
return lttng_metadata_cache_dump(stream);
}
+ case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK:
+ {
+ 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, &coherent);
+ if (ret > 0) {
+ lib_ring_buffer_switch_slow(buf, SWITCH_ACTIVE);
+ ret = 0;
+ } else if (ret < 0) {
+ goto err;
+ }
+ break;
+ }
default:
break;
}
/* PUT_SUBBUF is the one from lib ring buffer, unmodified. */
/* Performing lib ring buffer ioctl after our own. */
- ret = lib_ring_buffer_compat_ioctl(filp, cmd, arg, buf);
+ ret = lib_ring_buffer_compat_ioctl(filp, rb_cmd, arg, buf);
if (ret < 0)
goto err;
cmd, arg);
break;
}
+ case RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK:
+ {
+ return put_u32(coherent, arg);
+ }
default:
break;
}
metadata_stream->priv = buf;
stream_priv = metadata_stream;
metadata_stream->transport = channel->transport;
+ /* Initial state is an empty metadata, considered as incoherent. */
+ metadata_stream->coherent = false;
/*
* Since life-time of metadata cache differs from that of
return put_user(val, (uint64_t __user *) arg);
}
+static int put_u32(uint32_t val, unsigned long arg)
+{
+ return put_user(val, (uint32_t __user *) arg);
+}
+
static long lttng_stream_ring_buffer_ioctl(struct file *filp,
unsigned int cmd, unsigned long arg)
{