X-Git-Url: http://git.lttng.org/?p=lttng-modules.git;a=blobdiff_plain;f=lttng-abi.c;h=d202b728451209526e02bc8dae0a984570521bc5;hp=77e5e9859e7f51099964f4002b932faf98531984;hb=d1344afaa0bc9707015a0ded9b312e43e58ed2d9;hpb=4d328377868e2f8fc2027c2492c3cd53615dffdc diff --git a/lttng-abi.c b/lttng-abi.c index 77e5e985..d202b728 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -654,6 +654,38 @@ void lttng_metadata_ring_buffer_ioctl_put_next_subbuf(struct file *filp, stream->metadata_out = stream->metadata_in; } +/* + * Reset the counter of how much metadata has been consumed to 0. That way, + * the consumer receives the content of the metadata cache unchanged. This is + * different from the metadata_regenerate where the offset from epoch is + * resampled, here we want the exact same content as the last time the metadata + * was generated. This command is only possible if all the metadata written + * in the cache has been output to the metadata stream to avoid corrupting the + * metadata file. + * + * Return 0 on success, a negative value on error. + */ +static +int lttng_metadata_cache_dump(struct lttng_metadata_stream *stream) +{ + int ret; + struct lttng_metadata_cache *cache = stream->metadata_cache; + + mutex_lock(&cache->lock); + if (stream->metadata_out != cache->metadata_written) { + ret = -EBUSY; + goto end; + } + stream->metadata_out = 0; + stream->metadata_in = 0; + wake_up_interruptible(&stream->read_wait); + ret = 0; + +end: + mutex_unlock(&cache->lock); + return ret; +} + static long lttng_metadata_ring_buffer_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) @@ -706,6 +738,12 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp, return put_u64(stream->version, arg); } + case RING_BUFFER_METADATA_CACHE_DUMP: + { + struct lttng_metadata_stream *stream = filp->private_data; + + return lttng_metadata_cache_dump(stream); + } default: break; } @@ -783,6 +821,12 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, return put_u64(stream->version, arg); } + case RING_BUFFER_METADATA_CACHE_DUMP: + { + struct lttng_metadata_stream *stream = filp->private_data; + + return lttng_metadata_cache_dump(stream); + } default: break; }