summaryrefslogtreecommitdiff
path: root/io_u.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2017-11-29 20:45:33 -0700
committerJens Axboe <axboe@kernel.dk>2017-11-29 20:45:33 -0700
commite3c8c1081fb361803f7414fcc593b0dedc3c3bed (patch)
tree2fe780cecb4351399b1029b78286616d46881d89 /io_u.c
parent057bc4a6587d99088bfe4da28f43501212137ad4 (diff)
downloadfio-e3c8c1081fb361803f7414fcc593b0dedc3c3bed.tar.gz
fio-e3c8c1081fb361803f7414fcc593b0dedc3c3bed.tar.bz2
io_u: cleanup and simplify __get_next_rand_offset_zoned_abs()
We can drop various variables, it's easier to read this way too. Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_u.c')
-rw-r--r--io_u.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/io_u.c b/io_u.c
index 6ec04fa3..6b950014 100644
--- a/io_u.c
+++ b/io_u.c
@@ -162,8 +162,7 @@ static int __get_next_rand_offset_zoned_abs(struct thread_data *td,
enum fio_ddir ddir, uint64_t *b)
{
struct zone_split_index *zsi;
- uint64_t offset, lastb;
- uint64_t send, stotal;
+ uint64_t lastb, send, stotal;
static int warned;
unsigned int v;
@@ -181,6 +180,10 @@ bail:
*/
v = rand32_between(&td->zone_state, 1, 100);
+ /*
+ * Find our generated table. 'send' is the end block of this zone,
+ * 'stotal' is our start offset.
+ */
zsi = &td->zone_state_index[ddir][v - 1];
stotal = zsi->size_prev / td->o.ba[ddir];
send = zsi->size / td->o.ba[ddir];
@@ -205,29 +208,12 @@ bail:
}
/*
- * 'send' is some percentage below or equal to 100 that
- * marks the end of the current IO range. 'stotal' marks
- * the start, in percent.
+ * Generate index from 0..send-stotal
*/
- if (stotal)
- offset = stotal;
- else
- offset = 0;
-
- lastb = send - stotal;
-
- /*
- * Generate index from 0..send-of-lastb
- */
- if (__get_next_rand_offset(td, f, ddir, b, lastb) == 1)
+ if (__get_next_rand_offset(td, f, ddir, b, send - stotal) == 1)
return 1;
- /*
- * Add our start offset, if any
- */
- if (offset)
- *b += offset;
-
+ *b += stotal;
return 0;
}