@@ -381,7 +381,8 @@ get_usage(zpool_help_t idx)
381381 return (gettext ("\tinitialize [-c | -s] <pool> "
382382 "[<device> ...]\n" ));
383383 case HELP_SCRUB :
384- return (gettext ("\tscrub [-s | -p] <pool> ...\n" ));
384+ return (gettext ("\tscrub [-s | -p | -e | -e -s | -e -p] <pool>"
385+ " ...\n" ));
385386 case HELP_RESILVER :
386387 return (gettext ("\tresilver <pool> ...\n" ));
387388 case HELP_TRIM :
@@ -6691,7 +6692,11 @@ scrub_callback(zpool_handle_t *zhp, void *data)
66916692 return (1 );
66926693 }
66936694
6694- err = zpool_scan (zhp , cb -> cb_type , cb -> cb_scrub_cmd );
6695+ if (cb -> cb_type == POOL_RESCRUB ) {
6696+ err = zpool_rescrub (zhp , cb -> cb_type , cb -> cb_scrub_cmd );
6697+ } else {
6698+ err = zpool_scan (zhp , cb -> cb_type , cb -> cb_scrub_cmd );
6699+ }
66956700
66966701 if (err == 0 && zpool_has_checkpoint (zhp ) &&
66976702 cb -> cb_type == POOL_SCAN_SCRUB ) {
@@ -6706,6 +6711,7 @@ scrub_callback(zpool_handle_t *zhp, void *data)
67066711/*
67076712 * zpool scrub [-s | -p] <pool> ...
67086713 *
6714+ * -e For error blocks. Starts/Resumes error blocks scrubbing.
67096715 * -s Stop. Stops any in-progress scrub.
67106716 * -p Pause. Pause in-progress scrub.
67116717 */
@@ -6718,27 +6724,52 @@ zpool_do_scrub(int argc, char **argv)
67186724 cb .cb_type = POOL_SCAN_SCRUB ;
67196725 cb .cb_scrub_cmd = POOL_SCRUB_NORMAL ;
67206726
6727+ boolean_t is_error_scrub = B_FALSE ;
6728+ boolean_t is_pause = B_FALSE ;
6729+ boolean_t is_stop = B_FALSE ;
67216730 /* check options */
6722- while ((c = getopt (argc , argv , "sp " )) != -1 ) {
6731+ while ((c = getopt (argc , argv , "eps " )) != -1 ) {
67236732 switch (c ) {
6724- case 's' :
6725- cb . cb_type = POOL_SCAN_NONE ;
6733+ case 'e' : {
6734+ is_error_scrub = B_TRUE ;
67266735 break ;
6727- case 'p' :
6728- cb .cb_scrub_cmd = POOL_SCRUB_PAUSE ;
6736+ }
6737+ case 's' : {
6738+ is_stop = B_TRUE ;
6739+ break ;
6740+ }
6741+ case 'p' : {
6742+ is_pause = B_TRUE ;
67296743 break ;
6744+ }
67306745 case '?' :
67316746 (void ) fprintf (stderr , gettext ("invalid option '%c'\n" ),
67326747 optopt );
67336748 usage (B_FALSE );
67346749 }
67356750 }
67366751
6737- if (cb .cb_type == POOL_SCAN_NONE &&
6738- cb .cb_scrub_cmd == POOL_SCRUB_PAUSE ) {
6739- (void ) fprintf (stderr , gettext ("invalid option combination: "
6740- "-s and -p are mutually exclusive\n" ));
6752+ if (is_pause && is_stop ) {
6753+ (void ) fprintf (stderr , gettext ("invalid option "
6754+ "combination :-s and -p are mutually exclusive\n" ));
67416755 usage (B_FALSE );
6756+ } else {
6757+ if (is_error_scrub ) {
6758+ cb .cb_type = POOL_RESCRUB ;
6759+ if (is_pause ) {
6760+ cb .cb_scrub_cmd = POOL_RESCRUB_PAUSE ;
6761+ } else if (is_stop ) {
6762+ cb .cb_scrub_cmd = POOL_RESCRUB_STOP ;
6763+ } else {
6764+ cb .cb_scrub_cmd = POOL_RESCRUB_NORMAL ;
6765+ }
6766+ } else {
6767+ if (is_pause ) {
6768+ cb .cb_scrub_cmd = POOL_SCRUB_PAUSE ;
6769+ } else if (is_stop ) {
6770+ cb .cb_type = POOL_SCAN_NONE ;
6771+ }
6772+ }
67426773 }
67436774
67446775 cb .cb_argc = argc ;
0 commit comments