From 113775eb583fa28a669c6dc1f8dbf47a8ecd789c Mon Sep 17 00:00:00 2001 From: Jason Dillaman Date: Fri, 12 Aug 2016 08:26:49 -0400 Subject: [PATCH] rbd: bench io-size should not be larger than image size Fixes: http://tracker.ceph.com/issues/16967 Signed-off-by: Jason Dillaman --- src/tools/rbd/action/Bench.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 84543375f242f..42d05dd16ce3d 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -188,6 +188,14 @@ int do_bench(librbd::Image& image, io_type_t io_type, uint64_t io_size, uint64_t io_threads, uint64_t io_bytes, bool random) { + uint64_t size = 0; + image.size(&size); + if (io_size > size) { + std::cerr << "rbd: io-size " << prettybyte_t(io_size) << " " + << "larger than image size " << prettybyte_t(size) << std::endl; + return -EINVAL; + } + rbd_bencher b(&image, io_type, io_size); std::cout << "bench " @@ -204,9 +212,6 @@ int do_bench(librbd::Image& image, io_type_t io_type, utime_t last; unsigned ios = 0; - uint64_t size = 0; - image.size(&size); - vector thread_offset; uint64_t i; uint64_t start_pos; @@ -379,7 +384,7 @@ int bench_execute(const po::variables_map &vm, io_type_t bench_io_type) { r = do_bench(image, bench_io_type, bench_io_size, bench_io_threads, bench_bytes, bench_random); if (r < 0) { - std::cerr << "do_bench failed: " << cpp_strerror(r) << std::endl; + std::cerr << "bench failed: " << cpp_strerror(r) << std::endl; return r; } return 0; -- 2.39.5