Commit | Line | Data |
---|---|---|
2c5ff4e4 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
2c5ff4e4 | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
2c5ff4e4 | 5 | * |
2c5ff4e4 JG |
6 | */ |
7 | ||
8 | #ifndef LTTNG_TRACE_CHUNK_REGISTRY_H | |
9 | #define LTTNG_TRACE_CHUNK_REGISTRY_H | |
10 | ||
11 | #include <stddef.h> | |
12 | #include <stdint.h> | |
13 | #include <stdbool.h> | |
14 | #include <common/macros.h> | |
15 | #include <common/trace-chunk.h> | |
16 | ||
17 | struct lttng_trace_chunk_registry; | |
18 | ||
19 | /* | |
20 | * Create an lttng_trace_chunk registry. | |
21 | * | |
22 | * A trace chunk registry maintains an association between a | |
23 | * (session_id, chunk_id) tuple and a trace chunk object. The chunk_id can | |
24 | * be "unset" in the case of an anonymous trace chunk. | |
25 | * | |
26 | * Note that a trace chunk registry holds no ownership of its trace | |
27 | * chunks. Trace chunks are unpublished when their last reference is released. | |
28 | * See the documentation of lttng_trace_chunk. | |
29 | * | |
30 | * Returns a trace chunk registry on success, NULL on error. | |
31 | * | |
32 | * Note that a trace chunk registry may only be accessed by an RCU thread. | |
33 | */ | |
34 | LTTNG_HIDDEN | |
35 | struct lttng_trace_chunk_registry *lttng_trace_chunk_registry_create(void); | |
36 | ||
37 | /* | |
38 | * Destroy an lttng trace chunk registry. The registry must be emptied | |
39 | * (i.e. all references to the trace chunks it contains must be released) before | |
40 | * it is destroyed. | |
41 | */ | |
42 | LTTNG_HIDDEN | |
43 | void lttng_trace_chunk_registry_destroy( | |
44 | struct lttng_trace_chunk_registry *registry); | |
45 | ||
46 | /* | |
47 | * Publish a trace chunk for a given session id. | |
48 | * A reference is acquired on behalf of the caller. | |
49 | * | |
50 | * The trace chunk that is returned is the published version of the trace | |
51 | * chunk. The chunk provided should be discarded on success and it's | |
52 | * published version used in its place. | |
53 | * | |
54 | * See the documentation of lttng_trace_chunk for more information on | |
55 | * the usage of the various parameters. | |
56 | * | |
57 | * Returns an lttng_trace_chunk on success, NULL on error. | |
58 | */ | |
59 | LTTNG_HIDDEN | |
60 | struct lttng_trace_chunk *lttng_trace_chunk_registry_publish_chunk( | |
61 | struct lttng_trace_chunk_registry *registry, | |
62 | uint64_t session_id, struct lttng_trace_chunk *chunk); | |
63 | ||
64 | /* | |
65 | * Look-up a trace chunk by session_id and chunk_id. | |
66 | * A reference is acquired on behalf of the caller. | |
67 | * | |
68 | * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist. | |
69 | */ | |
70 | LTTNG_HIDDEN | |
71 | struct lttng_trace_chunk * | |
72 | lttng_trace_chunk_registry_find_chunk( | |
73 | const struct lttng_trace_chunk_registry *registry, | |
74 | uint64_t session_id, uint64_t chunk_id); | |
75 | ||
6b584c2e JG |
76 | /* |
77 | * Query the existence of a trace chunk by session_id and chunk_id. | |
78 | * | |
79 | * Returns 0 on success, a negative value on error. | |
80 | */ | |
81 | LTTNG_HIDDEN | |
82 | int lttng_trace_chunk_registry_chunk_exists( | |
83 | const struct lttng_trace_chunk_registry *registry, | |
84 | uint64_t session_id, uint64_t chunk_id, bool *chunk_exists); | |
85 | ||
2c5ff4e4 JG |
86 | /* |
87 | * Look-up an anonymous trace chunk by session_id. | |
88 | * A reference is acquired on behalf of the caller. | |
89 | * | |
90 | * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist. | |
91 | */ | |
92 | LTTNG_HIDDEN | |
93 | struct lttng_trace_chunk * | |
94 | lttng_trace_chunk_registry_find_anonymous_chunk( | |
95 | const struct lttng_trace_chunk_registry *registry, | |
96 | uint64_t session_id); | |
97 | ||
e10aec8f MD |
98 | LTTNG_HIDDEN |
99 | unsigned int lttng_trace_chunk_registry_put_each_chunk( | |
8ced4811 | 100 | const struct lttng_trace_chunk_registry *registry); |
e10aec8f | 101 | |
2c5ff4e4 | 102 | #endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */ |