Skip to content

Commit

Permalink
rbd: fix thread_offsets calculation of rbd bench
Browse files Browse the repository at this point in the history
This patch fixes the calculation of the thread_offset vector
for sequential I/O of rbd bench command.

The rbd bench command doesn't access whole image of rbd,
because the some chunks are not assigned to threads.
This patch changes the way to calculate the thread_offsets
to assign all chunks to threads.

Signed-off-by: Hitoshi Kamei <hitoshi.kamei.xm@hitachi.com>
Cc: Mitsuo Hayasaka <mitsuo.hayasaka.hu@hitachi.com>
  • Loading branch information
hitoshikamei committed Mar 2, 2018
1 parent 01fc18c commit 75c5620
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/tools/rbd/action/Bench.cc
Expand Up @@ -276,20 +276,14 @@ int do_bench(librbd::Image& image, io_type_t io_type,
int write_ops = 0;

for (off = 0; off < io_bytes; ) {
// Issue I/O
i = 0;
while (i < io_threads && off < io_bytes) {
bool read_flag = should_read(read_proportion);

b.wait_for(io_threads - 1);
b.start_io(io_threads, thread_offset[i], io_size, op_flags, read_flag);

if (random) {
thread_offset[i] = (rand() % (size / io_size)) * io_size;
} else {
thread_offset[i] += io_size;
if (thread_offset[i] + io_size > size)
thread_offset[i] = 0;
}
++i;
++ios;
off += io_size;
Expand All @@ -303,6 +297,22 @@ int do_bench(librbd::Image& image, io_type_t io_type,
write_ops++;
}

// Set the thread_offsets of next I/O
for (i = 0; i < io_threads; ++i) {
if (random) {
thread_offset[i] = (rand() % (size / io_size)) * io_size;
continue;
}
if (off < (io_size * unit_len * io_threads) ) {
thread_offset[i] += io_size;
} else {
// thread_offset is adjusted to the chunks unassigned to threads.
thread_offset[i] = off + (i * io_size);
}
if (thread_offset[i] + io_size > size)
thread_offset[i] = unit_len * i * io_size;
}

coarse_mono_time now = coarse_mono_clock::now();
chrono::duration<double> elapsed = now - start;
if (last == chrono::duration<double>::zero()) {
Expand Down

0 comments on commit 75c5620

Please sign in to comment.