X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-abi.c;h=ea746c2cfbfb33b1ee7b191be351de9d81bd86a6;hb=d7921a5faa41a160c2679bb130e31c79ee8641f2;hp=f2b207cbac95aa9ced52b603242784ca90caaaf3;hpb=4993071a89f88f92444cf62abdc0935efbc6c460;p=lttng-modules.git diff --git a/lttng-abi.c b/lttng-abi.c index f2b207cb..ea746c2c 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -56,6 +56,7 @@ #include #include #include +#include #include /* @@ -654,6 +655,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) @@ -684,6 +717,7 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp, */ return -ENOSYS; } + case RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */ case RING_BUFFER_FLUSH: { struct lttng_metadata_stream *stream = filp->private_data; @@ -705,17 +739,11 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp, return put_u64(stream->version, arg); } - case RING_BUFFER_SNAPSHOT: + case RING_BUFFER_METADATA_CACHE_DUMP: { - /* - * 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; + struct lttng_metadata_stream *stream = filp->private_data; + + return lttng_metadata_cache_dump(stream); } default: break; @@ -772,6 +800,7 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, */ return -ENOSYS; } + case RING_BUFFER_FLUSH_EMPTY: /* Fall-through. */ case RING_BUFFER_FLUSH: { struct lttng_metadata_stream *stream = filp->private_data; @@ -793,17 +822,11 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp, return put_u64(stream->version, arg); } - case RING_BUFFER_SNAPSHOT: + case RING_BUFFER_METADATA_CACHE_DUMP: { - /* - * 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; + struct lttng_metadata_stream *stream = filp->private_data; + + return lttng_metadata_cache_dump(stream); } default: break; @@ -1749,6 +1772,12 @@ int __init lttng_abi_init(void) wrapper_vmalloc_sync_all(); lttng_clock_ref(); + + ret = lttng_tp_mempool_init(); + if (ret) { + goto error; + } + lttng_proc_dentry = proc_create_data("lttng", S_IRUSR | S_IWUSR, NULL, <tng_fops, NULL); @@ -1761,6 +1790,7 @@ int __init lttng_abi_init(void) return 0; error: + lttng_tp_mempool_destroy(); lttng_clock_unref(); return ret; } @@ -1768,6 +1798,7 @@ error: /* No __exit annotation because used by init error path too. */ void lttng_abi_exit(void) { + lttng_tp_mempool_destroy(); lttng_clock_unref(); if (lttng_proc_dentry) remove_proc_entry("lttng", NULL);