]> granicus.if.org Git - zfs/commitdiff
Enhancements to zpool dry run mode.
authorTim Chase <tim@chase2k.com>
Tue, 22 Oct 2013 21:51:17 +0000 (16:51 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 11 Feb 2015 22:05:17 +0000 (14:05 -0800)
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 #1106

cmd/zpool/zpool_main.c

index 0f2bab6e925c724c46dfb975447afb15fdb3e367..9e37eb228a6fee97a7596983804b9ff9a85fec9a 100644 (file)
@@ -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);