Rename LTTng index in CTF index
A message that is not in the archive (sent off-list or not yet received): [email protected]
Merged!
David
Quoted 503 lines · Julien Desfossez
Also the magic becomes a
uint32_tinstead of 6 chars for more aligned reads.Signed-off-by Julien Desfossez <[email protected]>--- src/bin/lttng-relayd/index.h | 2 +- src/bin/lttng-relayd/live.c | 12 +++--- src/bin/lttng-relayd/lttng-relayd.h | 2 +- src/common/consumer-stream.c | 6 +-- src/common/consumer-stream.h | 2 +- src/common/consumer-timer.c | 2 +- src/common/consumer.c | 4 +- src/common/consumer.h | 6 +-- src/common/index/Makefile.am | 2 +- src/common/index/ctf-index.h | 60 ++++++++++++++++++++++++++++ src/common/index/index.c | 11 ++--- src/common/index/index.h | 4 +- src/common/index/lttng-index.h | 58 --------------------------- src/common/kernel-consumer/kernel-consumer.c | 4 +- src/common/relayd/relayd.c | 4 +- src/common/relayd/relayd.h | 2 +- src/common/sessiond-comm/relayd.h | 2 +- src/common/ust-consumer/ust-consumer.c | 4 +- tests/regression/tools/live/live_test.c | 2 +- 19 files changed, 96 insertions(+), 93 deletions(-) create mode 100644 src/common/index/ctf-index.h delete mode 100644 src/common/index/lttng-index.hsrc/bin/lttng-relayd/index.h +1
-1@@ -36,7 +36,7 @@ struct relay_index {int to_close_fd;/* Index packet data. This is the data that is written on disk. */ -struct lttng_packet_index index_data; +struct ctf_packet_index index_data;/* key1 = stream_id, key2 = net_seq_num */ struct lttng_ht_two_u64 key;src/bin/lttng-relayd/live.c +6
-6@@ -614,7 +614,7 @@ static int open_index(struct relay_viewer_stream *stream) {int ret;char fullpath[PATH_MAX ]; -struct lttng_packet_index_file_hdr hdr; +struct ctf_packet_index_file_hdr hdr;if (stream->tracefile_count >0 ) { ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR "/%s_%"@@ -649,13 +649,13 @@ static int open_index(struct relay_viewer_stream *stream)PERROR ("Reading index header" ); goto error; } -if (strncmp (hdr.magic,INDEX_MAGIC ,sizeof (hdr.magic)) !=0 ) { +if (be32toh (hdr.magic) !=CTF_INDEX_MAGIC ) {ERR ("Invalid header magic" ); ret =-1 ; goto error; } -if (be32toh (hdr.index_major) !=INDEX_MAJOR || -be32toh (hdr.index_minor) !=INDEX_MINOR ) { +if (be32toh (hdr.index_major) !=CTF_INDEX_MAJOR || +be32toh (hdr.index_minor) !=CTF_INDEX_MINOR ) {ERR ("Invalid header version" ); ret =-1 ; goto error;@@ -747,7 +747,7 @@ int init_viewer_stream(struct relay_stream *stream, int seek_last)if (seek_last && viewer_stream->index_read_fd >0 ) { ret =lseek (viewer_stream->index_read_fd, viewer_stream->total_index_received * -sizeof (struct lttng_packet_index ), +sizeof (struct ctf_packet_index ),SEEK_CUR );if (ret <0 ) { goto error;@@ -1075,7 +1075,7 @@ int viewer_get_next_index(struct relay_command *cmd,int ret;struct lttng_viewer_get_next_index request_index;struct lttng_viewer_index viewer_index; -struct lttng_packet_index packet_index; +struct ctf_packet_index packet_index;struct relay_viewer_stream *vstream;struct relay_stream *rstream;src/bin/lttng-relayd/lttng-relayd.h +1
-1@@ -25,7 +25,7 @@#include <urcu/wfqueue.h> #include <common/hashtable/hashtable.h> -#include <common/index/lttng-index.h> +#include <common/index/ctf-index.h> #include "ctf-trace.h" src/common/consumer-stream.c +3
-3@@ -331,7 +331,7 @@ void consumer_stream_destroy(struct lttng_consumer_stream *stream,* Return 0 on success or else a negative value. */ int consumer_stream_write_index (struct lttng_consumer_stream *stream, -struct lttng_packet_index *index) +struct ctf_packet_index *index) {int ret;struct consumer_relayd_sock_pair *relayd;@@ -348,8 +348,8 @@ int consumer_stream_write_index(struct lttng_consumer_stream *stream,ssize_t size_ret; size_ret =index_write (stream->index_fd, index, -sizeof (struct lttng_packet_index )); -if (size_ret <sizeof (struct lttng_packet_index )) { +sizeof (struct ctf_packet_index )); +if (size_ret <sizeof (struct ctf_packet_index )) { ret =-1 ; }else { ret =0 ;src/common/consumer-stream.h +1
-1@@ -72,7 +72,7 @@ void consumer_stream_destroy_buffers(struct lttng_consumer_stream *stream);* Write index of a specific stream either on the relayd or local disk. */ int consumer_stream_write_index (struct lttng_consumer_stream *stream, -struct lttng_packet_index *index); +struct ctf_packet_index *index);int consumer_stream_sync_metadata (struct lttng_consumer_local_data *ctx,uint64_t session_id);src/common/consumer-timer.c +1
-1@@ -115,7 +115,7 @@ static void metadata_switch_timer(struct lttng_consumer_local_data *ctx,static int send_empty_index (struct lttng_consumer_stream *stream,uint64_t ts) {int ret; -struct lttng_packet_index index; +struct ctf_packet_index index;memset (&index,0 ,sizeof (index)); index.timestamp_end =htobe64 (ts);src/common/consumer.c +2
-2@@ -1341,7 +1341,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap(struct lttng_consumer_local_data *ctx, struct lttng_consumer_stream *stream, unsigned long len, unsigned long padding, - struct lttng_packet_index *index) + struct ctf_packet_index *index) { unsigned long mmap_offset;void *mmap_base;@@ -1549,7 +1549,7 @@ ssize_t lttng_consumer_on_read_subbuffer_splice(struct lttng_consumer_local_data *ctx, struct lttng_consumer_stream *stream, unsigned long len, unsigned long padding, - struct lttng_packet_index *index) + struct ctf_packet_index *index) { ssize_t ret = 0, written = 0, ret_splice = 0;loff_t offset =0 ;src/common/consumer.h +3
-3@@ -32,7 +32,7 @@#include <common/compat/uuid.h> #include <common/sessiond-comm/sessiond-comm.h> #include <common/pipe.h> -#include <common/index/lttng-index.h> +#include <common/index/ctf-index.h> /* Commands for consumer */ enum lttng_consumer_command {@@ -611,12 +611,12 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap(struct lttng_consumer_local_data *ctx, struct lttng_consumer_stream *stream, unsigned long len, unsigned long padding, - struct lttng_packet_index *index); + struct ctf_packet_index *index);ssize_t lttng_consumer_on_read_subbuffer_splice (struct lttng_consumer_local_data *ctx,struct lttng_consumer_stream *stream,unsigned long len,unsigned long padding, -struct lttng_packet_index *index); +struct ctf_packet_index *index);int lttng_consumer_take_snapshot (struct lttng_consumer_stream *stream);int lttng_consumer_get_produced_snapshot (struct lttng_consumer_stream *stream,unsigned long *pos);src/common/index/Makefile.am +1
-1@@ -2,4 +2,4 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src noinst_LTLIBRARIES = libindex.la -libindex_la_SOURCES = index.c index.h lttng-index.h +libindex_la_SOURCES = index.c index.h ctf-index.hsrc/common/index/ctf-index.h new file +60
-0@@ -0,0 +1,60 @@ +/* +* Copyright (C) 2013 - Julien Desfossez <[email protected]> +* Mathieu Desnoyers <[email protected]> +* David Goulet <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a copy +* of this software and associated documentation files (the "Software"), to deal +* in the Software without restriction, including without limitation the rights +* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +* copies of the Software, and to permit persons to whom the Software is +* furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in +* all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +* SOFTWARE. +*/ + +#ifndef LTTNG_INDEX_H +#define LTTNG_INDEX_H + +#include <limits.h> + +#define CTF_INDEX_MAGIC 0xC1F1DCC1 +#define CTF_INDEX_MAJOR 1 +#define CTF_INDEX_MINOR 0 + +/* +* Header at the beginning of each index file. +* All integer fields are stored in big endian. +*/ +struct ctf_packet_index_file_hdr { +uint32_t magic; +uint32_t index_major; +uint32_t index_minor; +/* struct packet_index_len, in bytes */ +uint32_t packet_index_len; +} __attribute__((__packed__ )); + +/* +* Packet index generated for each trace packet store in a trace file. +* All integer fields are stored in big endian. +*/ +struct ctf_packet_index { +uint64_t offset;/* offset of the packet in the file, in bytes */ +uint64_t packet_size;/* packet size, in bits */ +uint64_t content_size;/* content size, in bits */ +uint64_t timestamp_begin; +uint64_t timestamp_end; +uint64_t events_discarded; +uint64_t stream_id; +} __attribute__((__packed__ )); + +#endif /* LTTNG_INDEX_H */ src/common/index/index.c +6
-5@@ -36,7 +36,7 @@ int index_create_file(char *path_name, char *stream_name, int uid, int gid, {int ret, fd =-1 ;ssize_t size_ret; -struct lttng_packet_index_file_hdr hdr; +struct ctf_packet_index_file_hdr hdr;char fullpath[PATH_MAX ]; ret = snprintf(fullpath, sizeof(fullpath), "%s/" DEFAULT_INDEX_DIR,@@ -62,9 +62,10 @@ int index_create_file(char *path_name, char *stream_name, int uid, int gid, } fd = ret; -memcpy (hdr.magic,INDEX_MAGIC ,sizeof (hdr.magic)); - hdr.index_major =htobe32 (INDEX_MAJOR ); - hdr.index_minor =htobe32 (INDEX_MINOR ); + hdr.magic =htobe32 (CTF_INDEX_MAGIC ); + hdr.index_major =htobe32 (CTF_INDEX_MAJOR ); + hdr.index_minor =htobe32 (CTF_INDEX_MINOR ); + hdr.packet_index_len =sizeof (struct ctf_packet_index ); size_ret =lttng_write (fd, &hdr,sizeof (hdr));if (size_ret <sizeof (hdr)) {@@ -93,7 +94,7 @@ error:* Return "len" on success or else < len on error. errno contains error * details. */ -ssize_t index_write (int fd,struct lttng_packet_index *index,size_t len) +ssize_t index_write (int fd,struct ctf_packet_index *index,size_t len) {ssize_t ret;src/common/index/index.h +2
-2@@ -21,10 +21,10 @@#include <inttypes.h> -#include "lttng-index.h" +#include "ctf-index.h" int index_create_file (char *path_name,char *stream_name,int uid,int gid,uint64_t size,uint64_t count); -ssize_t index_write (int fd,struct lttng_packet_index *index,size_t len); +ssize_t index_write (int fd,struct ctf_packet_index *index,size_t len);#endif /* _INDEX_H */ src/common/index/lttng-index.h deleted +0
-58@@ -1,58 +0,0 @@ -/* -* Copyright (C) 2013 - Julien Desfossez <[email protected]> -* Mathieu Desnoyers <[email protected]> -* David Goulet <[email protected]> -* -* Permission is hereby granted, free of charge, to any person obtaining a copy -* of this software and associated documentation files (the "Software"), to deal -* in the Software without restriction, including without limitation the rights -* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -* copies of the Software, and to permit persons to whom the Software is -* furnished to do so, subject to the following conditions: -* -* The above copyright notice and this permission notice shall be included in -* all copies or substantial portions of the Software. -* -* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -* SOFTWARE. -*/ - -#ifndef LTTNG_INDEX_H -#define LTTNG_INDEX_H - -#include <limits.h> - -#define INDEX_MAGIC "CTFIDX" -#define INDEX_MAJOR 1 -#define INDEX_MINOR 0 - -/* -* Header at the beginning of each index file. -* All integer fields are stored in big endian. -*/ -struct lttng_packet_index_file_hdr { -char magic[6 ]; -uint32_t index_major; -uint32_t index_minor; -} __attribute__((__packed__ )); - -/* -* Packet index generated for each trace packet store in a trace file. -* All integer fields are stored in big endian. -*/ -struct lttng_packet_index { -uint64_t offset;/* offset of the packet in the file, in bytes */ -uint64_t packet_size;/* packet size, in bits */ -uint64_t content_size;/* content size, in bits */ -uint64_t timestamp_begin; -uint64_t timestamp_end; -uint64_t events_discarded; -uint64_t stream_id; -} __attribute__((__packed__ )); - -#endif /* LTTNG_INDEX_H */ src/common/kernel-consumer/kernel-consumer.c +2
-2@@ -911,7 +911,7 @@ error_fatal:* * Return 0 on success or else a negative value. */ -static int get_index_values (struct lttng_packet_index *index,int infd) +static int get_index_values (struct ctf_packet_index *index,int infd) {int ret;@@ -1007,7 +1007,7 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,int err, write_index =1 ;ssize_t ret =0 ;int infd = stream->wait_fd; -struct lttng_packet_index index; +struct ctf_packet_index index;DBG ("In read_subbuffer (infd : %d)" , infd);src/common/relayd/relayd.c +2
-2@@ -26,7 +26,7 @@#include <common/common.h> #include <common/defaults.h> #include <common/sessiond-comm/relayd.h> -#include <common/index/lttng-index.h> +#include <common/index/ctf-index.h> #include "relayd.h" @@ -734,7 +734,7 @@ error:* Send index to the relayd. */ int relayd_send_index (struct lttcomm_relayd_sock *rsock, -struct lttng_packet_index *index,uint64_t relay_stream_id, +struct ctf_packet_index *index,uint64_t relay_stream_id,uint64_t net_seq_num) {int ret;src/common/relayd/relayd.h +1
-1@@ -46,7 +46,7 @@ int relayd_begin_data_pending(struct lttcomm_relayd_sock *sock, uint64_t id);int relayd_end_data_pending (struct lttcomm_relayd_sock *sock,uint64_t id,unsigned int *is_data_inflight);int relayd_send_index (struct lttcomm_relayd_sock *rsock, -struct lttng_packet_index *index,uint64_t relay_stream_id, +struct ctf_packet_index *index,uint64_t relay_stream_id,uint64_t net_seq_num);#endif /* _RELAYD_H */ src/common/sessiond-comm/relayd.h +1
-1@@ -26,7 +26,7 @@#include <lttng/lttng.h> #include <common/defaults.h> -#include <common/index/lttng-index.h> +#include <common/index/ctf-index.h> #include <config.h> #define RELAYD_VERSION_COMM_MAJOR VERSION_MAJORsrc/common/ust-consumer/ust-consumer.c +2
-2@@ -1704,7 +1704,7 @@ void lttng_ustconsumer_del_stream(struct lttng_consumer_stream *stream)* * Return 0 on success or else a negative value. */ -static int get_index_values (struct lttng_packet_index *index, +static int get_index_values (struct ctf_packet_index *index,struct ustctl_consumer_stream *ustream) {int ret;@@ -1869,7 +1869,7 @@ int lttng_ustconsumer_read_subbuffer(struct lttng_consumer_stream *stream,long ret =0 ;char dummy;struct ustctl_consumer_stream *ustream; -struct lttng_packet_index index; +struct ctf_packet_index index;assert (stream);assert (stream->ustream);tests/regression/tools/live/live_test.c +1
-1@@ -41,7 +41,7 @@#include <common/common.h> #include <bin/lttng-relayd/lttng-viewer.h> -#include <common/index/lttng-index.h> +#include <common/index/ctf-index.h> #define SESSION1 "test1"#define RELAYD_URL "net://localhost"Signature · 1 line
1.8.3.2
_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev