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
17 enum consumer_stream_open_packet_status
{
18 CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED
,
19 CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE
,
20 CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR
,
24 * Create a consumer stream.
26 * The channel lock MUST be acquired.
28 struct lttng_consumer_stream
*consumer_stream_create(
29 struct lttng_consumer_channel
*channel
,
32 const char *channel_name
,
35 struct lttng_trace_chunk
*trace_chunk
,
38 enum consumer_channel_type type
,
39 unsigned int monitor
);
42 * Close stream's file descriptors and, if needed, close stream also on the
45 * The stream lock MUST be acquired.
46 * The consumer data lock MUST be acquired.
48 void consumer_stream_close(struct lttng_consumer_stream
*stream
);
51 * Close stream on the relayd side. This call can destroy a relayd if the
54 * A RCU read side lock MUST be acquired if the relayd object was looked up in
55 * a hash table before calling this.
57 void consumer_stream_relayd_close(struct lttng_consumer_stream
*stream
,
58 struct consumer_relayd_sock_pair
*relayd
);
61 * Delete the stream from all possible hash tables.
63 * The consumer data lock MUST be acquired.
65 void consumer_stream_delete(struct lttng_consumer_stream
*stream
,
69 * Free the given stream within a RCU call.
71 void consumer_stream_free(struct lttng_consumer_stream
*stream
);
74 * Destroy a stream completely. This will delete, close and free the stream.
75 * Once return, the stream is NO longer usable. Its channel may get destroyed
76 * if conditions are met.
78 * This MUST be called WITHOUT the consumer data and stream lock acquired.
80 void consumer_stream_destroy(struct lttng_consumer_stream
*stream
,
84 * Destroy the stream's buffers on the tracer side. This is also called in a
87 void consumer_stream_destroy_buffers(struct lttng_consumer_stream
*stream
);
90 * Write index of a specific stream either on the relayd or local disk.
92 int consumer_stream_write_index(struct lttng_consumer_stream
*stream
,
93 struct ctf_packet_index
*index
);
95 int consumer_stream_sync_metadata(struct lttng_consumer_local_data
*ctx
,
99 * Create the output files of a local stream.
101 * This must be called with the channel's and the stream's lock held.
103 int consumer_stream_create_output_files(struct lttng_consumer_stream
*stream
,
107 * Rotate the output files of a local stream. This will change the
108 * active output files of both the binary and index in accordance
109 * with the stream's configuration (stream file count).
111 * This must be called with the channel's and the stream's lock held.
113 int consumer_stream_rotate_output_files(struct lttng_consumer_stream
*stream
);
116 * Indicates whether or not a stream is logically deleted. A deleted stream
117 * should no longer be used; its existence is only garanteed by the RCU lock
118 * held by the caller.
120 * This function must be called with the RCU read side lock held.
122 bool consumer_stream_is_deleted(struct lttng_consumer_stream
*stream
);
125 * Enable metadata bucketization. This must only be enabled if the tracer
126 * provides a reliable metadata `coherent` flag.
128 * This must be called on initialization before any subbuffer is consumed.
130 int consumer_stream_enable_metadata_bucketization(
131 struct lttng_consumer_stream
*stream
);
134 * Set the version of a metadata stream (i.e. following a metadata
137 * Changing the version of a metadata stream will cause any bucketized metadata
138 * to be discarded and will mark the metadata stream for future `reset`.
140 void consumer_stream_metadata_set_version(
141 struct lttng_consumer_stream
*stream
, uint64_t new_version
);
144 * Set the version of a metadata stream (i.e. following a metadata
147 * Changing the version of a metadata stream will cause any bucketized metadata
148 * to be discarded and will mark the metadata stream for future `reset`.
150 void consumer_stream_metadata_set_version(
151 struct lttng_consumer_stream
*stream
, uint64_t new_version
);
154 * Attempt to open a packet in a stream.
156 * This function must be called with the stream and channel locks held.
158 enum consumer_stream_open_packet_status
consumer_stream_open_packet(
159 struct lttng_consumer_stream
*stream
);
162 * Flush a stream's buffer.
164 * producer_active: if true, causes a flush to occur only if there is
165 * content present in the current sub-buffer. If false, forces a flush to take
166 * place (otherwise known as "flush_empty").
168 * This function must be called with the stream and channel locks held.
170 int consumer_stream_flush_buffer(struct lttng_consumer_stream
*stream
,
171 bool producer_active
);
177 #endif /* LTTNG_CONSUMER_STREAM_H */