2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: GPL-2.0-only
8 #ifndef LTTNG_CONSUMER_STREAM_H
9 #define LTTNG_CONSUMER_STREAM_H
14 * Create a consumer stream.
16 * The channel lock MUST be acquired.
18 struct lttng_consumer_stream
*consumer_stream_create(
19 struct lttng_consumer_channel
*channel
,
22 const char *channel_name
,
25 struct lttng_trace_chunk
*trace_chunk
,
28 enum consumer_channel_type type
,
29 unsigned int monitor
);
32 * Close stream's file descriptors and, if needed, close stream also on the
35 * The stream lock MUST be acquired.
36 * The consumer data lock MUST be acquired.
38 void consumer_stream_close(struct lttng_consumer_stream
*stream
);
41 * Close stream on the relayd side. This call can destroy a relayd if the
44 * A RCU read side lock MUST be acquired if the relayd object was looked up in
45 * a hash table before calling this.
47 void consumer_stream_relayd_close(struct lttng_consumer_stream
*stream
,
48 struct consumer_relayd_sock_pair
*relayd
);
51 * Delete the stream from all possible hash tables.
53 * The consumer data lock MUST be acquired.
55 void consumer_stream_delete(struct lttng_consumer_stream
*stream
,
59 * Free the given stream within a RCU call.
61 void consumer_stream_free(struct lttng_consumer_stream
*stream
);
64 * Destroy a stream completely. This will delete, close and free the stream.
65 * Once return, the stream is NO longer usable. Its channel may get destroyed
66 * if conditions are met.
68 * This MUST be called WITHOUT the consumer data and stream lock acquired.
70 void consumer_stream_destroy(struct lttng_consumer_stream
*stream
,
74 * Destroy the stream's buffers on the tracer side. This is also called in a
77 void consumer_stream_destroy_buffers(struct lttng_consumer_stream
*stream
);
80 * Write index of a specific stream either on the relayd or local disk.
82 int consumer_stream_write_index(struct lttng_consumer_stream
*stream
,
83 struct ctf_packet_index
*index
);
85 int consumer_stream_sync_metadata(struct lttng_consumer_local_data
*ctx
,
89 * Create the output files of a local stream.
91 * This must be called with the channel's and the stream's lock held.
93 int consumer_stream_create_output_files(struct lttng_consumer_stream
*stream
,
97 * Rotate the output files of a local stream. This will change the
98 * active output files of both the binary and index in accordance
99 * with the stream's configuration (stream file count).
101 * This must be called with the channel's and the stream's lock held.
103 int consumer_stream_rotate_output_files(struct lttng_consumer_stream
*stream
);
106 * Indicates whether or not a stream is logically deleted. A deleted stream
107 * should no longer be used; its existence is only garanteed by the RCU lock
108 * held by the caller.
110 * This function must be called with the RCU read side lock held.
112 bool consumer_stream_is_deleted(struct lttng_consumer_stream
*stream
);
115 * Enable metadata bucketization. This must only be enabled if the tracer
116 * provides a reliable metadata `coherent` flag.
118 * This must be called on initialization before any subbuffer is consumed.
120 int consumer_stream_enable_metadata_bucketization(
121 struct lttng_consumer_stream
*stream
);
124 * Set the version of a metadata stream (i.e. following a metadata
127 * Changing the version of a metadata stream will cause any bucketized metadata
128 * to be discarded and will mark the metadata stream for future `reset`.
130 void consumer_stream_metadata_set_version(
131 struct lttng_consumer_stream
*stream
, uint64_t new_version
);
133 #endif /* LTTNG_CONSUMER_STREAM_H */