dst->ss_dur = le64_to_cpu(src->ss_dur);
dst->ss_state = le32_to_cpu(src->ss_state);
dst->ss_head = le32_to_cpu(src->ss_head);
- dst->ss_sum_y = le64_to_cpu(src->ss_sum_y);
dst->ss_limit.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_limit.u.i));
dst->ss_slope.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_slope.u.i));
dst->ss_deviation.u.f = fio_uint64_to_double(le64_to_cpu(src->ss_deviation.u.i));
p.ts.ss_dur = cpu_to_le64(ts->ss_dur);
p.ts.ss_state = cpu_to_le32(ts->ss_state);
p.ts.ss_head = cpu_to_le32(ts->ss_head);
- p.ts.ss_sum_y = cpu_to_le64(ts->ss_sum_y);
p.ts.ss_limit.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_limit.u.f));
p.ts.ss_slope.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_slope.u.f));
p.ts.ss_deviation.u.i = cpu_to_le64(fio_double_to_uint64(ts->ss_deviation.u.f));
** otherwise it actually points to the second element
** in the list
*/
- if ((ts->ss_state & __FIO_SS_ATTAINED) || ts->ss_sum_y == 0)
+ if ((ts->ss_state & __FIO_SS_ATTAINED) || !(ts->ss_state & __FIO_SS_BUFFER_FULL))
j = ts->ss_head;
else
j = ts->ss_head == 0 ? ts->ss_dur - 1 : ts->ss_head - 1;
ts->ss_state = td->ss.state;
ts->ss_dur = td->ss.dur;
ts->ss_head = td->ss.head;
- ts->ss_sum_y = td->ss.sum_y;
ts->ss_bw_data = td->ss.bw_data;
ts->ss_iops_data = td->ss.iops_data;
ts->ss_limit.u.f = td->ss.limit;
else
new_val = bw;
- if (ss->tail < ss->head || (ss->tail - ss->head == ss->dur - 1)) {
- if (ss->sum_y == 0) { /* first time through */
- for(i = 0; i < ss->dur; i++) {
+ if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
+ if (!(ss->state & __FIO_SS_BUFFER_FULL)) {
+ /* first time through */
+ for(i = 0, ss->sum_y = 0; i < ss->dur; i++) {
if (ss->state & __FIO_SS_IOPS)
ss->sum_y += ss->iops_data[i];
else
ss->sum_y += ss->bw_data[i];
- j = ss->head + i;
- if (j >= ss->dur)
- j -= ss->dur;
+ j = (ss->head + i) % ss->dur;
if (ss->state & __FIO_SS_IOPS)
ss->sum_xy += i * ss->iops_data[j];
else
ss->sum_xy += i * ss->bw_data[j];
}
+ ss->state |= __FIO_SS_BUFFER_FULL;
} else { /* easy to update the sums */
ss->sum_y -= ss->oldest_y;
ss->sum_y += new_val;
ss->bw_data[ss->tail] = bw;
ss->iops_data[ss->tail] = iops;
- if (ss->tail < ss->head || (ss->tail - ss->head == ss->dur - 1)) {
- if (ss->sum_y == 0) { /* first time through */
- for(i = 0; i < ss->dur; i++)
+ if (ss->state & __FIO_SS_BUFFER_FULL || ss->tail - ss->head == ss->dur - 1) {
+ if (!(ss->state & __FIO_SS_BUFFER_FULL)) {
+ /* first time through */
+ for(i = 0, ss->sum_y = 0; i < ss->dur; i++)
if (ss->state & __FIO_SS_IOPS)
ss->sum_y += ss->iops_data[i];
else
ss->sum_y += ss->bw_data[i];
+ ss->state |= __FIO_SS_BUFFER_FULL;
} else { /* easy to update the sum */
ss->sum_y -= ss->oldest_y;
if (ss->state & __FIO_SS_IOPS)