From e02b533e746403743297020591e4b80d614a3aae Mon Sep 17 00:00:00 2001 From: Tim Chase Date: Tue, 22 Oct 2013 16:51:17 -0500 Subject: Enhancements to zpool dry run mode. 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 Signed-off-by: Brian Behlendorf Issue #1106 --- cmd/zpool/zpool_main.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'cmd/zpool') diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 0f2bab6e9..9e37eb228 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -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); @@ -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); -- cgit v1.2.3