Skip to content

Commit

Permalink
vdev_ops: don't try to call vdev_op_hold or vdev_op_rele when NULL
Browse files Browse the repository at this point in the history
This prevents a panic after a SLOG add/removal on the root pool followed
by a zpool scrub.

When a SLOG is removed, a hole takes its place - the vdev_ops for a hole
is vdev_hole_ops, which defines the handler functions of vdev_op_hold
and vdev_op_rele as NULL.

This bug has been reported in illumos and FreeBSD, a different trigger
in the FreeBSD report though.

Credit for this patch goes to Patrick Mooney <pmooney@pfmooney.com>

Obtained from: illumos-gate commit: c65bd18728f34725
External-issue: https://www.illumos.org/issues/12981
External-issue: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=252396
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Wing <rob.fx907@gmail.com>
Closes #11623
  • Loading branch information
fbynite authored and behlendorf committed Mar 5, 2021
1 parent 286c7f7 commit 4d4dd76
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2317,7 +2317,7 @@ vdev_hold(vdev_t *vd)
for (int c = 0; c < vd->vdev_children; c++)
vdev_hold(vd->vdev_child[c]);

if (vd->vdev_ops->vdev_op_leaf)
if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_hold != NULL)
vd->vdev_ops->vdev_op_hold(vd);
}

Expand All @@ -2328,7 +2328,7 @@ vdev_rele(vdev_t *vd)
for (int c = 0; c < vd->vdev_children; c++)
vdev_rele(vd->vdev_child[c]);

if (vd->vdev_ops->vdev_op_leaf)
if (vd->vdev_ops->vdev_op_leaf && vd->vdev_ops->vdev_op_rele != NULL)
vd->vdev_ops->vdev_op_rele(vd);
}

Expand Down

0 comments on commit 4d4dd76

Please sign in to comment.