Fix: ust-consumer: metadata thread not woken-up after version change
[lttng-tools.git] / src / common / consumer / consumer-metadata-cache.h
1 /*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19 #ifndef CONSUMER_METADATA_CACHE_H
20 #define CONSUMER_METADATA_CACHE_H
21
22 #include <common/consumer/consumer.h>
23
24 enum consumer_metadata_cache_write_status {
25 CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR = -1,
26 /*
27 * New metadata content was appended to the cache successfully.
28 * Previously available content remains valid.
29 */
30 CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT = 0,
31 /*
32 * The new content pushed to the cache invalidated the content that
33 * was already present. The contents of the cache should be re-read.
34 */
35 CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED,
36 /*
37 * A metadata cache write can simply overwrite an already existing
38 * section of the cache (and it should be a write-through with identical
39 * data). From the caller's standpoint, there is no change to the state
40 * of the cache.
41 */
42 CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE,
43 };
44
45 struct consumer_metadata_cache {
46 char *data;
47 uint64_t cache_alloc_size;
48 /*
49 * Current version of the metadata cache.
50 */
51 uint64_t version;
52 /*
53 * The upper-limit of data written inside the buffer.
54 *
55 * With the total_bytes_written it allows us to keep track of when the
56 * cache contains contiguous metadata ready to be sent to the RB.
57 * All cached data is contiguous.
58 */
59 uint64_t max_offset;
60 /*
61 * Lock to update the metadata cache and push into the ring_buffer
62 * (ustctl_write_metadata_to_channel).
63 *
64 * This is nested INSIDE the consumer_data lock.
65 */
66 pthread_mutex_t lock;
67 };
68
69 enum consumer_metadata_cache_write_status
70 consumer_metadata_cache_write(struct lttng_consumer_channel *channel,
71 unsigned int offset, unsigned int len, uint64_t version,
72 char *data);
73 int consumer_metadata_cache_allocate(struct lttng_consumer_channel *channel);
74 void consumer_metadata_cache_destroy(struct lttng_consumer_channel *channel);
75 int consumer_metadata_cache_flushed(struct lttng_consumer_channel *channel,
76 uint64_t offset, int timer);
77
78 #endif /* CONSUMER_METADATA_CACHE_H */
This page took 0.030876 seconds and 4 git commands to generate.