]> granicus.if.org Git - zfs/commitdiff
Fix coverity defects: CID 165755
authorGiuseppe Di Natale <dinatale2@users.noreply.github.com>
Mon, 24 Jul 2017 18:16:58 +0000 (11:16 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 24 Jul 2017 18:16:58 +0000 (11:16 -0700)
CID 165755: Division or modulo by zero (DIVIDE_BY_ZERO)

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Signed-off-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Closes #6352

module/zfs/mmp.c
module/zfs/spa.c

index 35348f8b4dc32b73b99be0e8d5bddf0f02141b81..6541eca162bdcc12a36871974eae57e09f3c1b82 100644 (file)
@@ -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);
                }
index 7edf0459ce47a3f9488b3b89fe336579873e18ea..f576293ebf3c3d21493f2c5b79ff0bd3ffdbd4e4 100644 (file)
@@ -2448,7 +2448,7 @@ spa_activity_check(spa_t *spa, uberblock_t *ub, nvlist_t *config)
         */
        if (ub->ub_mmp_magic == MMP_MAGIC && ub->ub_mmp_delay)
                import_delay = MAX(import_delay, import_intervals *
-                   ub->ub_mmp_delay * vdev_count_leaves(spa));
+                   ub->ub_mmp_delay * MAX(vdev_count_leaves(spa), 1));
 
        /* Apply a floor using the local default values. */
        import_delay = MAX(import_delay, import_intervals *