Skip to content

Commit 907e53a

Browse files
committed
rbd: "rbd bench" always writes the same byte
It's expected that the buffer is filled with the same byte, but the byte should differ from run to run: memset(bp.c_str(), rand() & 0xff, io_size); This was broken in commit c7f71d1 ("rbd: migrated existing command logic to new namespaces") which inadvertently moved the call to srand(), leaving rand() unseeded for the above memset(). Fixes: https://tracker.ceph.com/issues/67698 Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 1606e7f commit 907e53a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/tools/rbd/action/Bench.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,9 @@ int do_bench(librbd::Image& image, io_type_t io_type,
233233
return r;
234234
}
235235

236+
// seed rand() before constructing rbd_bencher
237+
srand(time(NULL) % (unsigned long) -1);
238+
236239
rbd_bencher b(&image, io_type, io_size);
237240

238241
std::cout << "bench "
@@ -261,8 +264,6 @@ int do_bench(librbd::Image& image, io_type_t io_type,
261264
}
262265
std::cout << std::endl;
263266

264-
srand(time(NULL) % (unsigned long) -1);
265-
266267
coarse_mono_time start = coarse_mono_clock::now();
267268
std::chrono::duration<double> last = std::chrono::duration<double>::zero();
268269
uint64_t ios = 0;

0 commit comments

Comments
 (0)