perf: Fix integer overflow
perf application can't generate IO for NVMe namespace with
more than 4G size.
Example of error:
"Attached to NVMe over Fabrics controller at 1.1.75.1:1023:
nqn.2016-06.io.spdk.r-dcs75:rd0
WARNING: controller SPDK bdev Controller (SPDK000DEADBEAF00 ) ns 1 has
invalid ns size 0 / block size 4096 for I/O size 4096
WARNING: Some requested NVMe devices were skipped
No valid NVMe controllers or AIO devices found"
ns_size variable is uint32_t, spdk_nvme_ns_get_size function
returns uint64_t. Result can exceed the maximum size of
uint32_t and ns_size remains 0.
The issue introduced by commit: f2462909
Change-Id: Idc6dd8688d5d6268bda1a1d6b06a611643af6155
Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Reviewed-on: https://review.gerrithub.io/c/443996
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
ceb32abbd8
commit
bdc96b4dd6
@ -4,6 +4,8 @@
|
|||||||
* Copyright (c) Intel Corporation.
|
* Copyright (c) Intel Corporation.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
* Copyright (c) 2019 Mellanox Technologies LTD. All rights reserved.
|
||||||
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
@ -588,7 +590,8 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
|
|||||||
{
|
{
|
||||||
struct ns_entry *entry;
|
struct ns_entry *entry;
|
||||||
const struct spdk_nvme_ctrlr_data *cdata;
|
const struct spdk_nvme_ctrlr_data *cdata;
|
||||||
uint32_t max_xfer_size, entries, ns_size, sector_size;
|
uint32_t max_xfer_size, entries, sector_size;
|
||||||
|
uint64_t ns_size;
|
||||||
struct spdk_nvme_io_qpair_opts opts;
|
struct spdk_nvme_io_qpair_opts opts;
|
||||||
|
|
||||||
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
cdata = spdk_nvme_ctrlr_get_data(ctrlr);
|
||||||
@ -606,7 +609,7 @@ register_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns *ns)
|
|||||||
|
|
||||||
if (ns_size < g_io_size_bytes || sector_size > g_io_size_bytes) {
|
if (ns_size < g_io_size_bytes || sector_size > g_io_size_bytes) {
|
||||||
printf("WARNING: controller %-20.20s (%-20.20s) ns %u has invalid "
|
printf("WARNING: controller %-20.20s (%-20.20s) ns %u has invalid "
|
||||||
"ns size %u / block size %u for I/O size %u\n",
|
"ns size %" PRIu64 " / block size %u for I/O size %u\n",
|
||||||
cdata->mn, cdata->sn, spdk_nvme_ns_get_id(ns),
|
cdata->mn, cdata->sn, spdk_nvme_ns_get_id(ns),
|
||||||
ns_size, spdk_nvme_ns_get_sector_size(ns), g_io_size_bytes);
|
ns_size, spdk_nvme_ns_get_sector_size(ns), g_io_size_bytes);
|
||||||
g_warn = true;
|
g_warn = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user