Home | History | Annotate | Download | only in btreplay

Lines Matching full:stream

222  * @stream: Output file information
225 static void write_file_hdr(struct io_stream *stream, struct io_file_hdr *hdr)
231 stream->file_name,
238 fseek(stream->ofp, 0, SEEK_SET);
239 if (fwrite(hdr, sizeof(*hdr), 1, stream->ofp) != 1) {
240 fatal(stream->file_name, ERR_SYSCALL, "Hdr write failed\n");
247 * @io_stream: IO stream being added to
251 static inline void io_bunch_create(struct io_stream *stream, __u64 start_time)
258 cur->hdr.time_stamp = stream->start_time = start_time;
260 stream->cur = cur;
265 * @stream: Per-output file stream information
270 static void io_bunch_add(struct io_stream *stream, struct io_spec *spec)
272 struct io_bunch *cur = stream->cur;
281 assert(stream->last_time == 0 || stream->last_time <= spec->time);
284 stream->last_time = spec->time;
480 * next_io - Retrieve next Q trace from input stream
571 static inline void bunch_output_hdr(struct io_stream *stream)
573 struct io_bunch_hdr *hdrp = &stream->cur->hdr;
576 if (fwrite(hdrp, sizeof(struct io_bunch_hdr), 1, stream->ofp) != 1) {
577 fatal(stream->file_name, ERR_SYSCALL, "fwrite(hdr) failed\n");
582 __u64 off = hdrp->time_stamp - stream->iip->genesis;
584 assert(stream->vfp);
585 fprintf(stream->vfp, "------------------\n");
586 fprintf(stream->vfp, "%4llu.%09llu %3llu\n",
590 fprintf(stream->vfp, "------------------\n");
597 static inline void bunch_output_pkts(struct io_stream *stream)
599 struct io_pkt *p = stream->cur->pkts;
600 size_t npkts = stream->cur->hdr.npkts;
603 if (fwrite(p, sizeof(struct io_pkt), npkts, stream->ofp) != npkts) {
604 fatal(stream->file_name, ERR_SYSCALL, "fwrite(pkts) failed\n");
611 assert(stream->vfp);
613 fprintf(stream->vfp, "\t%1d %10llu\t%10llu\n",
621 * stream_flush - Flush current bunch of IOs out to the output stream
622 * @stream: Per-output file stream information
624 static void stream_flush(struct io_stream *stream)
626 struct io_bunch *cur = stream->cur;
631 bunch_output_hdr(stream);
632 bunch_output_pkts(stream);
634 stream->bunches++;
635 stream->pkts += cur->hdr.npkts;
643 * @stream: Output stream information
646 static inline int bunch_done(struct io_stream *stream, struct io_spec *spec)
648 if (stream->cur->hdr.npkts >= max_pkts_per_bunch)
651 if ((spec->time - stream->start_time) > max_bunch_tm)
658 * stream_add_io - Add an IO trace to the current stream
659 * @stream: Output stream information
662 static void stream_add_io(struct io_stream *stream, struct io_spec *spec)
665 if (stream->cur == NULL)
666 io_bunch_create(stream, spec->time);
667 else if (bunch_done(stream, spec)) {
668 stream_flush(stream);
669 io_bunch_create(stream, spec->time);
672 io_bunch_add(stream, spec);
676 * stream_open - Open output stream for specified input stream
682 struct io_stream *stream = malloc(sizeof(*stream));
689 memset(stream, 0, sizeof(*stream));
692 stream->ofp = fopen(ofile_name, "w");
693 if (!stream->ofp) {
698 stream->iip = iip;
699 stream->cur = NULL;
700 stream->bunches = stream->pkts = 0;
701 stream->last_time = 0;
702 stream->file_name = strdup(ofile_name);
704 write_file_hdr(stream, &io_file_hdr);
711 stream->vfp = fopen(vfile_name, "w");
712 if (!stream->vfp) {
717 stream->vfn = strdup(vfile_name);
721 return stream;
725 * stream_close - Release resources associated with an output stream
726 * @stream: Stream to release
728 static void stream_close(struct io_stream *stream)
731 .genesis = stream->iip->genesis,
732 .nbunches = stream->bunches,
733 .total_pkts = stream->pkts
736 stream_flush(stream);
737 write_file_hdr(stream, &io_file_hdr);
738 fclose(stream->ofp);
740 if (verbose && stream->bunches) {
744 stream->iip->devnm, stream->iip->cpu,
745 (unsigned long long)stream->iip->tpkts,
746 (unsigned long long)stream->pkts,
747 (unsigned long long)stream->bunches,
748 (double)(stream->pkts) / (double)(stream->bunches));
750 fclose(stream->vfp);
751 free(stream->vfn);
754 free(stream->file_name);
755 free(stream);
765 struct io_stream *stream;
767 stream = stream_open(iip);
769 stream_add_io(stream, &spec);
770 stream_close(stream);