iowatcher: Fix some rounding errors around the max offset
authorChris Mason <chris.mason@fusionio.com>
Fri, 26 Oct 2012 19:23:40 +0000 (15:23 -0400)
committerChris Mason <clm@fb.com>
Wed, 24 Sep 2014 19:02:07 +0000 (12:02 -0700)
set_gdd_bit makes sure that we don't try to set bits past the max offset
we used to allocate our gdd array.

But, it only does this when the function is first called, and the whole
byte range for the IO we're recording may go past max offset.  This adds
a check to be sure we stay in the right range.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
iowatcher/main.c
iowatcher/plot.c

index 23fb7070b218182bb4edaac5f0d00c8dcfc61a83..6e392f279ad82adc9f5a522ffb5af5b2a95b719f 100644 (file)
@@ -297,8 +297,8 @@ static void read_traces(void)
 
                last_time = find_last_time(trace);
                tf->trace = trace;
-               tf->max_seconds = SECONDS(last_time);
-               tf->stop_seconds = SECONDS(last_time);
+               tf->max_seconds = SECONDS(last_time) + 1;
+               tf->stop_seconds = SECONDS(last_time) + 1;
                find_extreme_offsets(trace, &tf->min_offset, &tf->max_offset,
                                    &max_bank, &max_bank_offset);
                filter_outliers(trace, tf->min_offset, tf->max_offset, &ymin, &ymax);
index 79e5d3cefc07fad3574af852a835270b036b8e0b..1e9b7d7345612e999142e4e2e62a4dbae7f0867d 100644 (file)
@@ -148,7 +148,7 @@ struct graph_dot_data *alloc_dot_data(int min_seconds, int max_seconds, u64 min_
        arr_size = (rows + 1) * cols;
 
        /* the number of bytes */
-       arr_size /= 8;
+       arr_size = (arr_size + 7) / 8;
 
        gdd = calloc(1, size + arr_size);
        if (!gdd) {
@@ -191,10 +191,9 @@ void set_gdd_bit(struct graph_dot_data *gdd, u64 offset, double bytes, double ti
 
        if (offset > gdd->max_offset || offset < gdd->min_offset)
                return;
-
        gdd->total_ios++;
        time = time / 1000000000.0;
-       while (bytes > 0) {
+       while (bytes > 0 && offset <= gdd->max_offset) {
                row = (double)(offset - gdd->min_offset) / bytes_per_row;
                col = (time - gdd->min_seconds) / secs_per_col;