nvme: add additional check to avoid being divided by zero error
When a Namespace was removed all the field will be zeroed, which may lead to being divied by zero error when IO is running, especially with perf tool. The perf tool doesn't add hogplug support, so we add the additional check here to avoid such issue. Fix issues #728 and #629. Change-Id: I0e387c8c1bd4f3d40130377e2e0f5143f43be6a3 Signed-off-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/451762 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
f74643ef0f
commit
4582e9fb4a
@ -44,11 +44,15 @@ static bool
|
||||
spdk_nvme_ns_check_request_length(uint32_t lba_count, uint32_t sectors_per_max_io,
|
||||
uint32_t sectors_per_stripe, uint32_t qdepth)
|
||||
{
|
||||
uint32_t child_per_io;
|
||||
uint32_t child_per_io = UINT32_MAX;
|
||||
|
||||
/* After a namespace is destroyed(e.g. hotplug), all the fields associated with the
|
||||
* namespace will be cleared to zero, the function will return TRUE for this case,
|
||||
* and -EINVAL will be returned to caller.
|
||||
*/
|
||||
if (sectors_per_stripe > 0) {
|
||||
child_per_io = (lba_count + sectors_per_stripe - 1) / sectors_per_stripe;
|
||||
} else {
|
||||
} else if (sectors_per_max_io > 0) {
|
||||
child_per_io = (lba_count + sectors_per_max_io - 1) / sectors_per_max_io;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user