unsigned int ratecycle;
unsigned long rate_usec_cycle;
long rate_pending_usleep;
- unsigned long rate_kb;
+ unsigned long rate_sectors;
struct timeval lastrate;
unsigned long runtime; /* sec */
- unsigned long kb;
+ unsigned long sectors;
+
unsigned long io_blocks;
- unsigned long io_kb;
- unsigned long this_io_kb;
- unsigned long last_kb;
+ unsigned long io_sectors;
+ unsigned long this_io_sectors;
+ unsigned long last_sectors;
sem_t mutex;
struct drand48_data random_state;
struct io_stat slat_stat; /* submission latency */
struct io_stat bw_stat; /* bandwidth stats */
- unsigned long stat_io_kb;
+ unsigned long stat_io_sectors;
struct timeval stat_sample_time;
struct io_log *lat_log;
if (!td->sequential) {
int min_bs_kb = td->min_bs >> 10;
+ unsigned long max_kb = td->sectors << 1;
lrand48_r(&td->random_state, &r);
- kb = (1+(double) (td->kb-1) * r / (RAND_MAX+1.0));
+ kb = (1+(double) (max_kb-1) * r / (RAND_MAX+1.0));
kb = (kb + min_bs_kb - 1) & ~(min_bs_kb - 1);
} else
- kb = td->last_kb;
+ kb = td->last_sectors << 1;
return (kb << 10) + td->file_offset;
}
buflen = (buflen + td->min_bs - 1) & ~(td->min_bs - 1);
}
- if (buflen > ((td->kb - td->this_io_kb) << 10))
- buflen = (td->kb - td->this_io_kb) << 10;
+ if (buflen > ((td->sectors - td->this_io_sectors) << 9))
+ buflen = (td->sectors - td->this_io_sectors) << 9;
- td->last_kb += buflen >> 10;
+ td->last_sectors += buflen >> 9;
return buflen;
}
if (spent < td->bw_avg_time)
return;
- rate = ((td->this_io_kb - td->stat_io_kb) * 1024) / spent;
+ rate = ((td->this_io_sectors - td->stat_io_sectors) << 9) / spent;
add_stat_sample(td, &td->bw_stat, rate);
if (td->bw_log)
add_log_sample(td, td->bw_log, rate);
gettimeofday(&td->stat_sample_time, NULL);
- td->stat_io_kb = td->this_io_kb;
+ td->stat_io_sectors = td->this_io_sectors;
}
static void usec_sleep(int usec)
/*
* if rate blocks is set, sample is running
*/
- if (td->rate_kb) {
+ if (td->rate_sectors) {
spent = mtime_since(&td->lastrate, now);
if (spent < td->ratecycle)
return 0;
- rate = ((td->this_io_kb - td->rate_kb) * 1024) / spent;
+ rate = ((td->this_io_sectors - td->rate_sectors) << 9) / spent;
if (rate < td->ratemin) {
printf("Client%d: min rate %d not met, got %ldKiB/sec\n", td->thread_number, td->ratemin, rate);
if (rate_quit)
}
}
- td->rate_kb = td->this_io_kb;
+ td->rate_sectors = td->this_io_sectors;
memcpy(&td->lastrate, now, sizeof(*now));
return 0;
}
io_u = __get_io_u(td);
if (!td->odirect) {
- unsigned long size = td->kb << 10;
+ unsigned long size = td->sectors << 9;
if (fadvise(td->fd, 0, size, POSIX_FADV_DONTNEED) < 0) {
td->error = errno;
struct io_u *io_u = NULL;
struct timeval e;
- while (td->this_io_kb < td->kb) {
+ while (td->this_io_sectors < td->sectors) {
int ret;
if (td->terminate)
log_io_piece(td, io_u);
td->io_blocks++;
- td->io_kb += io_u->buflen >> 10;
- td->this_io_kb += io_u->buflen >> 10;
+ td->io_sectors += io_u->buflen >> 9;
+ td->this_io_sectors += io_u->buflen >> 9;
td->cur_off = io_u->offset + io_u->buflen;
gettimeofday(&e, NULL);
io_u = ev_to_iou(td->aio_events + i);
td->io_blocks++;
- td->io_kb += io_u->buflen >> 10;
- td->this_io_kb += io_u->buflen >> 10;
+ td->io_sectors += io_u->buflen >> 9;
+ td->this_io_sectors += io_u->buflen >> 9;
msec = mtime_since(&io_u->issue_time, &e);
struct timeval s, e;
unsigned long usec;
- while (td->this_io_kb < td->kb) {
+ while (td->this_io_sectors < td->sectors) {
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0};
struct timespec *timeout;
int ret, min_evts = 0;
return 1;
}
- td->kb = td->file_size >> 10;
+ td->sectors = td->file_size >> 9;
b = malloc(td->max_bs);
memset(b, 0, td->max_bs);
st.st_size = td->file_size;
}
- td->kb = (st.st_size - td->file_offset) / 1024;
- if (!td->kb) {
+ td->sectors = (st.st_size - td->file_offset) / 1024;
+ if (!td->sectors) {
fprintf(stderr, "Client%d: no io blocks\n", td->thread_number);
td->error = EINVAL;
return 1;
static void clear_io_state(struct thread_data *td)
{
td->cur_off = 0;
- td->last_kb = 0;
- td->stat_io_kb = 0;
- td->this_io_kb = 0;
+ td->last_sectors = 0;
+ td->stat_io_sectors = 0;
+ td->this_io_sectors = 0;
}
static void *thread_main(int shm_id, int offset, char *argv[])
unsigned long min, max, bw = 0;
double mean, dev;
- if (!td->io_kb && !td->error)
+ if (!td->io_sectors && !td->error)
return;
if (td->runtime)
- bw = td->io_kb * 1024 / td->runtime;
+ bw = (td->io_sectors << 9) / td->runtime;
prio = td->ioprio & 0xff;
prio_class = td->ioprio >> IOPRIO_CLASS_SHIFT;
- printf("Client%d: err=%2d, io=%6luMiB, bw=%6luKiB/s, runt=%6lumsec\n", td->thread_number, td->error, td->io_kb >> 10, bw, td->runtime);
+ printf("Client%d: err=%2d, io=%6luMiB, bw=%6luKiB/s, runt=%6lumsec\n", td->thread_number, td->error, td->io_sectors << 9, bw, td->runtime);
if (calc_lat(&td->slat_stat, &min, &max, &mean, &dev))
printf(" slat (msec): min=%5lu, max=%5lu, avg=%5.02f, dev=%5.02f\n", min, max, mean, dev);
max_run[td->ddir] = td->runtime;
if (td->runtime)
- bw = td->io_kb * 1024 / td->runtime;
+ bw = (td->io_sectors << 9) / td->runtime;
if (bw < min_bw[td->ddir])
min_bw[td->ddir] = bw;
if (bw > max_bw[td->ddir])
max_bw[td->ddir] = bw;
- io_mb[td->ddir] += td->io_kb >> 10;
+ io_mb[td->ddir] += td->io_sectors >> 9;
}
show_thread_status(td);