From 1ca56e603395b2d84c8043d5ff18f2082f57e6f1 Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Thu, 4 Sep 2014 23:06:55 -0700 Subject: [PATCH] Fragmentation should display as '-' if spacemap_histogram=disabled When com.delphix:spacemap_histogram is disabled, the value of fragmentation was printing as 18446744073709551615 (UINT64_MAX), when it should print as '-'. The issue was caused by a small mistake during the merge of "4980 metaslabs should have a fragmentation metric." upstream: https://github.com/illumos/illumos-gate/commit/2e4c998 ZoL: https://github.com/zfsonlinux/zfs/commit/f3a7f66 The problem is in zpool_get_prop_literal, where the handling of the pool property ZPOOL_PROP_FRAGMENTATION was added to wrong the section. In particular, ZPOOL_PROP_FRAGMENTATION should not be in the section where zpool_get_state(zhp) == POOL_STATE_UNAVAIL, but lower down after it's already been determined that the pool is in fact available, which is where upstream illumos correctly has had it. Thanks to lundman for helping to track down this bug. Signed-off-by: Jorgen Lundman Signed-off-by: Tim Chase Signed-off-by: Brian Behlendorf Closes #2664 --- lib/libzfs/libzfs_pool.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 5be231f77..d50b9c9cc 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -274,15 +274,6 @@ zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, intval = zpool_get_prop_int(zhp, prop, &src); (void) snprintf(buf, len, "%llu", (u_longlong_t)intval); break; - case ZPOOL_PROP_FRAGMENTATION: - intval = zpool_get_prop_int(zhp, prop, &src); - if (intval == UINT64_MAX) { - (void) strlcpy(buf, "-", len); - } else { - (void) snprintf(buf, len, "%llu%%", - (u_longlong_t)intval); - } - break; case ZPOOL_PROP_ALTROOT: case ZPOOL_PROP_CACHEFILE: @@ -340,6 +331,15 @@ zpool_get_prop_literal(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, (u_longlong_t)intval); break; + case ZPOOL_PROP_FRAGMENTATION: + if (intval == UINT64_MAX) { + (void) strlcpy(buf, "-", len); + } else { + (void) snprintf(buf, len, "%llu%%", + (u_longlong_t)intval); + } + break; + case ZPOOL_PROP_DEDUPRATIO: (void) snprintf(buf, len, "%llu.%02llux", (u_longlong_t)(intval / 100),