From 6b5cc49d81305b25b2d6a1348bf34f05dbd9a409 Mon Sep 17 00:00:00 2001 From: Olaf Faaland Date: Fri, 6 Apr 2018 13:29:11 -0700 Subject: [PATCH] Fix divide-by-zero in mmp_delay_update() vdev_count_leaves() in the denominator may return 0, caught by Coverity. Introduced by * 533ea04 Update mmp_delay on sync or skipped, failed write Reviewed-by: Brian Behlendorf Reviewed-by: Giuseppe Di Natale Reviewed-by: George Melikov Signed-off-by: Olaf Faaland Closes #7391 --- module/zfs/mmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/mmp.c b/module/zfs/mmp.c index 1ae5f31fd6..3b74a6b618 100644 --- a/module/zfs/mmp.c +++ b/module/zfs/mmp.c @@ -327,7 +327,7 @@ mmp_delay_update(spa_t *spa, boolean_t write_completed) */ if (delay < mts->mmp_delay) { hrtime_t min_delay = MSEC2NSEC(zfs_multihost_interval) / - vdev_count_leaves(spa); + MAX(1, vdev_count_leaves(spa)); mts->mmp_delay = MAX(((delay + mts->mmp_delay * 127) / 128), min_delay); }