2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
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.
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
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.
19 #ifndef CONSUMER_METADATA_CACHE_H
20 #define CONSUMER_METADATA_CACHE_H
22 #include <common/consumer/consumer.h>
24 enum consumer_metadata_cache_write_status
{
25 CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR
= -1,
27 * New metadata content was appended to the cache successfully.
28 * Previously available content remains valid.
30 CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT
= 0,
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.
35 CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED
,
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
42 CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE
,
45 struct consumer_metadata_cache
{
47 uint64_t cache_alloc_size
;
49 * Current version of the metadata cache.
53 * The upper-limit of data written inside the buffer.
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.
61 * Lock to update the metadata cache and push into the ring_buffer
62 * (ustctl_write_metadata_to_channel).
64 * This is nested INSIDE the consumer_data lock.
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
,
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
);
78 #endif /* CONSUMER_METADATA_CACHE_H */