Skip to content

Commit

Permalink
Enhancements to zpool dry run mode.
Browse files Browse the repository at this point in the history
In dry run mode, zpool should display more of the proposed pool
configuration for "zpool add".  This commit adds support for displaying
cache devices.

Signed-off-by: Tim Chase <tim@chase2k.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#1106
  • Loading branch information
dweeezil authored and DeHackEd committed Apr 5, 2015
1 parent 3355110 commit 45e40aa
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ zpool_do_add(int argc, char **argv)

if (dryrun) {
nvlist_t *poolnvroot;
nvlist_t **l2child;
uint_t l2children, c;
char *vname;
boolean_t hadcache = B_FALSE;

verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
&poolnvroot) == 0);
Expand All @@ -612,6 +616,30 @@ zpool_do_add(int argc, char **argv)
print_vdev_tree(zhp, "logs", nvroot, 0, B_TRUE);
}

/* Do the same for the caches */
if (nvlist_lookup_nvlist_array(poolnvroot, ZPOOL_CONFIG_L2CACHE,
&l2child, &l2children) == 0 && l2children) {
hadcache = B_TRUE;
(void) printf(gettext("\tcache\n"));
for (c = 0; c < l2children; c++) {
vname = zpool_vdev_name(g_zfs, NULL,
l2child[c], B_FALSE);
(void) printf("\t %s\n", vname);
free(vname);
}
}
if (nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_L2CACHE,
&l2child, &l2children) == 0 && l2children) {
if (!hadcache)
(void) printf(gettext("\tcache\n"));
for (c = 0; c < l2children; c++) {
vname = zpool_vdev_name(g_zfs, NULL,
l2child[c], B_FALSE);
(void) printf("\t %s\n", vname);
free(vname);
}
}

ret = 0;
} else {
ret = (zpool_add(zhp, nvroot) != 0);
Expand Down

0 comments on commit 45e40aa

Please sign in to comment.