From patchwork Fri Oct 13 12:46:40 2017 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: 10004501 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 A27DE6037E for ; Fri, 13 Oct 2017 12:51:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 959DD29060 for ; Fri, 13 Oct 2017 12:51:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A60529068; Fri, 13 Oct 2017 12:51:31 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E71829060 for ; Fri, 13 Oct 2017 12:51:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758514AbdJMMvB (ORCPT ); Fri, 13 Oct 2017 08:51:01 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:56357 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932368AbdJMMr4 (ORCPT ); Fri, 13 Oct 2017 08:47:56 -0400 Received: by mail-wm0-f66.google.com with SMTP id l68so21514260wmd.5 for ; Fri, 13 Oct 2017 05:47:55 -0700 (PDT) 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-transfer-encoding; bh=zm2rmK2Bqt1purIT8bs5UD1dFc6XSP4rzPmgKBiDLko=; b=ErlP5OlOr7kVeJljnI0OYlo2YaVeuZI6DaS4HKNUKazGYnWyBfy9TLmRtkVvinSMjx xFLntakfUpwIYZogijgdhLtFjfWQ7bXXF/JkJGo3yN+3FDIed4pkgU55g2zbrLydonr/ HBS3ys4F06BhvwJhPiC9JhDulK8+hskGe5wfA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zm2rmK2Bqt1purIT8bs5UD1dFc6XSP4rzPmgKBiDLko=; b=TEd/aQkSVjjrK3XWV2SS99tZaVEtzaLdC9Ox1tncwCLJKB02o/nYQit8dT+pIAgeha t1qRsII55b3UCyEXaJtomaOdbwtTbEZYiwBEVksvOUEsMa/Kwpb3oISaUDmkxto6I3wo wAOJJJ6myreN5bvzwy4MfZCXR7r4ZNr3lAyoWxjY10Pmwyh320qF6ECvpTWCWDHS+yKi SY7b5mN11LL9wU5aIAttNx7WHEXLnnuqh/BzjkPaAZiqrP6BitPoxISHiCXne4QGG8YS Bg9k+H/H0gTAgKZI5G4CPB81+/u2HyitQ2k1mPkswETEephdVFS5S5ZTUOZPK5TQE6su y1AA== X-Gm-Message-State: AMCzsaVT4ZOQLQQ/CoPq+Fpl2UT+rOOHKDP96hs2hww6ADQM0w/mDaJx ZT1yDZjG8J3gTAKbC1QMpYmaUw== X-Google-Smtp-Source: AOwi7QBwLX/mWR3IGMvxs5O9jL2Q/5uKocnp+Xpf8AYuVkfTwypDWqfs9oZ914wOYP8PWzswX5MHRw== X-Received: by 10.80.151.211 with SMTP id f19mr2012749edb.141.1507898875310; Fri, 13 Oct 2017 05:47:55 -0700 (PDT) Received: from skyninja.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id p91sm735012edp.69.2017.10.13.05.47.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:54 -0700 (PDT) From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [GIT PULL 51/58] lightnvm: pblk: add l2p crc debug printouts Date: Fri, 13 Oct 2017 14:46:40 +0200 Message-Id: <20171013124647.32668-52-m@bjorling.me> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20171013124647.32668-1-m@bjorling.me> References: <20171013124647.32668-1-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-Virus-Scanned: ClamAV using ClamSMTP From: Hans Holmberg Print the CRC of the logical-to-physical mapping during exit and after recovering the L2P table to facilitate detection of meta data corruption/recovery issues. The CRC printed after recovery should match the CRC printed during the previous exit - if it doesn't this indicates that either the meta data written to the disk is corrupt or recovery failed. Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-init.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index ad9f014..52c85f4 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -76,6 +76,28 @@ static blk_qc_t pblk_make_rq(struct request_queue *q, struct bio *bio) return BLK_QC_T_NONE; } +static size_t pblk_trans_map_size(struct pblk *pblk) +{ + int entry_size = 8; + + if (pblk->ppaf_bitsize < 32) + entry_size = 4; + + return entry_size * pblk->rl.nr_secs; +} + +#ifdef CONFIG_NVM_DEBUG +static u32 pblk_l2p_crc(struct pblk *pblk) +{ + size_t map_size; + u32 crc = ~(u32)0; + + map_size = pblk_trans_map_size(pblk); + crc = crc32_le(crc, pblk->trans_map, map_size); + return crc; +} +#endif + static void pblk_l2p_free(struct pblk *pblk) { vfree(pblk->trans_map); @@ -85,12 +107,10 @@ static int pblk_l2p_init(struct pblk *pblk) { sector_t i; struct ppa_addr ppa; - int entry_size = 8; + size_t map_size; - if (pblk->ppaf_bitsize < 32) - entry_size = 4; - - pblk->trans_map = vmalloc(entry_size * pblk->rl.nr_secs); + map_size = pblk_trans_map_size(pblk); + pblk->trans_map = vmalloc(map_size); if (!pblk->trans_map) return -ENOMEM; @@ -508,6 +528,10 @@ static int pblk_lines_configure(struct pblk *pblk, int flags) } } +#ifdef CONFIG_NVM_DEBUG + pr_info("pblk init: L2P CRC: %x\n", pblk_l2p_crc(pblk)); +#endif + /* Free full lines directly as GC has not been started yet */ pblk_gc_free_full_lines(pblk); @@ -901,6 +925,11 @@ static void pblk_exit(void *private) down_write(&pblk_lock); pblk_gc_exit(pblk); pblk_tear_down(pblk); + +#ifdef CONFIG_NVM_DEBUG + pr_info("pblk exit: L2P CRC: %x\n", pblk_l2p_crc(pblk)); +#endif + pblk_free(pblk); up_write(&pblk_lock); }