Skip to content

Commit

Permalink
Fix divide-by-zero in mmp_delay_update()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Signed-off-by: Olaf Faaland <[email protected]>
Closes openzfs#7391
  • Loading branch information
ofaaland authored and tonyhutter committed Aug 23, 2018
1 parent bb97bec commit ce32ed6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion module/zfs/mmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit ce32ed6

Please sign in to comment.