X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=lttng-abi.c;h=ea746c2cfbfb33b1ee7b191be351de9d81bd86a6;hb=d7921a5faa41a160c2679bb130e31c79ee8641f2;hp=87465189060edd4122cc9f8c5ad87c3fe218b6f1;hpb=96c55c2f6b20fd742b3ea2aa291c28e140df82d8;p=lttng-modules.git diff --git a/lttng-abi.c b/lttng-abi.c index 87465189..ea746c2c 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -51,10 +51,12 @@ #include #include #include +#include #include #include #include #include +#include #include /* @@ -396,7 +398,7 @@ int lttng_abi_create_channel(struct file *session_file, fops = <tng_metadata_fops; break; } - + chan_file = anon_inode_getfile("[lttng_channel]", fops, NULL, O_RDWR); @@ -569,6 +571,8 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg) return lttng_session_list_tracker_pids(session); case LTTNG_KERNEL_SESSION_METADATA_REGEN: return lttng_session_metadata_regenerate(session); + case LTTNG_KERNEL_SESSION_STATEDUMP: + return lttng_session_statedump(session); default: return -ENOIOCTLCMD; } @@ -651,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) @@ -681,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; @@ -702,6 +739,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; } @@ -757,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; @@ -778,6 +822,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; } @@ -972,8 +1022,11 @@ int lttng_abi_open_metadata_stream(struct file *channel_file) goto notransport; } - if (!lttng_kref_get(&session->metadata_cache->refcount)) + if (!lttng_kref_get(&session->metadata_cache->refcount)) { + ret = -EOVERFLOW; goto kref_error; + } + ret = lttng_abi_create_stream_fd(channel_file, stream_priv, <tng_metadata_ring_buffer_file_operations); if (ret < 0) @@ -1039,8 +1092,12 @@ int lttng_abi_create_event(struct file *channel_file, || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) { struct lttng_enabler *enabler; - if (event_param->name[strlen(event_param->name) - 1] == '*') { - enabler = lttng_enabler_create(LTTNG_ENABLER_WILDCARD, + if (strutils_is_star_glob_pattern(event_param->name)) { + /* + * If the event name is a star globbing pattern, + * we create the special star globbing enabler. + */ + enabler = lttng_enabler_create(LTTNG_ENABLER_STAR_GLOB, event_param, channel); } else { enabler = lttng_enabler_create(LTTNG_ENABLER_NAME, @@ -1715,9 +1772,15 @@ 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); - + if (!lttng_proc_dentry) { printk(KERN_ERR "Error creating LTTng control file\n"); ret = -ENOMEM; @@ -1727,6 +1790,7 @@ int __init lttng_abi_init(void) return 0; error: + lttng_tp_mempool_destroy(); lttng_clock_unref(); return ret; } @@ -1734,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);