Skip to content

Commit

Permalink
Added events for rebuild start and finish
Browse files Browse the repository at this point in the history
Also fixed a NULL vdev_top dereference

Signed-off-by: Isaac Huang <[email protected]>
  • Loading branch information
huangheintel committed Apr 18, 2017
1 parent aec467f commit e9341b3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion include/sys/fs/zfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,9 @@ typedef enum {
* given payloads:
*
* ESC_ZFS_RESILVER_START
* ESC_ZFS_RESILVER_END
* ESC_ZFS_RESILVER_FINISH
* ESC_ZFS_REBUILD_START
* ESC_ZFS_REBUILD_FINISH
* ESC_ZFS_POOL_DESTROY
* ESC_ZFS_POOL_REGUID
*
Expand Down
2 changes: 2 additions & 0 deletions include/sys/sysevent/eventdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ extern "C" {
*/
#define ESC_ZFS_RESILVER_START "resilver_start"
#define ESC_ZFS_RESILVER_FINISH "resilver_finish"
#define ESC_ZFS_REBUILD_START "rebuild_start"
#define ESC_ZFS_REBUILD_FINISH "rebuild_finish"
#define ESC_ZFS_VDEV_REMOVE "vdev_remove"
#define ESC_ZFS_VDEV_REMOVE_AUX "vdev_remove_aux"
#define ESC_ZFS_VDEV_REMOVE_DEV "vdev_remove_dev"
Expand Down
12 changes: 10 additions & 2 deletions module/zfs/dsl_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,16 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
vdev_dtl_reassess(spa->spa_root_vdev, tx->tx_txg,
complete ? scn->scn_phys.scn_max_txg : 0, B_TRUE);
if (complete) {
spa_event_notify(spa, NULL, scn->scn_phys.scn_min_txg ?
ESC_ZFS_RESILVER_FINISH : ESC_ZFS_SCRUB_FINISH);
const char *name;

if (DSL_SCAN_IS_REBUILD(scn))
name = ESC_ZFS_REBUILD_FINISH;
else if (scn->scn_phys.scn_min_txg)
name = ESC_ZFS_RESILVER_FINISH;
else
name = ESC_ZFS_SCRUB_FINISH;

spa_event_notify(spa, NULL, name);
}
spa_errlog_rotate(spa);

Expand Down
1 change: 1 addition & 0 deletions module/zfs/spa_scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ spa_scan_setup_sync(dmu_tx_t *tx)
spa_scan_stat_init(spa);

spa->spa_scrub_started = B_TRUE;
spa_event_notify(spa, NULL, ESC_ZFS_REBUILD_START);
}

int
Expand Down
2 changes: 1 addition & 1 deletion module/zfs/vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,7 @@ vdev_is_dead(vdev_t *vd)
boolean_t
vdev_is_dead_at(vdev_t *vd, uint64_t zio_offset)
{
if (vd->vdev_top->vdev_ops != &vdev_draid_ops)
if (vd->vdev_top == NULL || vd->vdev_top->vdev_ops != &vdev_draid_ops)
return (vdev_is_dead(vd));

if (vd->vdev_ops == &vdev_draid_spare_ops)
Expand Down
4 changes: 2 additions & 2 deletions module/zfs/vdev_mirror.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ vdev_mirror_child_readable(mirror_child_t *mc)
{
vdev_t *vd = mc->mc_vd;

if (vd->vdev_top->vdev_ops == &vdev_draid_ops)
if (vd->vdev_top != NULL && vd->vdev_top->vdev_ops == &vdev_draid_ops)
return (vdev_draid_readable(vd, mc->mc_offset));
else
return (vdev_readable(vd));
Expand All @@ -326,7 +326,7 @@ vdev_mirror_child_missing(mirror_child_t *mc, uint64_t txg, uint64_t size)
{
vdev_t *vd = mc->mc_vd;

if (vd->vdev_top->vdev_ops == &vdev_draid_ops)
if (vd->vdev_top != NULL && vd->vdev_top->vdev_ops == &vdev_draid_ops)
return (vdev_draid_missing(vd, mc->mc_offset, txg, size));
else
return (vdev_dtl_contains(vd, DTL_MISSING, txg, size));
Expand Down

0 comments on commit e9341b3

Please sign in to comment.