From patchwork Fri Oct 13 12:46:42 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: 10004489 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 5B31060216 for ; Fri, 13 Oct 2017 12:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E41B29081 for ; Fri, 13 Oct 2017 12:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4362529074; Fri, 13 Oct 2017 12:50:40 +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 D5CC72907E for ; Fri, 13 Oct 2017 12:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758327AbdJMMuK (ORCPT ); Fri, 13 Oct 2017 08:50:10 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:56362 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932391AbdJMMr6 (ORCPT ); Fri, 13 Oct 2017 08:47:58 -0400 Received: by mail-wm0-f67.google.com with SMTP id l68so21514528wmd.5 for ; Fri, 13 Oct 2017 05:47:57 -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=6Hd72K9nfbVa6Ef5FGtYY7gQsbD+3vFFs/3sZ7Us6LI=; b=yp36sA4Jx1h5VRmoyjdFx7ruCeu5mM97+1wqzpYQnP5i/806PHt0UR5uy/pUvm+rtt HsTD7Lea56dm5XrkvJTgcLAMRXfymgPrxacclJ5AEelUlF9mmbZ8P56YHsCxaoMmqfy1 TqtXdWefrPNGn9Tfh6g0SFx8YR/s0qjF9LIxY= 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=6Hd72K9nfbVa6Ef5FGtYY7gQsbD+3vFFs/3sZ7Us6LI=; b=YP5fNBZ78R1YV4YpU2KK9JvTtnhidJQh9bPIjsSXe2Re3JDaGOhZOprPwUhKrzGrwT /2Kr2JVfPaH49JTAJhyzgXyBTni7v1fTLCd8wZgkzIM2NnZjSIWYxyRBBhFSV9v8JM07 DOeb5qdy8t1RYrvBijFN20vwB7WMHvaWLWw4vSpyAq6OMip3KAh6DgRXAt1Cvm87Jn1B 432BWgGTDIWseXVnX3jecAsvLsvVbp6IEouLYF6WBbMn/uKFyz7G0NHVYCPqcFf5dL1y DxcqwCZ9McimIU3Vue2fw/x2TzrymdLbD6lo50VOUWOOJ8Appp1GArtYaQpjNuISMgcQ EChg== X-Gm-Message-State: AMCzsaV7fTWg8cd6wf+HM4C/cvOYuUoUbAHnBNXl4cx15Qiae8T8qR3P WJ9DDgmrp69UJuVIHDPtbmx/RA== X-Google-Smtp-Source: AOwi7QAAv6OaSmmYWk1L1qAPlYMVmC0jGz6Acs14DxnXeQK9oBMC0lqqbDXfjr8bTXYyxKJeva4q4Q== X-Received: by 10.80.166.133 with SMTP id e5mr1985834edc.51.1507898877144; Fri, 13 Oct 2017 05:47:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 13 Oct 2017 05:47:56 -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 53/58] lightnvm: pblk: correct valid lba count calculation Date: Fri, 13 Oct 2017 14:46:42 +0200 Message-Id: <20171013124647.32668-54-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 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 Signed-off-by: Matias Bjørling --- 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); }