From patchwork Fri Nov 20 12:47:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 7667611 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 5949D9F1C2 for ; Fri, 20 Nov 2015 12:49:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 737FA2041B for ; Fri, 20 Nov 2015 12:49:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D97E20411 for ; Fri, 20 Nov 2015 12:49:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760156AbbKTMsh (ORCPT ); Fri, 20 Nov 2015 07:48:37 -0500 Received: from mail-wm0-f46.google.com ([74.125.82.46]:38670 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760113AbbKTMsI (ORCPT ); Fri, 20 Nov 2015 07:48:08 -0500 Received: by wmec201 with SMTP id c201so19696051wme.1 for ; Fri, 20 Nov 2015 04:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bjorling.me; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=S4Iabdp63cxgavRMWElGwol8PbFXuCNmxmHRKujudhE=; b=V3Ae/W2p6rTxfViENK2RUO+MEw7pkRtZNc2JqcchudnhE0cCmM5TBvQZhFj/lsO9dQ HPA5G7luMb01gja/4dwimibEhsAFsGH+VnC60xEI2MhvB1Nvk8NjnkT8koUmqkd20Zvv bPrxgyfGMIHImQIjbhH475UAR1z5DTwUnIu0g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=S4Iabdp63cxgavRMWElGwol8PbFXuCNmxmHRKujudhE=; b=NLmKHdOGOAbqTw1aaK/rGc67wGCFvS9ni5QWLfBKQ7ou20WFOSHZTOwl9D31QGYpL4 KiOh1Pvt9xidMo+p3fpFCZOR3LQSH5Es5iZ1F68XaE5k4LTXByZmxKp/prmJ8adK1SUh vD0G+024GdrhcRHzEgTjlUV19Y867/LGY3FwNAyep4ppfSAszu6VWG0NVM5PEmCXq73O kU8yOPQcUtIw/LJodPjWV03Fb9w1FyLxXNve4DPsBqk0mkZEvw3Goq07aICjIWZqdAtH KiyiG8xit+oYICDM/uuV/w/slnBRE8Kn94BBojGWk6Mn90BPb/W4PgveKxx2Yo1TnxgH oJ1A== X-Gm-Message-State: ALoCoQlAsE0l8qCJkyMXlA6YidAd5mb3p3rmAqPVdrReGTUDnWonfZZUxFIHHj0t7zGQ4YnT0axk X-Received: by 10.194.134.3 with SMTP id pg3mr14122777wjb.63.1448023687617; Fri, 20 Nov 2015 04:48:07 -0800 (PST) Received: from localhost.localdomain (6164198-cl69.boa.fiberby.dk. [193.106.164.198]) by smtp.gmail.com with ESMTPSA id bh5sm12522435wjb.42.2015.11.20.04.48.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 20 Nov 2015 04:48:07 -0800 (PST) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, axboe@fb.com Cc: Javier Gonzalez , Javier Gonzalez , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 5/5] lightnvm: add free and bad lun info to show luns Date: Fri, 20 Nov 2015 13:47:57 +0100 Message-Id: <1448023677-22296-6-git-send-email-m@bjorling.me> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1448023677-22296-1-git-send-email-m@bjorling.me> References: <1448023677-22296-1-git-send-email-m@bjorling.me> MIME-Version: 1.0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Javier Gonzalez Add free block, used block, and bad block information to the show debug interface. This information is used to debug how targets track blocks. Also, change debug function name to make it more generic. Signed-off-by: Javier Gonzalez Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 2 +- drivers/lightnvm/gennvm.c | 19 ++++++++++++++----- include/linux/lightnvm.h | 4 ++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index f61d325..5178645 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -544,7 +544,7 @@ static int nvm_configure_show(const char *val) if (!dev->mt) return 0; - dev->mt->free_blocks_print(dev); + dev->mt->lun_info_print(dev); return 0; } diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 43c01e0..e20e74e 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -464,15 +464,24 @@ static struct nvm_lun *gennvm_get_lun(struct nvm_dev *dev, int lunid) return &gn->luns[lunid].vlun; } -static void gennvm_free_blocks_print(struct nvm_dev *dev) +static void gennvm_lun_info_print(struct nvm_dev *dev) { struct gen_nvm *gn = dev->mp; struct gen_lun *lun; unsigned int i; - gennvm_for_each_lun(gn, lun, i) - pr_info("%s: lun%8u\t%u\n", - dev->name, i, lun->vlun.nr_free_blocks); + + gennvm_for_each_lun(gn, lun, i) { + spin_lock(&lun->vlun.lock); + + pr_info("%s: lun%8u\t%u\t%u\t%u\n", + dev->name, i, + lun->vlun.nr_free_blocks, + lun->vlun.nr_inuse_blocks, + lun->vlun.nr_bad_blocks); + + spin_unlock(&lun->vlun.lock); + } } static struct nvmm_type gennvm = { @@ -490,7 +499,7 @@ static struct nvmm_type gennvm = { .erase_blk = gennvm_erase_blk, .get_lun = gennvm_get_lun, - .free_blocks_print = gennvm_free_blocks_print, + .lun_info_print = gennvm_lun_info_print, }; static int __init gennvm_module_init(void) diff --git a/include/linux/lightnvm.h b/include/linux/lightnvm.h index 831a20c..3db5552 100644 --- a/include/linux/lightnvm.h +++ b/include/linux/lightnvm.h @@ -380,7 +380,7 @@ typedef int (nvmm_end_io_fn)(struct nvm_rq *, int); typedef int (nvmm_erase_blk_fn)(struct nvm_dev *, struct nvm_block *, unsigned long); typedef struct nvm_lun *(nvmm_get_lun_fn)(struct nvm_dev *, int); -typedef void (nvmm_free_blocks_print_fn)(struct nvm_dev *); +typedef void (nvmm_lun_info_print_fn)(struct nvm_dev *); struct nvmm_type { const char *name; @@ -404,7 +404,7 @@ struct nvmm_type { nvmm_get_lun_fn *get_lun; /* Statistics */ - nvmm_free_blocks_print_fn *free_blocks_print; + nvmm_lun_info_print_fn *lun_info_print; struct list_head list; };