docs: Add supported versions and fix-backport policy
[lttng-tools.git] / src / common / consumer / consumer-stream.hpp
CommitLineData
51230d70 1/*
ab5be9fa 2 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
51230d70 3 *
ab5be9fa 4 * SPDX-License-Identifier: GPL-2.0-only
51230d70 5 *
51230d70
DG
6 */
7
8#ifndef LTTNG_CONSUMER_STREAM_H
9#define LTTNG_CONSUMER_STREAM_H
10
c9e313bc 11#include "consumer.hpp"
51230d70 12
503fefca
JG
13enum consumer_stream_open_packet_status {
14 CONSUMER_STREAM_OPEN_PACKET_STATUS_OPENED,
15 CONSUMER_STREAM_OPEN_PACKET_STATUS_NO_SPACE,
16 CONSUMER_STREAM_OPEN_PACKET_STATUS_ERROR,
17};
18
6f9449c2
JG
19/*
20 * Create a consumer stream.
21 *
22 * The channel lock MUST be acquired.
23 */
28f23191
JG
24struct lttng_consumer_stream *consumer_stream_create(struct lttng_consumer_channel *channel,
25 uint64_t channel_key,
26 uint64_t stream_key,
27 const char *channel_name,
28 uint64_t relayd_id,
29 uint64_t session_id,
30 struct lttng_trace_chunk *trace_chunk,
31 int cpu,
32 int *alloc_ret,
33 enum consumer_channel_type type,
34 unsigned int monitor);
6f9449c2 35
51230d70
DG
36/*
37 * Close stream's file descriptors and, if needed, close stream also on the
38 * relayd side.
39 *
40 * The stream lock MUST be acquired.
41 * The consumer data lock MUST be acquired.
42 */
d119bd01 43void consumer_stream_close_output(struct lttng_consumer_stream *stream);
51230d70
DG
44
45/*
46 * Close stream on the relayd side. This call can destroy a relayd if the
47 * conditions are met.
48 *
49 * A RCU read side lock MUST be acquired if the relayd object was looked up in
50 * a hash table before calling this.
51 */
52void consumer_stream_relayd_close(struct lttng_consumer_stream *stream,
28f23191 53 struct consumer_relayd_sock_pair *relayd);
51230d70
DG
54
55/*
56 * Delete the stream from all possible hash tables.
57 *
58 * The consumer data lock MUST be acquired.
59 */
28f23191 60void consumer_stream_delete(struct lttng_consumer_stream *stream, struct lttng_ht *ht);
51230d70
DG
61
62/*
63 * Free the given stream within a RCU call.
64 */
65void consumer_stream_free(struct lttng_consumer_stream *stream);
66
67/*
68 * Destroy a stream completely. This will delete, close and free the stream.
69 * Once return, the stream is NO longer usable. Its channel may get destroyed
70 * if conditions are met.
71 *
72 * This MUST be called WITHOUT the consumer data and stream lock acquired.
73 */
28f23191 74void consumer_stream_destroy(struct lttng_consumer_stream *stream, struct lttng_ht *ht);
51230d70 75
10a50311
JD
76/*
77 * Destroy the stream's buffers on the tracer side. This is also called in a
78 * stream destroy.
79 */
80void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);
81
1c20f0e2
JD
82/*
83 * Write index of a specific stream either on the relayd or local disk.
84 */
85int consumer_stream_write_index(struct lttng_consumer_stream *stream,
28f23191 86 struct ctf_packet_index *index);
1c20f0e2 87
28f23191 88int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, uint64_t session_id);
94d49140 89
d2956687 90/*
c35f9726 91 * Create the output files of a local stream.
d2956687
JG
92 *
93 * This must be called with the channel's and the stream's lock held.
94 */
28f23191 95int consumer_stream_create_output_files(struct lttng_consumer_stream *stream, bool create_index);
d2956687
JG
96
97/*
98 * Rotate the output files of a local stream. This will change the
99 * active output files of both the binary and index in accordance
100 * with the stream's configuration (stream file count).
101 *
102 * This must be called with the channel's and the stream's lock held.
103 */
104int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream);
105
cdb72e4e
JG
106/*
107 * Indicates whether or not a stream is logically deleted. A deleted stream
108 * should no longer be used; its existence is only garanteed by the RCU lock
109 * held by the caller.
110 *
111 * This function must be called with the RCU read side lock held.
112 */
113bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream);
114
f5ba75b4
JG
115/*
116 * Enable metadata bucketization. This must only be enabled if the tracer
117 * provides a reliable metadata `coherent` flag.
118 *
119 * This must be called on initialization before any subbuffer is consumed.
120 */
28f23191 121int consumer_stream_enable_metadata_bucketization(struct lttng_consumer_stream *stream);
f5ba75b4 122
503fefca
JG
123/*
124 * Set the version of a metadata stream (i.e. following a metadata
125 * regeneration).
126 *
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`.
129 */
28f23191
JG
130void consumer_stream_metadata_set_version(struct lttng_consumer_stream *stream,
131 uint64_t new_version);
503fefca
JG
132
133/*
134 * Attempt to open a packet in a stream.
135 *
136 * This function must be called with the stream and channel locks held.
137 */
28f23191
JG
138enum consumer_stream_open_packet_status
139consumer_stream_open_packet(struct lttng_consumer_stream *stream);
503fefca
JG
140
141/*
142 * Flush a stream's buffer.
143 *
144 * producer_active: if true, causes a flush to occur only if there is
145 * content present in the current sub-buffer. If false, forces a flush to take
146 * place (otherwise known as "flush_empty").
147 *
148 * This function must be called with the stream and channel locks held.
149 */
28f23191 150int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream, bool producer_active);
503fefca 151
51230d70 152#endif /* LTTNG_CONSUMER_STREAM_H */
This page took 0.081254 seconds and 4 git commands to generate.