relayd: implement file and session rotation on top of trace chunks
[lttng-tools.git] / src / bin / lttng-relayd / index.h
CommitLineData
7591bab1
MD
1#ifndef _RELAY_INDEX_H
2#define _RELAY_INDEX_H
3
1c20f0e2
JD
4/*
5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7591bab1 7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
1c20f0e2
JD
8 *
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License, version 2 only, as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along with
19 * this program; if not, write to the Free Software Foundation, Inc., 51
20 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
1c20f0e2
JD
23#include <inttypes.h>
24#include <pthread.h>
25
26#include <common/hashtable/hashtable.h>
27#include <common/index/index.h>
28
7591bab1
MD
29#include "stream-fd.h"
30
31struct relay_stream;
c35f9726
JG
32struct relay_connection;
33struct lttcomm_relayd_index;
7591bab1 34
1c20f0e2 35struct relay_index {
1c20f0e2 36 /*
7591bab1 37 * index lock nests inside stream lock.
1c20f0e2 38 */
7591bab1
MD
39 struct urcu_ref ref; /* Reference from getters. */
40 struct relay_stream *stream; /* Back ref to stream */
41
42 pthread_mutex_t lock;
43 /*
f8f3885c
MD
44 * index file on which to write the index data. May differ from
45 * stream->index_file due to tracefile rotation.
7591bab1 46 */
f8f3885c 47 struct lttng_index_file *index_file;
1c20f0e2
JD
48
49 /* Index packet data. This is the data that is written on disk. */
50adc264 50 struct ctf_packet_index index_data;
d3ecc550
JD
51 /* Data + padding size of this packet, filled by the data thread. */
52 uint64_t total_size;
1c20f0e2 53
7591bab1
MD
54 bool has_index_data;
55 bool flushed;
56 bool in_hash_table;
57
58 /*
59 * Node within indexes_ht that corresponds to this struct
60 * relay_index. Indexed by net_seq_num, which is unique for this
61 * index across the stream.
62 */
63 struct lttng_ht_node_u64 index_n;
64 struct rcu_head rcu_node; /* For call_rcu teardown. */
1c20f0e2
JD
65};
66
7591bab1 67struct relay_index *relay_index_get_by_id_or_create(struct relay_stream *stream,
1c20f0e2 68 uint64_t net_seq_num);
7591bab1 69void relay_index_put(struct relay_index *index);
f8f3885c
MD
70int relay_index_set_file(struct relay_index *index,
71 struct lttng_index_file *index_file,
72 uint64_t data_offset);
7591bab1
MD
73int relay_index_set_data(struct relay_index *index,
74 const struct ctf_packet_index *data);
75int relay_index_try_flush(struct relay_index *index);
76
77void relay_index_close_all(struct relay_stream *stream);
3d07a857
MD
78void relay_index_close_partial_fd(struct relay_stream *stream);
79uint64_t relay_index_find_last(struct relay_stream *stream);
d3ecc550 80int relay_index_switch_all_files(struct relay_stream *stream);
c35f9726
JG
81int relay_index_set_control_data(struct relay_index *index,
82 const struct lttcomm_relayd_index *data,
83 unsigned int minor_version);
1c20f0e2
JD
84
85#endif /* _RELAY_INDEX_H */
This page took 0.041473 seconds and 4 git commands to generate.