[PATCH] blkparse: we have to allow one skip to prevent sequence screwups
authorJens Axboe <axboe@suse.de>
Wed, 5 Oct 2005 07:54:55 +0000 (09:54 +0200)
committerJens Axboe <axboe@suse.de>
Wed, 5 Oct 2005 07:54:55 +0000 (09:54 +0200)
If one CPU file is completed in the first run, check_sequence()
would allow it to skip too early causing unordered events.

blkparse.c

index 7e3f0fad2ef75cb369c748c71cbca2174d404cfb..ff3742cdc9206a4f00ed499963d7f6daa11e4b69 100644 (file)
@@ -185,6 +185,7 @@ struct trace {
        struct blk_io_trace *bit;
        struct rb_node rb_node;
        struct trace *next;
+       int skipped;
 };
 
 static struct rb_root rb_sort_root;
@@ -1337,10 +1338,11 @@ static void put_trace(struct per_dev_info *pdi, struct trace *t)
        }
 }
 
-static int check_sequence(struct per_dev_info *pdi, struct blk_io_trace *bit)
+static int check_sequence(struct per_dev_info *pdi, struct trace *t)
 {
        unsigned long expected_sequence = pdi->last_sequence + 1;
-       struct trace *t;
+       struct blk_io_trace *bit = t->bit;
+       struct trace *__t;
        
        /*
         * first entry, always ok
@@ -1356,14 +1358,19 @@ static int check_sequence(struct per_dev_info *pdi, struct blk_io_trace *bit)
         * the final run, break and wait for more entries.
         */
        if (expected_sequence < smallest_seq_read) {
-               t = trace_rb_find_last(pdi, expected_sequence);
-               if (!t)
+               __t = trace_rb_find_last(pdi, expected_sequence);
+               if (!__t)
                        goto skip;
 
-               __put_trace_last(pdi, t);
+               __put_trace_last(pdi, __t);
                return 0;
        } else {
 skip:
+               if (!t->skipped)
+                       return 1;
+
+               t->skipped = 1;
+
                if (print_missing) {
                        fprintf(stderr, "(%d,%d): skipping %lu -> %u\n",
                                MAJOR(pdi->dev), MINOR(pdi->dev),
@@ -1399,7 +1406,7 @@ static void show_entries_rb(int force)
                }
 
                if (!force) {
-                       if (check_sequence(pdi, bit))
+                       if (check_sequence(pdi, t))
                                break;
 
                        if (bit->time > last_allowed_time)