diff mbox

[ndctl,3/4] ndctl, list: fix span for btt badblocks check

Message ID 149454010081.30857.7934265050481005763.stgit@dwillia2-desk3.amr.corp.intel.com (mailing list archive)
State Accepted
Commit ed15d291cf34
Headers show

Commit Message

Dan Williams May 11, 2017, 10:01 p.m. UTC
The size returned by ndctl_btt_get_size() accounts for space consumed by
metadata or otherwise lost to sector size geometry. For the
'badblock_count' property all we can do is report a count of possible
badblocks which may be larger than actual badblocks impacting live data.
Use the raw namespace size for this check.

Cc: Dave Jiang <dave.jiang@intel.com>
Cc: Vishal Verma <vishal.l.verma@intel.com>
Cc: Toshi Kani <toshi.kani@hpe.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 util/json.c |   13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)
diff mbox

Patch

diff --git a/util/json.c b/util/json.c
index f72ffca910ae..17595267c34c 100644
--- a/util/json.c
+++ b/util/json.c
@@ -379,14 +379,14 @@  static void util_btt_badblocks_to_json(struct ndctl_btt *btt,
 {
 	struct ndctl_region *region = ndctl_btt_get_region(btt);
 	struct ndctl_namespace *ndns = ndctl_btt_get_namespace(btt);
-	unsigned long long btt_begin, btt_size;
+	unsigned long long begin, size;
 
-	btt_begin = ndctl_namespace_get_resource(ndns);
-	if (btt_begin == ULLONG_MAX)
+	begin = ndctl_namespace_get_resource(ndns);
+	if (begin == ULLONG_MAX)
 		return;
 
-	btt_size = ndctl_btt_get_size(btt);
-	if (btt_size == ULLONG_MAX)
+	size = ndctl_namespace_get_size(ndns);
+	if (size == ULLONG_MAX)
 		return;
 
 	/*
@@ -397,8 +397,7 @@  static void util_btt_badblocks_to_json(struct ndctl_btt *btt,
 	 * FIXME: switch to native BTT badblocks representation
 	 * when / if the kernel provides it.
 	 */
-	dev_badblocks_to_json(region, btt_begin, btt_size,
-			false, bb_count);
+	dev_badblocks_to_json(region, begin, size, false, bb_count);
 }
 
 static struct json_object *util_dax_badblocks_to_json(struct ndctl_dax *dax,