4f8bb763fefdd1a893c01f5bd70f1fa9148866df
[lttng-tools.git] / src / common / consumer / consumer-metadata-cache.h
1 /*
2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 */
8
9 #ifndef CONSUMER_METADATA_CACHE_H
10 #define CONSUMER_METADATA_CACHE_H
11
12 #include <common/consumer/consumer.h>
13 #include <common/dynamic-buffer.h>
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 enum consumer_metadata_cache_write_status {
20 CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
21 /*
22 * New metadata content was appended to the cache successfully.
23 * Previously available content remains valid.
24 */
25 CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
26 /*
27 * The new content pushed to the cache invalidated the content that
28 * was already present. The contents of the cache should be re-read.
29 */
30 CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
31 /*
32 * A metadata cache write can simply overwrite an already existing
33 * section of the cache (and it should be a write-through with identical
34 * data). From the caller's standpoint, there is no change to the state
35 * of the cache.
36 */
37 CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
38 };
39
40 struct consumer_metadata_cache {
41 /* Current version of the metadata cache. */
42 uint64_t version;
43 /*
44 * Size is the upper-limit of data written inside the buffer.
45 * All cached data is contiguous.
46 */
47 struct lttng_dynamic_buffer contents;
48 /*
49 * Lock to update the metadata cache and push into the ring_buffer
50 * (lttng_ust_ctl_write_metadata_to_channel).
51 *
52 * This is nested INSIDE the consumer_data lock.
53 */
54 pthread_mutex_t lock;
55 };
56
57 enum consumer_metadata_cache_write_status
58 consumer_metadata_cache_write(struct consumer_metadata_cache *cache,
59 unsigned int offset, unsigned int len, uint64_t version,
60 const char *data);
61 int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
62 void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
63 int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
64 uint64_t offset, int timer);
65
66 #ifdef __cplusplus
67 }
68 #endif
69
70 #endif /* CONSUMER_METADATA_CACHE_H */
This page took 0.029794 seconds and 3 git commands to generate.