[PATCH] blktrace: allow for unaligned events
authorJens Axboe <axboe@suse.de>
Mon, 3 Oct 2005 12:06:07 +0000 (14:06 +0200)
committerJens Axboe <axboe@suse.de>
Mon, 3 Oct 2005 12:06:07 +0000 (14:06 +0200)
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

index 559cb7f248ba5a5979743a2eb2ecf6d1c503d8a6..852c9252d53ac2e406f90d24365b5bd648f604a6 100644 (file)
@@ -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))