]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rbd: bench io-size should not be larger than image size
authorJason Dillaman <dillaman@redhat.com>
Fri, 12 Aug 2016 12:26:49 +0000 (08:26 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 12 Aug 2016 12:26:49 +0000 (08:26 -0400)
Fixes: http://tracker.ceph.com/issues/16967
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/tools/rbd/action/Bench.cc

index 84543375f242faba14b932450f8633e4a93d15fb..42d05dd16ce3d9fa1fa313b9a15d8e7bc22a1807 100644 (file)
@@ -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<uint64_t> 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;