From patchwork Thu May 11 22:01:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9723201 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ADA6B601E7 for ; Thu, 11 May 2017 22:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AB60028724 for ; Thu, 11 May 2017 22:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E6342873A; Thu, 11 May 2017 22:07:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D5E1D28724 for ; Thu, 11 May 2017 22:07:33 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C5EC721A04E20; Thu, 11 May 2017 15:07:33 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 8BB5721A16E28 for ; Thu, 11 May 2017 15:07:32 -0700 (PDT) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 May 2017 15:07:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,326,1491289200"; d="scan'208";a="855723149" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by FMSMGA003.fm.intel.com with ESMTP; 11 May 2017 15:07:32 -0700 Subject: [ndctl PATCH 3/4] ndctl, list: fix span for btt badblocks check From: Dan Williams To: linux-nvdimm@lists.01.org Date: Thu, 11 May 2017 15:01:40 -0700 Message-ID: <149454010081.30857.7934265050481005763.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <149454009049.30857.6643219237076670086.stgit@dwillia2-desk3.amr.corp.intel.com> References: <149454009049.30857.6643219237076670086.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP 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 Cc: Vishal Verma Cc: Toshi Kani Signed-off-by: Dan Williams --- util/json.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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,