Commit | Line | Data |
---|---|---|
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 | ||
11 | #include "consumer.h" | |
12 | ||
503fefca JG |
13 | enum 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 | */ | |
24 | struct lttng_consumer_stream *consumer_stream_create( | |
25 | struct lttng_consumer_channel *channel, | |
26 | uint64_t channel_key, | |
27 | uint64_t stream_key, | |
28 | const char *channel_name, | |
29 | uint64_t relayd_id, | |
30 | uint64_t session_id, | |
31 | struct lttng_trace_chunk *trace_chunk, | |
32 | int cpu, | |
33 | int *alloc_ret, | |
34 | enum consumer_channel_type type, | |
35 | unsigned int monitor); | |
36 | ||
51230d70 DG |
37 | /* |
38 | * Close stream's file descriptors and, if needed, close stream also on the | |
39 | * relayd side. | |
40 | * | |
41 | * The stream lock MUST be acquired. | |
42 | * The consumer data lock MUST be acquired. | |
43 | */ | |
44 | void consumer_stream_close(struct lttng_consumer_stream *stream); | |
45 | ||
46 | /* | |
47 | * Close stream on the relayd side. This call can destroy a relayd if the | |
48 | * conditions are met. | |
49 | * | |
50 | * A RCU read side lock MUST be acquired if the relayd object was looked up in | |
51 | * a hash table before calling this. | |
52 | */ | |
53 | void consumer_stream_relayd_close(struct lttng_consumer_stream *stream, | |
54 | struct consumer_relayd_sock_pair *relayd); | |
55 | ||
56 | /* | |
57 | * Delete the stream from all possible hash tables. | |
58 | * | |
59 | * The consumer data lock MUST be acquired. | |
60 | */ | |
61 | void consumer_stream_delete(struct lttng_consumer_stream *stream, | |
62 | struct lttng_ht *ht); | |
63 | ||
64 | /* | |
65 | * Free the given stream within a RCU call. | |
66 | */ | |
67 | void consumer_stream_free(struct lttng_consumer_stream *stream); | |
68 | ||
69 | /* | |
70 | * Destroy a stream completely. This will delete, close and free the stream. | |
71 | * Once return, the stream is NO longer usable. Its channel may get destroyed | |
72 | * if conditions are met. | |
73 | * | |
74 | * This MUST be called WITHOUT the consumer data and stream lock acquired. | |
75 | */ | |
76 | void consumer_stream_destroy(struct lttng_consumer_stream *stream, | |
77 | struct lttng_ht *ht); | |
78 | ||
10a50311 JD |
79 | /* |
80 | * Destroy the stream's buffers on the tracer side. This is also called in a | |
81 | * stream destroy. | |
82 | */ | |
83 | void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream); | |
84 | ||
1c20f0e2 JD |
85 | /* |
86 | * Write index of a specific stream either on the relayd or local disk. | |
87 | */ | |
88 | int consumer_stream_write_index(struct lttng_consumer_stream *stream, | |
50adc264 | 89 | struct ctf_packet_index *index); |
1c20f0e2 | 90 | |
94d49140 JD |
91 | int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, |
92 | uint64_t session_id); | |
93 | ||
d2956687 | 94 | /* |
c35f9726 | 95 | * Create the output files of a local stream. |
d2956687 JG |
96 | * |
97 | * This must be called with the channel's and the stream's lock held. | |
98 | */ | |
99 | int consumer_stream_create_output_files(struct lttng_consumer_stream *stream, | |
100 | bool create_index); | |
101 | ||
102 | /* | |
103 | * Rotate the output files of a local stream. This will change the | |
104 | * active output files of both the binary and index in accordance | |
105 | * with the stream's configuration (stream file count). | |
106 | * | |
107 | * This must be called with the channel's and the stream's lock held. | |
108 | */ | |
109 | int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream); | |
110 | ||
cdb72e4e JG |
111 | /* |
112 | * Indicates whether or not a stream is logically deleted. A deleted stream | |
113 | * should no longer be used; its existence is only garanteed by the RCU lock | |
114 | * held by the caller. | |
115 | * | |
116 | * This function must be called with the RCU read side lock held. | |
117 | */ | |
118 | bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream); | |
119 | ||
f5ba75b4 JG |
120 | /* |
121 | * Enable metadata bucketization. This must only be enabled if the tracer | |
122 | * provides a reliable metadata `coherent` flag. | |
123 | * | |
124 | * This must be called on initialization before any subbuffer is consumed. | |
125 | */ | |
126 | int consumer_stream_enable_metadata_bucketization( | |
127 | struct lttng_consumer_stream *stream); | |
128 | ||
55954e07 JG |
129 | /* |
130 | * Set the version of a metadata stream (i.e. following a metadata | |
131 | * regeneration). | |
132 | * | |
133 | * Changing the version of a metadata stream will cause any bucketized metadata | |
134 | * to be discarded and will mark the metadata stream for future `reset`. | |
135 | */ | |
136 | void consumer_stream_metadata_set_version( | |
137 | struct lttng_consumer_stream *stream, uint64_t new_version); | |
138 | ||
503fefca JG |
139 | /* |
140 | * Set the version of a metadata stream (i.e. following a metadata | |
141 | * regeneration). | |
142 | * | |
143 | * Changing the version of a metadata stream will cause any bucketized metadata | |
144 | * to be discarded and will mark the metadata stream for future `reset`. | |
145 | */ | |
146 | void consumer_stream_metadata_set_version( | |
147 | struct lttng_consumer_stream *stream, uint64_t new_version); | |
148 | ||
149 | /* | |
150 | * Attempt to open a packet in a stream. | |
151 | * | |
152 | * This function must be called with the stream and channel locks held. | |
153 | */ | |
154 | enum consumer_stream_open_packet_status consumer_stream_open_packet( | |
155 | struct lttng_consumer_stream *stream); | |
156 | ||
157 | /* | |
158 | * Flush a stream's buffer. | |
159 | * | |
160 | * producer_active: if true, causes a flush to occur only if there is | |
161 | * content present in the current sub-buffer. If false, forces a flush to take | |
162 | * place (otherwise known as "flush_empty"). | |
163 | * | |
164 | * This function must be called with the stream and channel locks held. | |
165 | */ | |
166 | int consumer_stream_flush_buffer(struct lttng_consumer_stream *stream, | |
167 | bool producer_active); | |
168 | ||
51230d70 | 169 | #endif /* LTTNG_CONSUMER_STREAM_H */ |