Command to regenerate the metadata of a session
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 7 Aug 2015 21:07:28 +0000 (17:07 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 25 Sep 2015 16:30:00 +0000 (12:30 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/ringbuffer/vfs.h
lttng-abi.c
lttng-abi.h
lttng-events.c
lttng-events.h

index ea317a1eaa4854642393ad9173ab07c223e0a148..5444a4b2bb6404a68ffc675f9badf5ec7cd1c808 100644 (file)
@@ -113,6 +113,8 @@ ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
 #define RING_BUFFER_GET_MMAP_READ_OFFSET       _IOR(0xF6, 0x0B, unsigned long)
 /* flush the current sub-buffer */
 #define RING_BUFFER_FLUSH                      _IO(0xF6, 0x0C)
+/* Get the current version of the metadata cache (after a get_next). */
+#define RING_BUFFER_GET_METADATA_VERSION       _IOR(0xF6, 0x0D, uint64_t)
 
 #ifdef CONFIG_COMPAT
 /* Get a snapshot of the current ring buffer producer and consumer positions */
@@ -145,6 +147,8 @@ ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos,
 #define RING_BUFFER_COMPAT_GET_MMAP_READ_OFFSET        _IOR(0xF6, 0x0B, compat_ulong_t)
 /* flush the current sub-buffer */
 #define RING_BUFFER_COMPAT_FLUSH               RING_BUFFER_FLUSH
+/* Get the current version of the metadata cache (after a get_next). */
+#define RING_BUFFER_COMPAT_GET_METADATA_VERSION        RING_BUFFER_GET_METADATA_VERSION
 #endif /* CONFIG_COMPAT */
 
 #endif /* _LIB_RING_BUFFER_VFS_H */
index 4178d87724eed3b774a7978e831a514d50b7b088..d47280f502f61c3c4a5792752443030caeb58c2b 100644 (file)
@@ -69,6 +69,8 @@ static const struct file_operations lttng_metadata_fops;
 static const struct file_operations lttng_event_fops;
 static struct file_operations lttng_stream_ring_buffer_file_operations;
 
+static int put_u64(uint64_t val, unsigned long arg);
+
 /*
  * Teardown management: opened file descriptors keep a refcount on the module,
  * so it can only exit when all file descriptors are closed.
@@ -551,6 +553,8 @@ long lttng_session_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                return lttng_session_untrack_pid(session, (int) arg);
        case LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS:
                return lttng_session_list_tracker_pids(session);
+       case LTTNG_KERNEL_SESSION_METADATA_REGEN:
+               return lttng_session_metadata_regenerate(session);
        default:
                return -ENOIOCTLCMD;
        }
@@ -678,6 +682,12 @@ long lttng_metadata_ring_buffer_ioctl(struct file *filp,
                        goto err;
                break;
        }
+       case RING_BUFFER_GET_METADATA_VERSION:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+
+               return put_u64(stream->version, arg);
+       }
        default:
                break;
        }
@@ -750,6 +760,12 @@ long lttng_metadata_ring_buffer_compat_ioctl(struct file *filp,
                                cmd, arg);
                break;
        }
+       case RING_BUFFER_GET_METADATA_VERSION:
+       {
+               struct lttng_metadata_stream *stream = filp->private_data;
+
+               return put_u64(stream->version, arg);
+       }
        default:
                break;
        }
index 994d2805a142a1f7269a744ab3b6ceaf3144f282..a40b58f51dec8487c3e3d5a3c6d1129faac65dc3 100644 (file)
@@ -194,6 +194,7 @@ struct lttng_kernel_filter_bytecode {
 #define LTTNG_KERNEL_SESSION_UNTRACK_PID       \
        _IOR(0xF6, 0x59, int32_t)
 #define LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS _IO(0xF6, 0x58)
+#define LTTNG_KERNEL_SESSION_METADATA_REGEN    _IO(0xF6, 0x59)
 
 /* Channel FD ioctl */
 #define LTTNG_KERNEL_STREAM                    _IO(0xF6, 0x62)
index bd7b4efedba7d8522f81b2f7c54623155ebbe3c4..f648feb67a64c8ab180c429ec77db907e2ca5f8e 100644 (file)
@@ -270,6 +270,48 @@ end:
        return ret;
 }
 
+int lttng_session_metadata_regenerate(struct lttng_session *session)
+{
+       int ret = 0;
+       struct lttng_channel *chan;
+       struct lttng_event *event;
+       struct lttng_metadata_cache *cache = session->metadata_cache;
+       struct lttng_metadata_stream *stream;
+
+       mutex_lock(&sessions_mutex);
+       if (!session->active) {
+               ret = -EBUSY;
+               goto end;
+       }
+
+       mutex_lock(&cache->lock);
+       memset(cache->data, 0, cache->cache_alloc);
+       cache->metadata_written = 0;
+       cache->version++;
+       list_for_each_entry(stream, &session->metadata_cache->metadata_stream, list) {
+               stream->metadata_out = 0;
+               stream->metadata_in = 0;
+       }
+       mutex_unlock(&cache->lock);
+
+       session->metadata_dumped = 0;
+       list_for_each_entry(chan, &session->chan, list) {
+               chan->metadata_dumped = 0;
+       }
+
+       list_for_each_entry(event, &session->events, list) {
+               event->metadata_dumped = 0;
+       }
+
+       ret = _lttng_session_metadata_statedump(session);
+
+end:
+       mutex_unlock(&sessions_mutex);
+       return ret;
+}
+
+
+
 int lttng_channel_enable(struct lttng_channel *channel)
 {
        int ret = 0;
@@ -1517,6 +1559,10 @@ int lttng_metadata_output_channel(struct lttng_metadata_stream *stream,
        if (stream->metadata_in != stream->metadata_out)
                goto end;
 
+       /* Metadata regenerated, change the version. */
+       if (stream->metadata_cache->version != stream->version)
+               stream->version = stream->metadata_cache->version;
+
        len = stream->metadata_cache->metadata_written -
                stream->metadata_in;
        if (!len)
index 82b88e851769fe5ed813945921311d1ad72244b9..4bf8920f3fc18fe74b24704f7f45e1c4e244ec61 100644 (file)
@@ -421,6 +421,7 @@ struct lttng_metadata_stream {
        wait_queue_head_t read_wait;    /* Reader buffer-level wait queue */
        struct list_head list;          /* Stream list */
        struct lttng_transport *transport;
+       uint64_t version;               /* Current version of the metadata cache */
 };
 
 
@@ -466,7 +467,8 @@ struct lttng_metadata_cache {
        struct kref refcount;           /* Metadata cache usage */
        struct list_head metadata_stream;       /* Metadata stream list */
        uuid_le uuid;                   /* Trace session unique ID (copy) */
-       struct mutex lock;
+       struct mutex lock;              /* Produce/consume lock */
+       uint64_t version;               /* Current version of the metadata */
 };
 
 void lttng_lock_sessions(void);
@@ -487,6 +489,7 @@ struct lttng_session *lttng_session_create(void);
 int lttng_session_enable(struct lttng_session *session);
 int lttng_session_disable(struct lttng_session *session);
 void lttng_session_destroy(struct lttng_session *session);
+int lttng_session_metadata_regenerate(struct lttng_session *session);
 void metadata_cache_destroy(struct kref *kref);
 
 struct lttng_channel *lttng_channel_create(struct lttng_session *session,
This page took 0.029484 seconds and 4 git commands to generate.