From: Mathieu Desnoyers Date: Mon, 9 Dec 2019 15:09:05 +0000 (-0500) Subject: relayd: tracefile array: Allow head position to skip ahead X-Git-Url: http://git.efficios.com/?p=lttng-tools.git;a=commitdiff_plain;h=62f6e9ef54e271dceb5c9d0ef0f3d38b113f80c6 relayd: tracefile array: Allow head position to skip ahead The clear feature needs to move the head position ahead (jump) over sequence numbers. Signed-off-by: Mathieu Desnoyers Change-Id: I08482bd13dd748621968c43de7647f9d19670880 Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 427d30a00..d34158bd2 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -1160,7 +1160,7 @@ int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num, ret = relay_index_try_flush(index); if (ret == 0) { tracefile_array_file_rotate(stream->tfa, TRACEFILE_ROTATE_READ); - tracefile_array_commit_seq(stream->tfa); + tracefile_array_commit_seq(stream->tfa, stream->index_received_seqcount); stream->index_received_seqcount++; LTTNG_OPTIONAL_SET(&stream->received_packet_seq_num, be64toh(index->index_data.packet_seq_num)); @@ -1256,7 +1256,7 @@ int stream_add_index(struct relay_stream *stream, ret = relay_index_try_flush(index); if (ret == 0) { tracefile_array_file_rotate(stream->tfa, TRACEFILE_ROTATE_READ); - tracefile_array_commit_seq(stream->tfa); + tracefile_array_commit_seq(stream->tfa, stream->index_received_seqcount); stream->index_received_seqcount++; stream->pos_after_last_complete_data_index += index->total_size; stream->prev_index_seq = index_info->net_seq_num; diff --git a/src/bin/lttng-relayd/tracefile-array.c b/src/bin/lttng-relayd/tracefile-array.c index a52ccd550..c7a86966f 100644 --- a/src/bin/lttng-relayd/tracefile-array.c +++ b/src/bin/lttng-relayd/tracefile-array.c @@ -120,15 +120,16 @@ void tracefile_array_file_rotate(struct tracefile_array *tfa, } } -void tracefile_array_commit_seq(struct tracefile_array *tfa) +void tracefile_array_commit_seq(struct tracefile_array *tfa, + uint64_t new_seq_head) { uint64_t *headp, *tailp; /* Increment overall head. */ - tfa->seq_head++; - /* If we are committing our first index overall, set tail to 0. */ + tfa->seq_head = new_seq_head; + /* If we are committing our first index overall, set tail to head. */ if (tfa->seq_tail == -1ULL) { - tfa->seq_tail = 0; + tfa->seq_tail = new_seq_head; } if (!tfa->count) { /* Not in tracefile rotation mode. */ diff --git a/src/bin/lttng-relayd/tracefile-array.h b/src/bin/lttng-relayd/tracefile-array.h index 53b32d9f5..dc556733b 100644 --- a/src/bin/lttng-relayd/tracefile-array.h +++ b/src/bin/lttng-relayd/tracefile-array.h @@ -64,7 +64,8 @@ struct tracefile_array *tracefile_array_create(size_t count); void tracefile_array_destroy(struct tracefile_array *tfa); void tracefile_array_file_rotate(struct tracefile_array *tfa, enum tracefile_rotate_type type); -void tracefile_array_commit_seq(struct tracefile_array *tfa); +void tracefile_array_commit_seq(struct tracefile_array *tfa, + uint64_t new_seq_head); void tracefile_array_reset(struct tracefile_array *tfa); uint64_t tracefile_array_get_read_file_index_head(struct tracefile_array *tfa);