mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-27 04:32:16 +03:00
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:
committed by
Brian Behlendorf
parent
81eb8a1fbb
commit
1528bfdb14
+26
-4
@@ -360,7 +360,7 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
|
||||
vdev_cmd_data_list_t *vcdl = cb_vcdl;
|
||||
vdev_cmd_data_t *data;
|
||||
char *path = NULL;
|
||||
int i;
|
||||
int i, match = 0;
|
||||
|
||||
if (nvlist_lookup_string(nv, ZPOOL_CONFIG_PATH, &path) != 0)
|
||||
return (1);
|
||||
@@ -374,6 +374,19 @@ for_each_vdev_run_cb(zpool_handle_t *zhp, nvlist_t *nv, void *cb_vcdl)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for whitelisted vdevs here, if any */
|
||||
for (i = 0; i < vcdl->vdev_names_count; i++) {
|
||||
if (strcmp(vcdl->vdev_names[i], zpool_vdev_name(g_zfs, zhp, nv,
|
||||
vcdl->cb_name_flags)) == 0) {
|
||||
match = 1;
|
||||
break; /* match */
|
||||
}
|
||||
}
|
||||
|
||||
/* If we whitelisted vdevs, and this isn't one of them, then bail out */
|
||||
if (!match && vcdl->vdev_names_count)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Resize our array and add in the new element.
|
||||
*/
|
||||
@@ -437,19 +450,28 @@ all_pools_for_each_vdev_run_vcdl(vdev_cmd_data_list_t *vcdl)
|
||||
}
|
||||
|
||||
/*
|
||||
* Run command 'cmd' on all vdevs in all pools. Saves the first line of output
|
||||
* from the command in vcdk->data[].line for all vdevs.
|
||||
* Run command 'cmd' on all vdevs in all pools in argv. Saves the first line of
|
||||
* output from the command in vcdk->data[].line for all vdevs. If you want
|
||||
* to run the command on only certain vdevs, fill in g_zfs, vdev_names,
|
||||
* vdev_names_count, and cb_name_flags. Otherwise leave them as zero.
|
||||
*
|
||||
* Returns a vdev_cmd_data_list_t that must be freed with
|
||||
* free_vdev_cmd_data_list();
|
||||
*/
|
||||
vdev_cmd_data_list_t *
|
||||
all_pools_for_each_vdev_run(int argc, char **argv, char *cmd)
|
||||
all_pools_for_each_vdev_run(int argc, char **argv, char *cmd,
|
||||
libzfs_handle_t *g_zfs, char **vdev_names, int vdev_names_count,
|
||||
int cb_name_flags)
|
||||
{
|
||||
vdev_cmd_data_list_t *vcdl;
|
||||
vcdl = safe_malloc(sizeof (vdev_cmd_data_list_t));
|
||||
vcdl->cmd = cmd;
|
||||
|
||||
vcdl->vdev_names = vdev_names;
|
||||
vcdl->vdev_names_count = vdev_names_count;
|
||||
vcdl->cb_name_flags = cb_name_flags;
|
||||
vcdl->g_zfs = g_zfs;
|
||||
|
||||
/* Gather our list of all vdevs in all pools */
|
||||
for_each_pool(argc, argv, B_TRUE, NULL,
|
||||
all_pools_for_each_vdev_gather_cb, vcdl);
|
||||
|
||||
Reference in New Issue
Block a user