Cleanup: Use pkg-config to detect liburcu
[lttng-tools.git] / src / bin / lttng-relayd / index.h
CommitLineData
7591bab1
MD
1#ifndef _RELAY_INDEX_H
2#define _RELAY_INDEX_H
3
1c20f0e2 4/*
ab5be9fa
MJ
5 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
6 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
7 * Copyright (C) 2015 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
1c20f0e2 8 *
ab5be9fa 9 * SPDX-License-Identifier: GPL-2.0-only
1c20f0e2 10 *
1c20f0e2
JD
11 */
12
1c20f0e2
JD
13#include <inttypes.h>
14#include <pthread.h>
15
16#include <common/hashtable/hashtable.h>
17#include <common/index/index.h>
18
7591bab1 19struct relay_stream;
c35f9726
JG
20struct relay_connection;
21struct lttcomm_relayd_index;
7591bab1 22
1c20f0e2 23struct relay_index {
1c20f0e2 24 /*
7591bab1 25 * index lock nests inside stream lock.
1c20f0e2 26 */
7591bab1
MD
27 struct urcu_ref ref; /* Reference from getters. */
28 struct relay_stream *stream; /* Back ref to stream */
29
30 pthread_mutex_t lock;
31 /*
f8f3885c
MD
32 * index file on which to write the index data. May differ from
33 * stream->index_file due to tracefile rotation.
7591bab1 34 */
f8f3885c 35 struct lttng_index_file *index_file;
1c20f0e2
JD
36
37 /* Index packet data. This is the data that is written on disk. */
50adc264 38 struct ctf_packet_index index_data;
d3ecc550
JD
39 /* Data + padding size of this packet, filled by the data thread. */
40 uint64_t total_size;
1c20f0e2 41
7591bab1
MD
42 bool has_index_data;
43 bool flushed;
44 bool in_hash_table;
45
46 /*
47 * Node within indexes_ht that corresponds to this struct
48 * relay_index. Indexed by net_seq_num, which is unique for this
49 * index across the stream.
50 */
51 struct lttng_ht_node_u64 index_n;
52 struct rcu_head rcu_node; /* For call_rcu teardown. */
1c20f0e2
JD
53};
54
7591bab1 55struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
1c20f0e2 56 uint64_t net_seq_num);
7591bab1 57void relay_index_put(struct relay_index *index);
f8f3885c
MD
58int relay_index_set_file(struct relay_index *index,
59 struct lttng_index_file *index_file,
60 uint64_t data_offset);
7591bab1 61int relay_index_set_data(struct relay_index *index,
3a5328d2 62 const struct ctf_packet_index *data);
7591bab1
MD
63int relay_index_try_flush(struct relay_index *index);
64
65void relay_index_close_all(struct relay_stream *stream);
3d07a857
MD
66void relay_index_close_partial_fd(struct relay_stream *stream);
67uint64_t relay_index_find_last(struct relay_stream *stream);
d3ecc550 68int relay_index_switch_all_files(struct relay_stream *stream);
c35f9726
JG
69int relay_index_set_control_data(struct relay_index *index,
70 const struct lttcomm_relayd_index *data,
71 unsigned int minor_version);
1c20f0e2
JD
72
73#endif /* _RELAY_INDEX_H */
This page took 0.04638 seconds and 4 git commands to generate.