From 4b5db44a063baeace0690456f8f7a46681659fcf Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 3 Oct 2005 14:06:07 +0200 Subject: [PATCH] [PATCH] blktrace: allow for unaligned events Unfortunately it looks like we have to support this for now, as it appears relayfs will still miss events on buffer wraps for the read cases. --- blktrace.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/blktrace.c b/blktrace.c index 559cb7f..852c925 100644 --- a/blktrace.c +++ b/blktrace.c @@ -292,6 +292,22 @@ static void *extract_data(struct thread_information *tip, int nb) return NULL; } +static int get_event(struct thread_information *tip, struct blk_io_trace *bit) +{ + void *p = &bit->sequence; + + do { + if (read_data(tip, bit, sizeof(bit->magic))) + return -1; + + } while (!CHECK_MAGIC(bit)); + + if (!read_data(tip, p, sizeof(*bit) - sizeof(bit->magic))) + return 0; + + return -1; +} + static inline void tip_fd_unlock(struct thread_information *tip) { if (tip->fd_lock) @@ -333,7 +349,7 @@ static void *extract(void *arg) pdu_data = NULL; while (!is_done()) { - if (read_data(tip, &t, sizeof(t))) + if (get_event(tip, &t)) break; if (verify_trace(&t)) -- 2.25.1