From 43cb30b3ce6ee3c3041276c93594ae61e7daaf86 Mon Sep 17 00:00:00 2001 From: Sean Eric Fagan Date: Mon, 6 Nov 2017 15:13:23 -0800 Subject: [PATCH] OpenZFS 8959 - Add notifications when a scrub is paused or resumed Authored by: Sean Eric Fagan Reviewed by: Alek Pinchuk Reviewed by: Matthew Ahrens Reviewed-by: George Melikov Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Approved by: Gordon Ross Ported-by: Giuseppe Di Natale Porting Notes: - Brought #defines in eventdefs.h in line with ZFS on Linux format. - Updated zfs-events.5 with the new events. OpenZFS-issue: https://www.illumos.org/issues/8959 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c862b93eea Closes #7049 --- include/sys/sysevent/eventdefs.h | 3 +++ man/man5/zfs-events.5 | 29 ++++++++++++++++++++++++++++- module/zfs/dsl_scan.c | 6 +++++- 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/include/sys/sysevent/eventdefs.h b/include/sys/sysevent/eventdefs.h index 825d88a7bc..aa13bd5052 100644 --- a/include/sys/sysevent/eventdefs.h +++ b/include/sys/sysevent/eventdefs.h @@ -110,6 +110,9 @@ extern "C" { #define ESC_ZFS_CONFIG_SYNC "config_sync" #define ESC_ZFS_SCRUB_START "scrub_start" #define ESC_ZFS_SCRUB_FINISH "scrub_finish" +#define ESC_ZFS_SCRUB_ABORT "scrub_abort" +#define ESC_ZFS_SCRUB_RESUME "scrub_resume" +#define ESC_ZFS_SCRUB_PAUSED "scrub_paused" #define ESC_ZFS_VDEV_SPARE "vdev_spare" #define ESC_ZFS_VDEV_AUTOEXPAND "vdev_autoexpand" #define ESC_ZFS_BOOTFS_VDEV_ATTACH "bootfs_vdev_attach" diff --git a/man/man5/zfs-events.5 b/man/man5/zfs-events.5 index 398ea8ad13..5cef4f5392 100644 --- a/man/man5/zfs-events.5 +++ b/man/man5/zfs-events.5 @@ -328,7 +328,34 @@ Issued when a scrub is started on a pool. \fBscrub.finish\fR .ad .RS 12n -Issued when a pool have finished scrubbing. +Issued when a pool has finished scrubbing. +.RE + +.sp +.ne 2 +.na +\fBscrub.abort\fR +.ad +.RS 12n +Issued when a scrub is aborted on a pool. +.RE + +.sp +.ne 2 +.na +\fBscrub.resume\fR +.ad +.RS 12n +Issued when a scrub is resumed on a pool. +.RE + +.sp +.ne 2 +.na +\fBscrub.paused\fR +.ad +.RS 12n +Issued when a scrub is paused on a pool. .RE .sp diff --git a/module/zfs/dsl_scan.c b/module/zfs/dsl_scan.c index de579d1c7e..2231ef1c0e 100644 --- a/module/zfs/dsl_scan.c +++ b/module/zfs/dsl_scan.c @@ -714,8 +714,10 @@ dsl_scan(dsl_pool_t *dp, pool_scan_func_t func) /* got scrub start cmd, resume paused scrub */ int err = dsl_scrub_set_pause_resume(scn->scn_dp, POOL_SCRUB_NORMAL); - if (err == 0) + if (err == 0) { + spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_RESUME); return (ECANCELED); + } return (SET_ERROR(err)); } @@ -842,6 +844,7 @@ dsl_scan_cancel_sync(void *arg, dmu_tx_t *tx) dsl_scan_done(scn, B_FALSE, tx); dsl_scan_sync_state(scn, tx, SYNC_MANDATORY); + spa_event_notify(scn->scn_dp->dp_spa, NULL, NULL, ESC_ZFS_SCRUB_ABORT); } int @@ -886,6 +889,7 @@ dsl_scrub_pause_resume_sync(void *arg, dmu_tx_t *tx) spa->spa_scan_pass_scrub_pause = gethrestime_sec(); scn->scn_phys.scn_flags |= DSF_SCRUB_PAUSED; dsl_scan_sync_state(scn, tx, SYNC_CACHED); + spa_event_notify(spa, NULL, NULL, ESC_ZFS_SCRUB_PAUSED); } else { ASSERT3U(*cmd, ==, POOL_SCRUB_NORMAL); if (dsl_scan_is_paused_scrub(scn)) {