2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
5 * SPDX-License-Identifier: GPL-2.0-only
9 #ifndef CONSUMER_METADATA_CACHE_H
10 #define CONSUMER_METADATA_CACHE_H
12 #include <common/consumer/consumer.h>
14 enum consumer_metadata_cache_write_status
{
15 CONSUMER_METADATA_CACHE_WRITE_STATUS_ERROR
= -1,
17 * New metadata content was appended to the cache successfully.
18 * Previously available content remains valid.
20 CONSUMER_METADATA_CACHE_WRITE_STATUS_APPENDED_CONTENT
= 0,
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.
25 CONSUMER_METADATA_CACHE_WRITE_STATUS_INVALIDATED
,
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
32 CONSUMER_METADATA_CACHE_WRITE_STATUS_NO_CHANGE
,
35 struct consumer_metadata_cache
{
37 uint64_t cache_alloc_size
;
39 * Current version of the metadata cache.
43 * The upper-limit of data written inside the buffer.
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.
47 * All cached data is contiguous.
51 * Lock to update the metadata cache and push into the ring_buffer
52 * (ustctl_write_metadata_to_channel).
54 * This is nested INSIDE the consumer_data lock.
59 enum consumer_metadata_cache_write_status
60 consumer_metadata_cache_write(struct consumer_metadata_cache
*cache
,
61 unsigned int offset
, unsigned int len
, uint64_t version
,
63 int consumer_metadata_cache_allocate(struct lttng_consumer_channel
*channel
);
64 void consumer_metadata_cache_destroy(struct lttng_consumer_channel
*channel
);
65 int consumer_metadata_cache_flushed(struct lttng_consumer_channel
*channel
,
66 uint64_t offset
, int timer
);
68 #endif /* CONSUMER_METADATA_CACHE_H */