From patchwork Tue Oct 3 10:05:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982103 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 238C960365 for ; Tue, 3 Oct 2017 10:07:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DD74201B1 for ; Tue, 3 Oct 2017 10:07:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10649286E6; Tue, 3 Oct 2017 10:07:41 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham 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 05F0F286E6 for ; Tue, 3 Oct 2017 10:07:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751964AbdJCKHi (ORCPT ); Tue, 3 Oct 2017 06:07:38 -0400 Received: from mail-wm0-f42.google.com ([74.125.82.42]:53777 "EHLO mail-wm0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751880AbdJCKG4 (ORCPT ); Tue, 3 Oct 2017 06:06:56 -0400 Received: by mail-wm0-f42.google.com with SMTP id q132so15705076wmd.2 for ; Tue, 03 Oct 2017 03:06:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3P3H6zcn/UKfZJiWqcG9JfIRFSuZiKAlXkyPYtZcnn8=; b=HFhwHMNnpeSXvct9WuXqTUn3fxeWci43328Y3hyZo6DDsd1O38OaY1fMDJ2RZM+5Rd i/PaoxrTKuubjjJ6KQ0lGEo09ioBB15rsJsKx4iyp9sd5JaXITqvBzZPCFkaE1d3z9Ek YRLlDu5ikCkX+dPuakzmtMW/EpP2mBQU+pDLMUL1n4krjamigtD8irDR5zeoC6vMCZSw WFU4J1cCusfwUI8+yxjGGhVmyNaFGd5760F6FUrdB2pI2DrxJEbuY3sMgMNDejfJUGLr LbhRqBf9zGe6LsqILq6HjXrS3I0R63lAbdQZ/qVrzOMuiHAJ4gC/EwdCzxBFmNK5MQM5 ptSg== 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; bh=3P3H6zcn/UKfZJiWqcG9JfIRFSuZiKAlXkyPYtZcnn8=; b=PfbaP7Ig/YX57/4cwnVswaXOvVy8kwiYZdySnc7JNAGRHQU8qv28eFyzISLBJfr2w5 BSuMZoqhC1ZCZ1MhwgHWFdYp26OcO3xs1S6O4mcBto0GBMdOdYpns5uSTp4iMi56KYhg 0P97escKo+ULfZLsCjtmhtIwOrtmOqmWZ7B59SS/XKeFQWrInRBqSrXQ+V7wLDTD85Nb ErOAR46yM5g8P3r9Q1rD0lOLhblnDqzhMpO4vDFsRelUI/E0wtGd3UMEVnme8OBKawtu O7jD5/U/v3i1mzypYc0a5NPXKjXE/Z0QfMb2tZj7FOkze6p30VzFfYN5d5kQh55mu8P3 wV+A== X-Gm-Message-State: AHPjjUi+eJMfY+nNTyPuUkAWK2g7DmVafwZbMfoigVLTM3k1B1O9ZryP M5NAZfP1Wq7e0lwnTjSymVfN+A== X-Google-Smtp-Source: AOwi7QCX6PufVI1wz0sL/0UJWAvRNybCsHjZVBzlJ2BEsRhBdjKMCdDS4f2BUFKOf8BzKfT6K0AHUw== X-Received: by 10.80.193.130 with SMTP id m2mr23519267edf.209.1507025215626; Tue, 03 Oct 2017 03:06:55 -0700 (PDT) Received: from titan.cnexlabs.com (6164211-cl69.boa.fiberby.dk. [193.106.164.211]) by smtp.gmail.com with ESMTPSA id e50sm10594908ede.18.2017.10.03.03.06.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 03:06:55 -0700 (PDT) From: Hans Holmberg To: Matias Bjorling Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Gonzales , Hans Holmberg , Hans Holmberg Subject: [PATCH 7/9] lightnvm: pblk: add l2p crc debug printouts Date: Tue, 3 Oct 2017 12:05:11 +0200 Message-Id: <1507025113-13351-8-git-send-email-hans.ml.holmberg@owltronix.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1507025113-13351-1-git-send-email-hans.ml.holmberg@owltronix.com> References: <1507025113-13351-1-git-send-email-hans.ml.holmberg@owltronix.com> 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 Reviewed-by: Javier González --- 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 fb41182..c452478 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; - - if (pblk->ppaf_bitsize < 32) - entry_size = 4; + size_t map_size; - 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); @@ -898,6 +922,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); }