+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;
+}
+
+
+