trace-cmd record: Fix compression when files are greater than 2GB
PATCH 1/1 trace-cmd record: Fix compression when files are greater than 2GB
From: "Steven Rostedt (Google)" <[email protected]>
Several file size references in the compression code is defined as "int", but that can only be used for sizes less than 2GB. Convert them to size_t and ssize_t. Also convert some long long and unsigned long long to use ssize_t and size_t respectively for consistency.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=219264
Reported-by Arnaud Lefebvre <[email protected]>
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- .../include/private/trace-cmd-private.h | 18 ++--- lib/trace-cmd/include/trace-cmd-local.h | 2 +- lib/trace-cmd/trace-compress.c | 66 +++++++++---------- lib/trace-cmd/trace-input.c | 9 ++- lib/trace-cmd/trace-output.c | 8 +-- tracecmd/trace-record.c | 2 +- 6 files changed, 52 insertions(+), 53 deletions(-)
lib/trace-cmd/include/private/trace-cmd-private.h +9 -9
@@ -179,8 +179,8 @@ struct tracecmd_ftrace { };struct tracecmd_proc_addr_map { -unsigned long long start; -unsigned long long end; +size_t start; +size_t end;char *lib_name; };
@@ -252,7 +252,7 @@ tracecmd_set_all_cpus_to_timestamp(struct tracecmd_input *handle, unsigned long long time);int tracecmd_set_cursor (struct tracecmd_input *handle, -int cpu,unsigned long long offset); +int cpu,size_t offset);unsigned long long tracecmd_get_cursor (struct tracecmd_input *handle,int cpu);
@@ -339,7 +339,7 @@ int tracecmd_append_buffer_cpu_data(struct tracecmd_output *handle, const char *name, int cpus, char * const *cpu_data_files);struct tracecmd_output *tracecmd_get_output_handle_fd (int fd);unsigned long tracecmd_get_out_file_version (struct tracecmd_output *handle); -unsigned long long tracecmd_get_out_file_offset (struct tracecmd_output *handle); +size_t tracecmd_get_out_file_offset (struct tracecmd_output *handle);/* --- Reading the Fly Recorder Trace --- */
@@ -550,10 +550,10 @@ void tracecmd_compress_destroy(struct tracecmd_compression *handle);int tracecmd_compress_block (struct tracecmd_compression *handle);int tracecmd_uncompress_block (struct tracecmd_compression *handle);void tracecmd_compress_reset (struct tracecmd_compression *handle); -int tracecmd_compress_buffer_read (struct tracecmd_compression *handle,char *dst,int len); -int tracecmd_compress_pread (struct tracecmd_compression *handle,char *dst,int len,off_t offset); +ssize_t tracecmd_compress_buffer_read (struct tracecmd_compression *handle,char *dst,size_t len); +ssize_t tracecmd_compress_pread (struct tracecmd_compression *handle,char *dst,size_t len,off_t offset);int tracecmd_compress_buffer_write (struct tracecmd_compression *handle, -const void *data,unsigned long long size); +const void *data,size_t size);off_t tracecmd_compress_lseek (struct tracecmd_compression *handle,off_t offset,int whence);int tracecmd_compress_proto_get_name (struct tracecmd_compression *compress,const char **name,const char **version);
@@ -561,9 +561,9 @@ bool tracecmd_compress_is_supported(const char *name, const char *version);int tracecmd_compress_protos_get (char ***names,char ***versions);int tracecmd_compress_proto_register (struct tracecmd_compression_proto *proto);int tracecmd_compress_copy_from (struct tracecmd_compression *handle,int fd,int chunk_size, -unsigned long long *read_size,unsigned long long *write_size); +size_t *read_size,size_t *write_size);int tracecmd_uncompress_copy_to (struct tracecmd_compression *handle,int fd, -unsigned long long *read_size,unsigned long long *write_size); +size_t *read_size,size_t *write_size);int tracecmd_uncompress_chunk (struct tracecmd_compression *handle,struct tracecmd_compress_chunk *chunk,char *data); int tracecmd_load_chunks_info(struct tracecmd_compression *handle,
lib/trace-cmd/include/trace-cmd-local.h +1 -1
@@ -93,7 +93,7 @@ out_add_buffer_option(struct tracecmd_output *handle, const char *name,struct cpu_data_source {int fd; -int size; +ssize_t size;off_t offset; };
lib/trace-cmd/trace-compress.c +33 -33
146 lines not on this page · raw message
lib/trace-cmd/trace-input.c +4 -5
@@ -2342,8 +2342,7 @@ tracecmd_set_all_cpus_to_timestamp(struct tracecmd_input *handle,* Now the next tracecmd_peek_data or tracecmd_read_data will return * the original record. */ -int tracecmd_set_cursor (struct tracecmd_input *handle, -int cpu,unsigned long long offset) +int tracecmd_set_cursor (struct tracecmd_input *handle,int cpu,size_t offset) {struct cpu_data *cpu_data = &handle->cpu_data[cpu];unsigned long long page_offset;
@@ -3304,8 +3303,8 @@ tracecmd_read_prev(struct tracecmd_input *handle, struct tep_record *record)static int init_cpu_zfile (struct tracecmd_input *handle,int cpu) {struct cpu_data *cpu_data; -unsigned long long size;off_t offset; +size_t size; cpu_data = &handle->cpu_data[cpu]; offset =lseek (handle->fd,0 ,SEEK_CUR );
@@ -3740,7 +3739,7 @@ static int trace_pid_map_load(struct tracecmd_input *handle, char *buf) *line ='\0' ;if (strlen (buf) >STR_PROCMAP_LINE_MAX )break ; - res =sscanf (buf,"%llx %llx %s" , &maps->lib_maps[i].start, + res =sscanf (buf,"%zx %zx %s" , &maps->lib_maps[i].start, &maps->lib_maps[i].end, mapname);if (res !=3 )break ;
@@ -4353,7 +4352,7 @@ static int init_cpu_data(struct tracecmd_input *handle)int init_latency_data (struct tracecmd_input *handle) { -unsigned long long wsize; +size_t wsize;int ret;if (!handle->cpu_compressed)
lib/trace-cmd/trace-output.c +4 -4
@@ -391,9 +391,9 @@ __hidden unsigned long long out_copy_fd_compress(struct tracecmd_output *handle,unsigned long long *write_size, int page) { -unsigned long long rsize =0 ; -unsigned long long wsize =0 ; -unsigned long long size; + size_t rsize = 0; +size_t wsize =0 ; +size_t size;int ret;if (handle->compress) {
@@ -3019,7 +3019,7 @@ unsigned long tracecmd_get_out_file_version(struct tracecmd_output *handle)return handle->file_version; } -unsigned long long tracecmd_get_out_file_offset (struct tracecmd_output *handle) +size_t tracecmd_get_out_file_offset (struct tracecmd_output *handle) {return do_lseek (handle,0 ,SEEK_CUR ); }
tracecmd/trace-record.c +1 -1
@@ -4407,7 +4407,7 @@ add_pid_maps(struct tracecmd_output *handle, struct buffer_instance *instance)trace_seq_printf (&s,"%x %x %s\n" , maps->pid, maps->nr_lib_maps, maps->proc_name);for (i =0 ; i < maps->nr_lib_maps; i++) -trace_seq_printf (&s,"%llx %llx %s\n" , +trace_seq_printf (&s,"%zx %zx %s\n" , maps->lib_maps[i].start, maps->lib_maps[i].end, maps->lib_maps[i].lib_name);
Signature · 1 line
2.45.2