From 4a287e8fcd10c70b3b41854c9af1200b508c8427 Mon Sep 17 00:00:00 2001 From: haoyixing Date: Mon, 16 Aug 2021 18:55:24 +0800 Subject: [PATCH] rbd: avoid overflow of ios and clarify io-size limit for bench When doing rbd bench, we record done ios to print progress, current it's unsigned. Suppose we do a bench of io-size 512B and io-total 4T, that means a total number of 8G ios which causes an overflow. And we don't support io-size greater than 4G, so change help message. Signed-off-by: haoyixing --- src/test/cli/rbd/help.t | 2 +- src/tools/rbd/action/Bench.cc | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/cli/rbd/help.t b/src/test/cli/rbd/help.t index 3f4c54377873c..22362eb806a1e 100644 --- a/src/test/cli/rbd/help.t +++ b/src/test/cli/rbd/help.t @@ -183,7 +183,7 @@ -p [ --pool ] arg pool name --namespace arg namespace name --image arg image name - --io-size arg IO size (in B/K/M/G/T) [default: 4K] + --io-size arg IO size (in B/K/M/G) (< 4G) [default: 4K] --io-threads arg ios in flight [default: 16] --io-total arg total size for IO (in B/K/M/G/T) [default: 1G] --io-pattern arg IO pattern (rand, seq, or full-seq) [default: seq] diff --git a/src/tools/rbd/action/Bench.cc b/src/tools/rbd/action/Bench.cc index 6d0e2cff8f33d..061a76d333290 100644 --- a/src/tools/rbd/action/Bench.cc +++ b/src/tools/rbd/action/Bench.cc @@ -265,7 +265,7 @@ int do_bench(librbd::Image& image, io_type_t io_type, coarse_mono_time start = coarse_mono_clock::now(); std::chrono::duration last = std::chrono::duration::zero(); - unsigned ios = 0; + uint64_t ios = 0; std::vector thread_offset; uint64_t i; @@ -389,7 +389,7 @@ int do_bench(librbd::Image& image, io_type_t io_type, std::cout.width(5); std::cout << (int)elapsed.count(); std::cout.width(10); - std::cout << (int)(ios - io_threads); + std::cout << ios - io_threads; std::cout.width(10); std::cout << boost::accumulators::rolling_sum(ios_acc) / time_sum; std::cout.width(10); @@ -438,7 +438,7 @@ void add_bench_common_options(po::options_description *positional, at::add_image_spec_options(positional, options, at::ARGUMENT_MODIFIER_NONE); options->add_options() - ("io-size", po::value(), "IO size (in B/K/M/G/T) [default: 4K]") + ("io-size", po::value(), "IO size (in B/K/M/G) (< 4G) [default: 4K]") ("io-threads", po::value(), "ios in flight [default: 16]") ("io-total", po::value(), "total size for IO (in B/K/M/G/T) [default: 1G]") ("io-pattern", po::value(), "IO pattern (rand, seq, or full-seq) [default: seq]") -- 2.39.5