X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fplugins%2Fctf%2Ffs-src%2Fdata-stream-file.c;h=924a2be788c5fe9b450862d82118005537ecdd2b;hb=c8ebf034d0bcdfe9a716d1697b02b307e4ee4514;hp=2c28c51d48b5a50c70e141ff03563063a89df255;hpb=f102bfaac631f63ee859c3a6e58706451f942cc2;p=babeltrace.git diff --git a/src/plugins/ctf/fs-src/data-stream-file.c b/src/plugins/ctf/fs-src/data-stream-file.c index 2c28c51d..924a2be7 100644 --- a/src/plugins/ctf/fs-src/data-stream-file.c +++ b/src/plugins/ctf/fs-src/data-stream-file.c @@ -25,7 +25,7 @@ #define BT_COMP_LOG_SELF_COMP (ds_file->self_comp) #define BT_LOG_OUTPUT_LEVEL (ds_file->log_level) #define BT_LOG_TAG "PLUGIN/SRC.CTF.FS/DS" -#include "plugins/comp-logging.h" +#include "logging/comp-logging.h" #include #include @@ -216,8 +216,8 @@ enum bt_msg_iter_medium_status medop_seek(enum bt_msg_iter_seek_whence whence, if (whence != BT_MSG_ITER_SEEK_WHENCE_SET || offset < 0 || offset > file_size) { BT_COMP_LOGE("Invalid medium seek request: whence=%d, offset=%jd, " - "file-size=%jd", (int) whence, offset, - file_size); + "file-size=%jd", (int) whence, (intmax_t) offset, + (intmax_t) file_size); ret = BT_MSG_ITER_MEDIUM_STATUS_INVAL; goto end; } @@ -236,7 +236,7 @@ enum bt_msg_iter_medium_status medop_seek(enum bt_msg_iter_seek_whence whence, int unmap_ret; BT_COMP_LOGD("Medium seek request cannot be accomodated by the current " "file mapping: offset=%jd, mmap-offset=%jd, " - "mmap-len=%zu", offset, ds_file->mmap_offset, + "mmap-len=%zu", (intmax_t) offset, (intmax_t) ds_file->mmap_offset, ds_file->mmap_len); unmap_ret = ds_file_munmap(ds_file); if (unmap_ret) { @@ -251,7 +251,7 @@ enum bt_msg_iter_medium_status medop_seek(enum bt_msg_iter_seek_whence whence, map_requested_offset: offset_in_mapping = offset % - bt_common_get_page_size(ds_file->log_level); + bt_mmap_get_offset_align_size(ds_file->log_level); ds_file->mmap_offset = offset - offset_in_mapping; ds_file->request_offset = offset_in_mapping; @@ -284,7 +284,8 @@ int convert_cycles_to_ns(struct ctf_clock_class *clock_class, static struct ctf_fs_ds_index *build_index_from_idx_file( - struct ctf_fs_ds_file *ds_file) + struct ctf_fs_ds_file *ds_file, + struct ctf_fs_ds_file_info *file_info) { int ret; gchar *directory = NULL; @@ -403,6 +404,9 @@ struct ctf_fs_ds_index *build_index_from_idx_file( goto error; } + /* Set path to stream file. */ + index_entry->path = file_info->path->str; + /* Convert size in bits to bytes. */ packet_size /= CHAR_BIT; index_entry->packet_size = packet_size; @@ -411,7 +415,7 @@ struct ctf_fs_ds_index *build_index_from_idx_file( if (i != 0 && index_entry->offset < prev_index_entry->offset) { BT_COMP_LOGW("Invalid, non-monotonic, packet offset encountered in LTTng trace index file: " "previous offset=%" PRIu64 ", current offset=%" PRIu64, - (index_entry - 1)->offset, index_entry->offset); + prev_index_entry->offset, index_entry->offset); goto error; } @@ -491,6 +495,8 @@ int init_index_entry(struct ctf_fs_ds_index_entry *entry, entry->packet_size = packet_size; if (props->snapshots.beginning_clock != UINT64_C(-1)) { + entry->timestamp_begin = props->snapshots.beginning_clock; + /* Convert the packet's bound to nanoseconds since Epoch. */ ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.beginning_clock, @@ -500,10 +506,14 @@ int init_index_entry(struct ctf_fs_ds_index_entry *entry, goto end; } } else { + entry->timestamp_begin = UINT64_C(-1); entry->timestamp_begin_ns = UINT64_C(-1); } if (props->snapshots.end_clock != UINT64_C(-1)) { + entry->timestamp_end = props->snapshots.end_clock; + + /* Convert the packet's bound to nanoseconds since Epoch. */ ret = convert_cycles_to_ns(sc->default_clock_class, props->snapshots.end_clock, &entry->timestamp_end_ns); @@ -512,6 +522,7 @@ int init_index_entry(struct ctf_fs_ds_index_entry *entry, goto end; } } else { + entry->timestamp_end = UINT64_C(-1); entry->timestamp_end_ns = UINT64_C(-1); } @@ -521,7 +532,8 @@ end: static struct ctf_fs_ds_index *build_index_from_stream_file( - struct ctf_fs_ds_file *ds_file) + struct ctf_fs_ds_file *ds_file, + struct ctf_fs_ds_file_info *file_info) { int ret; struct ctf_fs_ds_index *index = NULL; @@ -576,9 +588,9 @@ struct ctf_fs_ds_index *build_index_from_stream_file( "packet-offset=%jd, packet-size-bytes=%jd, " "file-size=%jd", ds_file->file->path->str, - current_packet_offset_bytes, - current_packet_size_bytes, - ds_file->file->size); + (intmax_t) current_packet_offset_bytes, + (intmax_t) current_packet_size_bytes, + (intmax_t) ds_file->file->size); goto error; } @@ -588,6 +600,9 @@ struct ctf_fs_ds_index *build_index_from_stream_file( goto error; } + /* Set path to stream file. */ + index_entry->path = file_info->path->str; + ret = init_index_entry(index_entry, ds_file, &props, current_packet_size_bytes, current_packet_offset_bytes); if (ret) { @@ -600,8 +615,8 @@ struct ctf_fs_ds_index *build_index_from_stream_file( current_packet_offset_bytes += current_packet_size_bytes; BT_COMP_LOGD("Seeking to next packet: current-packet-offset=%jd, " "next-packet-offset=%jd", - current_packet_offset_bytes - current_packet_size_bytes, - current_packet_offset_bytes); + (intmax_t) (current_packet_offset_bytes - current_packet_size_bytes), + (intmax_t) current_packet_offset_bytes); } while (iter_status == BT_MSG_ITER_STATUS_OK); @@ -627,7 +642,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( bt_logging_level log_level) { int ret; - const size_t page_size = bt_common_get_page_size(log_level); + const size_t offset_align = bt_mmap_get_offset_align_size(log_level); struct ctf_fs_ds_file *ds_file = g_new0(struct ctf_fs_ds_file, 1); if (!ds_file) { @@ -657,7 +672,7 @@ struct ctf_fs_ds_file *ctf_fs_ds_file_create( goto error; } - ds_file->mmap_max_len = page_size * 2048; + ds_file->mmap_max_len = offset_align * 2048; goto end; @@ -672,18 +687,19 @@ end: BT_HIDDEN struct ctf_fs_ds_index *ctf_fs_ds_file_build_index( - struct ctf_fs_ds_file *ds_file) + struct ctf_fs_ds_file *ds_file, + struct ctf_fs_ds_file_info *file_info) { struct ctf_fs_ds_index *index; - index = build_index_from_idx_file(ds_file); + index = build_index_from_idx_file(ds_file, file_info); if (index) { goto end; } BT_COMP_LOGI("Failed to build index from .index file; " "falling back to stream indexing."); - index = build_index_from_stream_file(ds_file); + index = build_index_from_stream_file(ds_file, file_info); end: return index; }