2 * Copyright (C) 2019 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_TRACE_CHUNK_REGISTRY_H
9 #define LTTNG_TRACE_CHUNK_REGISTRY_H
14 #include <common/macros.h>
15 #include <common/trace-chunk.h>
17 struct lttng_trace_chunk_registry
;
20 * Create an lttng_trace_chunk registry.
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.
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.
30 * Returns a trace chunk registry on success, NULL on error.
32 * Note that a trace chunk registry may only be accessed by an RCU thread.
35 struct lttng_trace_chunk_registry
*lttng_trace_chunk_registry_create(void);
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
43 void lttng_trace_chunk_registry_destroy(
44 struct lttng_trace_chunk_registry
*registry
);
47 * Publish a trace chunk for a given session id.
48 * A reference is acquired on behalf of the caller.
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.
54 * See the documentation of lttng_trace_chunk for more information on
55 * the usage of the various parameters.
57 * Returns an lttng_trace_chunk on success, NULL on error.
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
);
65 * Look-up a trace chunk by session_id and chunk_id.
66 * A reference is acquired on behalf of the caller.
68 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
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
);
77 * Query the existence of a trace chunk by session_id and chunk_id.
79 * Returns 0 on success, a negative value on error.
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
);
87 * Look-up an anonymous trace chunk by session_id.
88 * A reference is acquired on behalf of the caller.
90 * Returns an lttng_trace_chunk on success, NULL if the chunk does not exist.
93 struct lttng_trace_chunk
*
94 lttng_trace_chunk_registry_find_anonymous_chunk(
95 const struct lttng_trace_chunk_registry
*registry
,
99 unsigned int lttng_trace_chunk_registry_put_each_chunk(
100 const struct lttng_trace_chunk_registry
*registry
);
102 #endif /* LTTNG_TRACE_CHUNK_REGISTRY_H */