Skip to content

Commit

Permalink
Fix divide by zero during indirect split damage
Browse files Browse the repository at this point in the history
This patch simply ensures that vdev_indirect_splits_damage()
cannot hit a divide by zero exception if a split has no
children with valid data. The normal reconstruction code
path in vdev_indirect_reconstruct_io_done() already has this
check.

Signed-off-by: Tom Caputi <tcaputi@datto.com>

TEST_ZTEST_TIMEOUT=3600
  • Loading branch information
Tom Caputi committed Oct 31, 2018
1 parent 31e00ec commit a065662
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion module/zfs/vdev_indirect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,8 @@ vdev_indirect_splits_enumerate_randomly(indirect_vsd_t *iv, zio_t *zio)
static int
vdev_indirect_splits_damage(indirect_vsd_t *iv, zio_t *zio)
{
int error;

/* Presume all the copies are unique for initial selection. */
for (indirect_split_t *is = list_head(&iv->iv_splits);
is != NULL; is = list_next(&iv->iv_splits, is)) {
Expand All @@ -1599,13 +1601,18 @@ vdev_indirect_splits_damage(indirect_vsd_t *iv, zio_t *zio)
list_insert_tail(&is->is_unique_child, ic);
}
}

if (list_is_empty(&is->is_unique_child)) {
error = SET_ERROR(EIO);
goto out;
}
}

/*
* Set each is_good_child to a randomly-selected child which
* is known to contain validated data.
*/
int error = vdev_indirect_splits_enumerate_randomly(iv, zio);
error = vdev_indirect_splits_enumerate_randomly(iv, zio);
if (error)
goto out;

Expand Down

0 comments on commit a065662

Please sign in to comment.