Don't run 'zpool iostat -c CMD' command on all vdevs, if vdevs specified

zpool iostat allows you to specify only certain vdevs to display.
Currently, if you run 'zpool iostat -c CMD vdev1 vdev2 ...'
on specific vdevs, it will actually run the command on *all* vdevs,
and just display the results for the vdevs you specify.  This patch
corrects the behavior to only run the command on the specified vdevs,
and also enables the zpool_iostat_005_pos.ksh tests.
    
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #5443
This commit is contained in:
Tony Hutter
2016-12-16 16:10:45 -08:00
committed by Brian Behlendorf
parent 81eb8a1fbb
commit 1528bfdb14
5 changed files with 81 additions and 19 deletions
+22 -10
View File
@@ -312,7 +312,7 @@ get_usage(zpool_help_t idx) {
"[-R root] [-F [-n]]\n"
"\t <pool | id> [newpool]\n"));
case HELP_IOSTAT:
return (gettext("\tiostat [-T d | u] [-ghHLpPvy] "
return (gettext("\tiostat [-c CMD] [-T d | u] [-ghHLpPvy] "
"[[-lq]|[-r|-w]]\n"
"\t [[pool ...]|[pool vdev ...]|[vdev ...]] "
"[interval [count]]\n"));
@@ -335,8 +335,8 @@ get_usage(zpool_help_t idx) {
case HELP_SCRUB:
return (gettext("\tscrub [-s] <pool> ...\n"));
case HELP_STATUS:
return (gettext("\tstatus [-gLPvxD] [-T d|u] [pool] ... "
"[interval [count]]\n"));
return (gettext("\tstatus [-c CMD] [-gLPvxD] [-T d|u] [pool]"
" ... [interval [count]]\n"));
case HELP_UPGRADE:
return (gettext("\tupgrade\n"
"\tupgrade -v\n"
@@ -4055,8 +4055,13 @@ zpool_do_iostat(int argc, char **argv)
usage(B_FALSE);
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
if (optopt == 'c') {
fprintf(stderr,
gettext("Missing CMD for -c\n"));
} else {
fprintf(stderr,
gettext("invalid option '%c'\n"), optopt);
}
usage(B_FALSE);
}
}
@@ -4256,9 +4261,10 @@ zpool_do_iostat(int argc, char **argv)
continue;
}
if (cmd != NULL)
if (cmd != NULL && cb.cb_verbose)
cb.vcdl = all_pools_for_each_vdev_run(argc,
argv, cmd);
argv, cmd, g_zfs, cb.cb_vdev_names,
cb.cb_vdev_names_count, cb.cb_name_flags);
pool_list_iter(list, B_FALSE, print_iostat, &cb);
@@ -6113,8 +6119,13 @@ zpool_do_status(int argc, char **argv)
get_timestamp_arg(*optarg);
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
optopt);
if (optopt == 'c') {
fprintf(stderr,
gettext("Missing CMD for -c\n"));
} else {
fprintf(stderr,
gettext("invalid option '%c'\n"), optopt);
}
usage(B_FALSE);
}
}
@@ -6135,7 +6146,8 @@ zpool_do_status(int argc, char **argv)
print_timestamp(timestamp_fmt);
if (cmd != NULL)
cb.vcdl = all_pools_for_each_vdev_run(argc, argv, cmd);
cb.vcdl = all_pools_for_each_vdev_run(argc, argv, cmd,
NULL, NULL, 0, 0);
ret = for_each_pool(argc, argv, B_TRUE, NULL,
status_callback, &cb);