projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add ramp_time option
[fio.git]
/
io_u.c
diff --git
a/io_u.c
b/io_u.c
index 3f713671ea66f5017be80534f025af3f940d0531..17db16b1cb3ad13a29a7d4c8e905b564f3e88573 100644
(file)
--- a/
io_u.c
+++ b/
io_u.c
@@
-77,7
+77,6
@@
static void mark_random_map(struct thread_data *td, struct io_u *io_u)
else
mask = ((1U << this_blocks) - 1) << bit;
else
mask = ((1U << this_blocks) - 1) << bit;
- fio_assert(td, !(f->file_map[idx] & mask));
f->file_map[idx] |= mask;
nr_blocks -= this_blocks;
blocks += this_blocks;
f->file_map[idx] |= mask;
nr_blocks -= this_blocks;
blocks += this_blocks;
@@
-228,20
+227,30
@@
static int get_next_offset(struct thread_data *td, struct io_u *io_u)
return 0;
}
return 0;
}
+static inline int is_power_of_2(unsigned int val)
+{
+ return (val != 0 && ((val & (val - 1)) == 0));
+}
+
static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
{
const int ddir = io_u->ddir;
static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
{
const int ddir = io_u->ddir;
- unsigned int buflen = buflen; /* silence dumb gcc warning */
+ unsigned int uninitialized_var(buflen);
+ unsigned int minbs, maxbs;
long r;
long r;
- if (td->o.min_bs[ddir] == td->o.max_bs[ddir])
- buflen = td->o.min_bs[ddir];
+ minbs = td->o.min_bs[ddir];
+ maxbs = td->o.max_bs[ddir];
+
+ if (minbs == maxbs)
+ buflen = minbs;
else {
r = os_random_long(&td->bsrange_state);
if (!td->o.bssplit_nr) {
else {
r = os_random_long(&td->bsrange_state);
if (!td->o.bssplit_nr) {
- buflen = (unsigned int)
- (1 + (double) (td->o.max_bs[ddir] - 1)
- * r / (OS_RAND_MAX + 1.0));
+ buflen = 1 + (unsigned int) ((double) maxbs *
+ (r / (OS_RAND_MAX + 1.0)));
+ if (buflen < minbs)
+ buflen = minbs;
} else {
long perc = 0;
unsigned int i;
} else {
long perc = 0;
unsigned int i;
@@
-251,20
+260,18
@@
static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u)
buflen = bsp->bs;
perc += bsp->perc;
buflen = bsp->bs;
perc += bsp->perc;
- if (r <= ((
LONG
_MAX / 100L) * perc))
+ if (r <= ((
OS_RAND
_MAX / 100L) * perc))
break;
}
}
break;
}
}
- if (!td->o.bs_unaligned) {
- buflen = (buflen + td->o.min_bs[ddir] - 1)
- & ~(td->o.min_bs[ddir] - 1);
- }
+ if (!td->o.bs_unaligned && is_power_of_2(minbs))
+ buflen = (buflen + minbs - 1) & ~(minbs - 1);
}
if (io_u->offset + buflen > io_u->file->real_file_size) {
dprint(FD_IO, "lower buflen %u -> %u (ddir=%d)\n", buflen,
}
if (io_u->offset + buflen > io_u->file->real_file_size) {
dprint(FD_IO, "lower buflen %u -> %u (ddir=%d)\n", buflen,
-
td->o.min_bs[ddir]
, ddir);
- buflen =
td->o.min_bs[ddir]
;
+
minbs
, ddir);
+ buflen =
minbs
;
}
return buflen;
}
return buflen;
@@
-896,24
+903,29
@@
static void io_completed(struct thread_data *td, struct io_u *io_u,
if (!io_u->error) {
unsigned int bytes = io_u->buflen - io_u->resid;
const enum fio_ddir idx = io_u->ddir;
if (!io_u->error) {
unsigned int bytes = io_u->buflen - io_u->resid;
const enum fio_ddir idx = io_u->ddir;
- int ret;
+ int ret, ramp_done;
+
+ ramp_done = ramp_time_over(td);
- td->io_blocks[idx]++;
- td->io_bytes[idx] += bytes;
- td->this_io_bytes[idx] += bytes;
+ if (ramp_done) {
+ td->io_blocks[idx]++;
+ td->io_bytes[idx] += bytes;
+ td->this_io_bytes[idx] += bytes;
- usec = utime_since(&io_u->issue_time, &icd->time);
+
usec = utime_since(&io_u->issue_time, &icd->time);
- add_clat_sample(td, idx, usec);
- add_bw_sample(td, idx, &icd->time);
- io_u_mark_latency(td, usec);
+ add_clat_sample(td, idx, usec);
+ add_bw_sample(td, idx, &icd->time);
+ io_u_mark_latency(td, usec);
+ }
if (td_write(td) && idx == DDIR_WRITE &&
td->o.do_verify &&
td->o.verify != VERIFY_NONE)
log_io_piece(td, io_u);
if (td_write(td) && idx == DDIR_WRITE &&
td->o.do_verify &&
td->o.verify != VERIFY_NONE)
log_io_piece(td, io_u);
- icd->bytes_done[idx] += bytes;
+ if (ramp_done)
+ icd->bytes_done[idx] += bytes;
if (io_u->end_io) {
ret = io_u->end_io(td, io_u);
if (io_u->end_io) {
ret = io_u->end_io(td, io_u);
@@
-971,19
+983,19
@@
long io_u_sync_complete(struct thread_data *td, struct io_u *io_u)
/*
* Called to complete min_events number of io for the async engines.
*/
/*
* Called to complete min_events number of io for the async engines.
*/
-long io_u_queued_complete(struct thread_data *td, int min_ev
en
ts)
+long io_u_queued_complete(struct thread_data *td, int min_evts)
{
struct io_completion_data icd;
struct timespec *tvp = NULL;
int ret;
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, };
{
struct io_completion_data icd;
struct timespec *tvp = NULL;
int ret;
struct timespec ts = { .tv_sec = 0, .tv_nsec = 0, };
- dprint(FD_IO, "io_u_queued_completed: min=%d\n", min_ev
en
ts);
+ dprint(FD_IO, "io_u_queued_completed: min=%d\n", min_evts);
- if (!min_ev
en
ts)
+ if (!min_evts)
tvp = &ts;
tvp = &ts;
- ret = td_io_getevents(td, min_ev
ents, td->cur_depth
, tvp);
+ ret = td_io_getevents(td, min_ev
ts, td->o.iodepth_batch_complete
, tvp);
if (ret < 0) {
td_verror(td, -ret, "td_io_getevents");
return ret;
if (ret < 0) {
td_verror(td, -ret, "td_io_getevents");
return ret;