From: Mathieu Desnoyers Date: Thu, 4 Nov 2021 20:51:34 +0000 (-0400) Subject: Refactoring: event create: introduce _lttng_event_recorder_metadata_statedump X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=ee7e9a186b9bf3815d6088e58d4bf816b27b9adf;p=lttng-modules.git Refactoring: event create: introduce _lttng_event_recorder_metadata_statedump Signed-off-by: Mathieu Desnoyers Change-Id: I03494b121ef036c240f95b6cd9cae37c434452e3 --- diff --git a/src/lttng-events.c b/src/lttng-events.c index 0115debb..cd8efff1 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -73,9 +73,7 @@ static void _lttng_event_destroy(struct lttng_kernel_event_common *event); static void _lttng_channel_destroy(struct lttng_kernel_channel_buffer *chan); static int _lttng_event_unregister(struct lttng_kernel_event_common *event); static -int _lttng_event_metadata_statedump(struct lttng_kernel_session *session, - struct lttng_kernel_channel_buffer *chan, - struct lttng_kernel_event_recorder *event); +int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *event); static int _lttng_session_metadata_statedump(struct lttng_kernel_session *session); static @@ -1163,7 +1161,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l WARN_ON_ONCE(!ret); ret = try_module_get(event_return->priv->desc->owner); WARN_ON_ONCE(!ret); - ret = _lttng_event_metadata_statedump(chan->parent.session, chan, event_recorder_return); + ret = _lttng_event_recorder_metadata_statedump(event_return); WARN_ON_ONCE(ret > 0); if (ret) { lttng_kernel_event_free(event_return); @@ -1243,7 +1241,7 @@ struct lttng_kernel_event_recorder *_lttng_kernel_event_recorder_create(struct l ret = -EINVAL; goto register_error; } - ret = _lttng_event_metadata_statedump(chan->parent.session, chan, event_recorder); + ret = _lttng_event_recorder_metadata_statedump(event); WARN_ON_ONCE(ret > 0); if (ret) { goto statedump_error; @@ -3664,12 +3662,19 @@ int _lttng_fields_metadata_statedump(struct lttng_kernel_session *session, * transaction. */ static -int _lttng_event_metadata_statedump(struct lttng_kernel_session *session, - struct lttng_kernel_channel_buffer *chan, - struct lttng_kernel_event_recorder *event_recorder) +int _lttng_event_recorder_metadata_statedump(struct lttng_kernel_event_common *event) { + struct lttng_kernel_event_recorder *event_recorder; + struct lttng_kernel_channel_buffer *chan; + struct lttng_kernel_session *session; int ret = 0; + if (event->type != LTTNG_KERNEL_EVENT_TYPE_RECORDER) + return 0; + event_recorder = container_of(event, struct lttng_kernel_event_recorder, parent); + chan = event_recorder->chan; + session = chan->parent.session; + if (event_recorder->priv->metadata_dumped || !LTTNG_READ_ONCE(session->active)) return 0; if (chan->priv->channel_type == METADATA_CHANNEL) @@ -4124,8 +4129,7 @@ skip_session: } list_for_each_entry(event_recorder_priv, &session->priv->events, parent.node) { - ret = _lttng_event_metadata_statedump(session, event_recorder_priv->pub->chan, - event_recorder_priv->pub); + ret = _lttng_event_recorder_metadata_statedump(&event_recorder_priv->pub->parent); if (ret) goto end; }