Commit | Line | Data |
---|---|---|
331744e3 JD |
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 | ||
c8fea79c | 22 | #include <common/consumer/consumer.h> |
331744e3 | 23 | |
c124970b JG |
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 | ||
331744e3 JD |
45 | struct consumer_metadata_cache { |
46 | char *data; | |
47 | uint64_t cache_alloc_size; | |
93ec662e JD |
48 | /* |
49 | * Current version of the metadata cache. | |
50 | */ | |
51 | uint64_t version; | |
331744e3 JD |
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. | |
c585821b | 57 | * All cached data is contiguous. |
331744e3 JD |
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). | |
73811ecc DG |
63 | * |
64 | * This is nested INSIDE the consumer_data lock. | |
331744e3 JD |
65 | */ |
66 | pthread_mutex_t lock; | |
67 | }; | |
68 | ||
c124970b JG |
69 | enum consumer_metadata_cache_write_status |
70 | consumer_metadata_cache_write(struct lttng_consumer_channel *channel, | |
93ec662e JD |
71 | unsigned int offset, unsigned int len, uint64_t version, |
72 | char *data); | |
331744e3 JD |
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, | |
5e41ebe1 | 76 | uint64_t offset, int timer); |
331744e3 JD |
77 | |
78 | #endif /* CONSUMER_METADATA_CACHE_H */ |