5 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
6 * David Goulet <dgoulet@efficios.com>
7 * 2015 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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.
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
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.
27 #include <common/hashtable/hashtable.h>
29 #include "index-file.h"
30 #include "stream-fd.h"
36 * index lock nests inside stream lock.
38 pthread_mutex_t reflock
; /* Protects refcounting. */
39 struct urcu_ref ref
; /* Reference from getters. */
40 struct relay_stream
*stream
; /* Back ref to stream */
44 * index file on which to write the index data. May differ from
45 * stream->index_file due to tracefile rotation.
47 struct relay_index_file
*index_file
;
49 /* Index packet data. This is the data that is written on disk. */
50 struct ctf_packet_index index_data
;
57 * Node within indexes_ht that corresponds to this struct
58 * relay_index. Indexed by net_seq_num, which is unique for this
59 * index across the stream.
61 struct lttng_ht_node_u64 index_n
;
62 struct rcu_head rcu_node
; /* For call_rcu teardown. */
65 struct relay_index
*relay_index_get_by_id_or_create(struct relay_stream
*stream
,
66 uint64_t net_seq_num
);
67 void relay_index_put(struct relay_index
*index
);
68 int relay_index_set_file(struct relay_index
*index
,
69 struct relay_index_file
*index_file
,
70 uint64_t data_offset
);
71 int relay_index_set_data(struct relay_index
*index
,
72 const struct ctf_packet_index
*data
);
73 int relay_index_try_flush(struct relay_index
*index
);
75 void relay_index_close_all(struct relay_stream
*stream
);
76 void relay_index_close_partial_fd(struct relay_stream
*stream
);
77 uint64_t relay_index_find_last(struct relay_stream
*stream
);
79 #endif /* _RELAY_INDEX_H */