aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mason <chris.mason@fusionio.com>2012-10-26 15:23:40 -0400
committerChris Mason <chris.mason@fusionio.com>2012-10-26 15:23:40 -0400
commit619d3c2d6f974ab7b12c539436bd586856135a5b (patch)
tree0c9371cde106e63861a742184895aa132da447cf
parentd8bd7d8c853d6d6470692c22ee767e400a4414f4 (diff)
downloadiowatcher-619d3c2d6f974ab7b12c539436bd586856135a5b.tar.gz
Fix some rounding errors around the max offset
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>
-rw-r--r--main.c4
-rw-r--r--plot.c5
2 files changed, 4 insertions, 5 deletions
diff --git a/main.c b/main.c
index 23fb707..6e392f2 100644
--- a/main.c
+++ b/main.c
@@ -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);
diff --git a/plot.c b/plot.c
index 79e5d3c..1e9b7d7 100644
--- a/plot.c
+++ b/plot.c
@@ -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;