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 | ||
6f9449c2 JG |
13 | /* |
14 | * Create a consumer stream. | |
15 | * | |
16 | * The channel lock MUST be acquired. | |
17 | */ | |
18 | struct lttng_consumer_stream *consumer_stream_create( | |
19 | struct lttng_consumer_channel *channel, | |
20 | uint64_t channel_key, | |
21 | uint64_t stream_key, | |
22 | const char *channel_name, | |
23 | uint64_t relayd_id, | |
24 | uint64_t session_id, | |
25 | struct lttng_trace_chunk *trace_chunk, | |
26 | int cpu, | |
27 | int *alloc_ret, | |
28 | enum consumer_channel_type type, | |
29 | unsigned int monitor); | |
30 | ||
51230d70 DG |
31 | /* |
32 | * Close stream's file descriptors and, if needed, close stream also on the | |
33 | * relayd side. | |
34 | * | |
35 | * The stream lock MUST be acquired. | |
36 | * The consumer data lock MUST be acquired. | |
37 | */ | |
38 | void consumer_stream_close(struct lttng_consumer_stream *stream); | |
39 | ||
40 | /* | |
41 | * Close stream on the relayd side. This call can destroy a relayd if the | |
42 | * conditions are met. | |
43 | * | |
44 | * A RCU read side lock MUST be acquired if the relayd object was looked up in | |
45 | * a hash table before calling this. | |
46 | */ | |
47 | void consumer_stream_relayd_close(struct lttng_consumer_stream *stream, | |
48 | struct consumer_relayd_sock_pair *relayd); | |
49 | ||
50 | /* | |
51 | * Delete the stream from all possible hash tables. | |
52 | * | |
53 | * The consumer data lock MUST be acquired. | |
54 | */ | |
55 | void consumer_stream_delete(struct lttng_consumer_stream *stream, | |
56 | struct lttng_ht *ht); | |
57 | ||
58 | /* | |
59 | * Free the given stream within a RCU call. | |
60 | */ | |
61 | void consumer_stream_free(struct lttng_consumer_stream *stream); | |
62 | ||
63 | /* | |
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. | |
67 | * | |
68 | * This MUST be called WITHOUT the consumer data and stream lock acquired. | |
69 | */ | |
70 | void consumer_stream_destroy(struct lttng_consumer_stream *stream, | |
71 | struct lttng_ht *ht); | |
72 | ||
10a50311 JD |
73 | /* |
74 | * Destroy the stream's buffers on the tracer side. This is also called in a | |
75 | * stream destroy. | |
76 | */ | |
77 | void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream); | |
78 | ||
1c20f0e2 JD |
79 | /* |
80 | * Write index of a specific stream either on the relayd or local disk. | |
81 | */ | |
82 | int consumer_stream_write_index(struct lttng_consumer_stream *stream, | |
50adc264 | 83 | struct ctf_packet_index *index); |
1c20f0e2 | 84 | |
94d49140 JD |
85 | int consumer_stream_sync_metadata(struct lttng_consumer_local_data *ctx, |
86 | uint64_t session_id); | |
87 | ||
d2956687 | 88 | /* |
c35f9726 | 89 | * Create the output files of a local stream. |
d2956687 JG |
90 | * |
91 | * This must be called with the channel's and the stream's lock held. | |
92 | */ | |
93 | int consumer_stream_create_output_files(struct lttng_consumer_stream *stream, | |
94 | bool create_index); | |
95 | ||
96 | /* | |
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). | |
100 | * | |
101 | * This must be called with the channel's and the stream's lock held. | |
102 | */ | |
103 | int consumer_stream_rotate_output_files(struct lttng_consumer_stream *stream); | |
104 | ||
cdb72e4e JG |
105 | /* |
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. | |
109 | * | |
110 | * This function must be called with the RCU read side lock held. | |
111 | */ | |
112 | bool consumer_stream_is_deleted(struct lttng_consumer_stream *stream); | |
113 | ||
f5ba75b4 JG |
114 | /* |
115 | * Enable metadata bucketization. This must only be enabled if the tracer | |
116 | * provides a reliable metadata `coherent` flag. | |
117 | * | |
118 | * This must be called on initialization before any subbuffer is consumed. | |
119 | */ | |
120 | int consumer_stream_enable_metadata_bucketization( | |
121 | struct lttng_consumer_stream *stream); | |
122 | ||
55954e07 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 | */ | |
130 | void consumer_stream_metadata_set_version( | |
131 | struct lttng_consumer_stream *stream, uint64_t new_version); | |
132 | ||
51230d70 | 133 | #endif /* LTTNG_CONSUMER_STREAM_H */ |