From: Julien Desfossez Date: Mon, 6 Jul 2015 17:22:51 +0000 (-0400) Subject: Store the instance id and packet_seq_num in indexes X-Git-Tag: v2.8.0-rc1~85 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=234cd6367843a2106a4cb10f8fb99443208516df;p=lttng-tools.git Store the instance id and packet_seq_num in indexes Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 7fc2fb503..e4ded2b86 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -1036,7 +1036,8 @@ error_testpoint: * Set index data from the control port to a given index object. */ static int set_index_control_data(struct relay_index *index, - struct lttcomm_relayd_index *data) + struct lttcomm_relayd_index *data, + struct relay_connection *conn) { struct ctf_packet_index index_data; @@ -1052,6 +1053,12 @@ static int set_index_control_data(struct relay_index *index, index_data.timestamp_end = data->timestamp_end; index_data.events_discarded = data->events_discarded; index_data.stream_id = data->stream_id; + + if (conn->minor >= 8) { + index->index_data.stream_instance_id = data->stream_instance_id; + index->index_data.packet_seq_num = data->packet_seq_num; + } + return relay_index_set_data(index, &index_data); } @@ -1925,7 +1932,7 @@ static int relay_recv_index(struct lttcomm_relayd_hdr *recv_hdr, ERR("relay_index_get_by_id_or_create index NULL"); goto end_stream_put; } - if (set_index_control_data(index, &index_info)) { + if (set_index_control_data(index, &index_info, conn)) { ERR("set_index_control_data error"); relay_index_put(index); ret = -1; diff --git a/src/common/index/ctf-index.h b/src/common/index/ctf-index.h index 1f38d9ab0..8755f1218 100644 --- a/src/common/index/ctf-index.h +++ b/src/common/index/ctf-index.h @@ -29,7 +29,7 @@ #define CTF_INDEX_MAGIC 0xC1F1DCC1 #define CTF_INDEX_MAJOR 1 -#define CTF_INDEX_MINOR 0 +#define CTF_INDEX_MINOR 1 /* * Header at the beginning of each index file. @@ -54,7 +54,10 @@ struct ctf_packet_index { uint64_t timestamp_begin; uint64_t timestamp_end; uint64_t events_discarded; - uint64_t stream_id; + uint64_t stream_id; /* ID of the channel */ + /* CTF_INDEX 1.0 limit */ + uint64_t stream_instance_id; /* ID of the channel instance */ + uint64_t packet_seq_num; /* packet sequence number */ } __attribute__((__packed__)); #endif /* LTTNG_INDEX_H */ diff --git a/src/common/kernel-consumer/kernel-consumer.c b/src/common/kernel-consumer/kernel-consumer.c index 42d471d1a..e5c0c2e83 100644 --- a/src/common/kernel-consumer/kernel-consumer.c +++ b/src/common/kernel-consumer/kernel-consumer.c @@ -1093,6 +1093,20 @@ static int get_index_values(struct ctf_packet_index *index, int infd) } index->stream_id = htobe64(index->stream_id); + ret = kernctl_get_instance_id(infd, &index->stream_instance_id); + if (ret < 0) { + PERROR("kernctl_get_instance_id"); + goto error; + } + index->stream_instance_id = htobe64(index->stream_instance_id); + + ret = kernctl_get_sequence_number(infd, &index->packet_seq_num); + if (ret < 0) { + PERROR("kernctl_get_sequence_number"); + goto error; + } + index->packet_seq_num = htobe64(index->packet_seq_num); + error: return ret; } diff --git a/src/common/relayd/relayd.c b/src/common/relayd/relayd.c index fade4b11e..60b7ee849 100644 --- a/src/common/relayd/relayd.c +++ b/src/common/relayd/relayd.c @@ -851,6 +851,11 @@ int relayd_send_index(struct lttcomm_relayd_sock *rsock, msg.events_discarded = index->events_discarded; msg.stream_id = index->stream_id; + if (rsock->minor >= 8) { + msg.stream_instance_id = index->stream_instance_id; + msg.packet_seq_num = index->packet_seq_num; + } + /* Send command */ ret = send_command(rsock, RELAYD_SEND_INDEX, &msg, sizeof(msg), 0); if (ret < 0) { diff --git a/src/common/sessiond-comm/relayd.h b/src/common/sessiond-comm/relayd.h index 4d751b86d..358123273 100644 --- a/src/common/sessiond-comm/relayd.h +++ b/src/common/sessiond-comm/relayd.h @@ -159,6 +159,8 @@ struct lttcomm_relayd_index { uint64_t timestamp_end; uint64_t events_discarded; uint64_t stream_id; + uint64_t stream_instance_id; + uint64_t packet_seq_num; } LTTNG_PACKED; /* diff --git a/src/common/ust-consumer/ust-consumer.c b/src/common/ust-consumer/ust-consumer.c index 5b4b14965..5686fbd09 100644 --- a/src/common/ust-consumer/ust-consumer.c +++ b/src/common/ust-consumer/ust-consumer.c @@ -2079,6 +2079,20 @@ static int get_index_values(struct ctf_packet_index *index, } index->stream_id = htobe64(index->stream_id); + ret = ustctl_get_instance_id(ustream, &index->stream_instance_id); + if (ret < 0) { + PERROR("ustctl_get_instance_id"); + goto error; + } + index->stream_instance_id = htobe64(index->stream_instance_id); + + ret = ustctl_get_sequence_number(ustream, &index->packet_seq_num); + if (ret < 0) { + PERROR("ustctl_get_sequence_number"); + goto error; + } + index->packet_seq_num = htobe64(index->packet_seq_num); + error: return ret; }