aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/mmp.c
diff options
context:
space:
mode:
authorGiuseppe Di Natale <[email protected]>2017-07-24 11:16:58 -0700
committerBrian Behlendorf <[email protected]>2017-07-24 11:16:58 -0700
commit802ae562ed817af978e2636806db1952d29ee86d (patch)
treed67a37dddedc2ee71e9e75acf4c7e4d33122a621 /module/zfs/mmp.c
parent39554216dff2c8bd4a2fa296644b5e3723ce8ed3 (diff)
Fix coverity defects: CID 165755
CID 165755: Division or modulo by zero (DIVIDE_BY_ZERO) Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Olaf Faaland <[email protected]> Signed-off-by: Giuseppe Di Natale <[email protected]> Closes #6352
Diffstat (limited to 'module/zfs/mmp.c')
-rw-r--r--module/zfs/mmp.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/module/zfs/mmp.c b/module/zfs/mmp.c
index 35348f8b4..6541eca16 100644
--- a/module/zfs/mmp.c
+++ b/module/zfs/mmp.c
@@ -378,7 +378,7 @@ mmp_thread(spa_t *spa)
* with fake, but reasonable, default non-zero values.
*/
mmp->mmp_delay = MSEC2NSEC(MAX(zfs_multihost_interval,
- MMP_MIN_INTERVAL)) / vdev_count_leaves(spa);
+ MMP_MIN_INTERVAL)) / MAX(vdev_count_leaves(spa), 1);
mmp->mmp_last_write = gethrtime() - mmp->mmp_delay;
while (!mmp->mmp_thread_exiting) {
@@ -392,7 +392,7 @@ mmp_thread(spa_t *spa)
start = gethrtime();
if (multihost) {
next_time = start + mmp_interval /
- vdev_count_leaves(spa);
+ MAX(vdev_count_leaves(spa), 1);
} else {
next_time = start + MSEC2NSEC(MMP_DEFAULT_INTERVAL);
}