From 5f20c145df3ca45f86cd1892137edb117d4c8a82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kan=20Johansson?= Date: Thu, 1 Dec 2016 01:46:16 +0100 Subject: [PATCH] Do not force VDEV_NAME_TYPE_ID in max_width() Do not force VDEV_NAME_TYPE_ID in max_width(), instead add it in the relevant calls to max_width(). The first location of max_width() where VDEV_NAME_TYPE_ID is now added in show_import() is followed by print_import_config() and print_logs(). Both these print children vdev names that have been retrieved using an explicit VDEV_NAME_TYPE_ID added. The second location is in status_callback(). This is followed by print_status_config(), print_logs(), print_l2cache(), and print_spares(). For l2cache and spares it should not matter as there are no mirror-X or raidz-X involved. print_status_config() as above retrieves the name using explicit VDEV_NAME_TYPE_ID before calling itself to print children. The call of max_width() in get_namewidth() is not changed, as this is used by zpool_do_iostat(), followed by print_iostat(), which does not add VDEV_NAME_TYPE_ID. Overall, we should consider adding VDEV_NAME_TYPE_ID to the relevant name_flags / cb_name_flags fields, and remove the explicit adding in called routines. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: Haakan T Johansson Closes #5401 --- cmd/zpool/zpool_main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index e50acbd2ad..0216484b55 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -1422,7 +1422,7 @@ max_width(zpool_handle_t *zhp, nvlist_t *nv, int depth, int max, uint_t c, children; int ret; - name = zpool_vdev_name(g_zfs, zhp, nv, name_flags | VDEV_NAME_TYPE_ID); + name = zpool_vdev_name(g_zfs, zhp, nv, name_flags); if (strlen(name) + depth > max) max = strlen(name) + depth; @@ -2066,7 +2066,7 @@ show_import(nvlist_t *config) (void) printf(gettext(" config:\n\n")); - cb.cb_namewidth = max_width(NULL, nvroot, 0, 0, 0); + cb.cb_namewidth = max_width(NULL, nvroot, 0, 0, VDEV_NAME_TYPE_ID); if (cb.cb_namewidth < 10) cb.cb_namewidth = 10; @@ -5995,7 +5995,7 @@ status_callback(zpool_handle_t *zhp, void *data) print_scan_status(ps); cbp->cb_namewidth = max_width(zhp, nvroot, 0, 0, - cbp->cb_name_flags); + cbp->cb_name_flags | VDEV_NAME_TYPE_ID); if (cbp->cb_namewidth < 10) cbp->cb_namewidth = 10;