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 <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Olaf Faaland <faaland1@llnl.gov>
Closes #7391
This commit is contained in:
Olaf Faaland 2018-04-06 13:29:11 -07:00 committed by Brian Behlendorf
parent 1bf9a552bb
commit 0ba106e75c
1 changed files with 1 additions and 1 deletions

View File

@ -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);
}