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