From patchwork Tue Oct 3 10:05:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Hans Holmberg X-Patchwork-Id: 9982099 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 95AEF60365 for ; Tue, 3 Oct 2017 10:07:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90A0F201B1 for ; Tue, 3 Oct 2017 10:07:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 856DD28885; Tue, 3 Oct 2017 10:07:32 +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.4 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, 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 1C128201B1 for ; Tue, 3 Oct 2017 10:07:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbdJCKHS (ORCPT ); Tue, 3 Oct 2017 06:07:18 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:50171 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751901AbdJCKG6 (ORCPT ); Tue, 3 Oct 2017 06:06:58 -0400 Received: by mail-wm0-f46.google.com with SMTP id b189so11675735wmd.4 for ; Tue, 03 Oct 2017 03:06:58 -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=cFrRZyfzPDkGT5cVax+bRRnT2t28/kB2kQ8OzTdp5eA=; b=CPcBXxvUt6JlZNqRLEzxsMoDSobLGJJdLz+CWmOGplZL31ea4mkrBVTLCu+kTwvMp3 UjBTQGBktwUXcf0tuq533ngSJRk3VRg3hpHxJTZmfNnhhIk28JcLqV1qVr2Sz0zxwy4D Pjo7SldST5u7hZcPXhLk3oX43HAt4caTUv/Wtygyix12oQqycStmW9172sNH0QcojkxV NCN+c/A+yQXfj3mWLfvW1hzSW7bL761HG5D1m81d+YLVWrggecjiGUBbtmFAEYXWVf2M Rvz1zHs4AxpOC3XybSk1swCUiINrWiG6Zhy1SwHRO34oq8hk9XYrl6VZywC3DSlYiVqy r0EQ== 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=cFrRZyfzPDkGT5cVax+bRRnT2t28/kB2kQ8OzTdp5eA=; b=sDFi867ELJLFKcZ14DCix2jGJvKQK9/VsQB41r4tBRy0EcZGfipFH7JvtI1zE/pGDc p3Ioonc1Sm81h81hrT5Y3Cdq9MbsKjCu4+9P/GlVu3rZ7Pf+uE+U15uZIJxKhI1bHxvR hJVxFm4Lg2qdX94lXm9s8v6+zCKdldBp3DJlEl8aXty0oOCSU0YqRxilw0U3zOWYB7lo 08FdglH32YxMnMta0ebcSMpwXXR9Btyub5WheE3IxqTiLy5gio0U3OopJK9Wsvswvz6w zH9tlRE7Dv+60AZIErBFK+8mfgFHUJhIn0JHGKKkYWvtZAwc10u/I7PFlfWQb0j3o9zH zbuQ== X-Gm-Message-State: AHPjjUjy062hoWS4eJ10Jj8KX2iURGAeFyc1MHlYSqhQMMHT/8y2Jq8L J9nGnlpZZPUie5P4PtEojSLicA== X-Google-Smtp-Source: AOwi7QAQ4RIPAXDzxB6yJYYSjntVzmBrnuzz0DmTvj05PHkBkI2cqlZmlzNSHM2LJA4eaB7UsL/3FQ== X-Received: by 10.80.142.179 with SMTP id w48mr23853957edw.215.1507025217637; Tue, 03 Oct 2017 03:06:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 03:06:57 -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 9/9] lightnvm: pblk: correct valid lba count calculation Date: Tue, 3 Oct 2017 12:05:13 +0200 Message-Id: <1507025113-13351-10-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 During garbage collect, lbas being written can end up being invalidated. Make sure that this is reflected in the valid lba count. Signed-off-by: Hans Holmberg Reviewed-by: Javier González --- drivers/lightnvm/pblk-map.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c index 3bc4c94..6f3ecde 100644 --- a/drivers/lightnvm/pblk-map.c +++ b/drivers/lightnvm/pblk-map.c @@ -45,6 +45,8 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry, paddr = pblk_alloc_page(pblk, line, nr_secs); for (i = 0; i < nr_secs; i++, paddr++) { + __le64 addr_empty = cpu_to_le64(ADDR_EMPTY); + /* ppa to be sent to the device */ ppa_list[i] = addr_to_gen_ppa(pblk, paddr, line->id); @@ -61,10 +63,9 @@ static void pblk_map_page_data(struct pblk *pblk, unsigned int sentry, w_ctx->ppa = ppa_list[i]; meta_list[i].lba = cpu_to_le64(w_ctx->lba); lba_list[paddr] = cpu_to_le64(w_ctx->lba); - line->nr_valid_lbas++; + if (lba_list[paddr] != addr_empty) + line->nr_valid_lbas++; } else { - __le64 addr_empty = cpu_to_le64(ADDR_EMPTY); - lba_list[paddr] = meta_list[i].lba = addr_empty; __pblk_map_invalidate(pblk, line, paddr); }