diff mbox

rbd.cc: Check io-size avoid floating point exception.

Message ID 6AA21C22F0A5DA478922644AD2EC308C87E2AA@SHSMSX101.ccr.corp.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ma, Jianpeng June 12, 2014, 8:15 a.m. UTC
In func do_bench_write if io_size is zero,it can cause floating point execption.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
---
 src/rbd.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Josh Durgin July 11, 2014, 1:01 a.m. UTC | #1
On 06/12/2014 01:15 AM, Ma, Jianpeng wrote:
> In func do_bench_write if io_size is zero,it can cause floating point execption.
>
> Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>

Applied, thanks!

Josh

> ---
>   src/rbd.cc | 8 ++++++++
>   1 file changed, 8 insertions(+)
>
> diff --git a/src/rbd.cc b/src/rbd.cc
> index d6658e3..c068ed6 100644
> --- a/src/rbd.cc
> +++ b/src/rbd.cc
> @@ -2038,6 +2038,14 @@ int main(int argc, const char **argv)
>   	return EXIT_FAILURE;
>         }
>       } else if (ceph_argparse_withlonglong(args, i, &bench_io_size, &err, "--io-size", (char*)NULL)) {
> +      if (!err.str().empty()) {
> +	cerr << "rbd: " << err.str() << std::endl;
> +	return EXIT_FAILURE;
> +      }
> +      if (bench_io_size == 0) {
> +	cerr << "rbd: io-size must be > 0" << std::endl;
> +	return EXIT_FAILURE;
> +      }
>       } else if (ceph_argparse_withlonglong(args, i, &bench_io_threads, &err, "--io-threads", (char*)NULL)) {
>       } else if (ceph_argparse_withlonglong(args, i, &bench_bytes, &err, "--io-total", (char*)NULL)) {
>       } else if (ceph_argparse_witharg(args, i, &bench_pattern, &err, "--io-pattern", (char*)NULL)) {
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/src/rbd.cc b/src/rbd.cc
index d6658e3..c068ed6 100644
--- a/src/rbd.cc
+++ b/src/rbd.cc
@@ -2038,6 +2038,14 @@  int main(int argc, const char **argv)
 	return EXIT_FAILURE;
       }
     } else if (ceph_argparse_withlonglong(args, i, &bench_io_size, &err, "--io-size", (char*)NULL)) {
+      if (!err.str().empty()) {
+	cerr << "rbd: " << err.str() << std::endl;
+	return EXIT_FAILURE;
+      }
+      if (bench_io_size == 0) {
+	cerr << "rbd: io-size must be > 0" << std::endl;
+	return EXIT_FAILURE;
+      }
     } else if (ceph_argparse_withlonglong(args, i, &bench_io_threads, &err, "--io-threads", (char*)NULL)) {
     } else if (ceph_argparse_withlonglong(args, i, &bench_bytes, &err, "--io-total", (char*)NULL)) {
     } else if (ceph_argparse_witharg(args, i, &bench_pattern, &err, "--io-pattern", (char*)NULL)) {