From patchwork Mon Feb 11 12:25:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805569 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABC1713BF for ; Mon, 11 Feb 2019 12:25:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC97285A8 for ; Mon, 11 Feb 2019 12:25:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FD4528BA0; Mon, 11 Feb 2019 12:25:22 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 31374285A8 for ; Mon, 11 Feb 2019 12:25:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727305AbfBKMZU (ORCPT ); Mon, 11 Feb 2019 07:25:20 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34534 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbfBKMZT (ORCPT ); Mon, 11 Feb 2019 07:25:19 -0500 Received: by mail-lf1-f68.google.com with SMTP id u21so2127983lfu.1 for ; Mon, 11 Feb 2019 04:25:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KPfj6O2aC060Aqi37cieoJdRqiRZa7RZ5+dNEdZ/P94=; b=1bj/j4qvjt92z2YEKndx3N/g6jFbxGaZJ7pCGJf/pl0Ul3ogiiUjttyADP2GErlMuY brvWbrLgR1YlLiScjSGyHuUa6XKrg1q+cQKIowPryuYh1Qn6wv9AZdk68yRUTYQGaPTc 2y0F/oaEh5cclchgFjrrd421BIIgHUp7W8BaNF7MSklfLWlgs7zW3G7mYctncr4jUKJq Kbm8yRQdrwQEIHrNSy9srlRyBbJLqm5UzIySHHDc0gVC5Cy6iFK/abEvXRwLmXOsMjxH IMHygEwX8IRSIge6RttFv1io1HFodXqLYM1D3n31Vf4jLv/Fugf7KeAXOn5b1ExjN6cb GQ5Q== 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=KPfj6O2aC060Aqi37cieoJdRqiRZa7RZ5+dNEdZ/P94=; b=ClAmMdW9eikr8rplAiOh4XDVHv6JY6HTCknn0n4F3MxhD0tVzx3cyLkymcREGGZ0Qx JuDD8HXXjdqE+kIwIugNZwcjGXe8NY3j/CHQBFkgN5maCCuhHpvgcRRtMe3QIEhkVd5i 5ztGQrSfgpRhZj2DgfwNFdozn5PdGKJChL/0rn7tZUIyXpmvHd/7Z+m2LlepYp5MVQfq RGhKEgJ7iXkODinkZMw0YsccizuAbq32B6/lIue0dKnOACu3YZc3/i2L04FPDdpWVVm2 LV6He2dMFBNOyhe9w42R3FChjH3zB8YIOCw/5KmEnLlagVitnoq7rxHm5A34uDQ1thZT 0iQg== X-Gm-Message-State: AHQUAuab5Jiedqpu3wV3K2TUSB7fLWIbua0naqfuBCq0mflCM2WzcTJe HywUMXPFS5YY4pXDODWnlRelyA== X-Google-Smtp-Source: AHgI3Ib6zsrnmy/UsnGMsHx8SinEpiwhMUQqjeMu5ETC9jQVXPbXZgTd+5HeQPgwocZuinsuhxpbMg== X-Received: by 2002:ac2:4343:: with SMTP id o3mr19806315lfl.129.1549887917145; Mon, 11 Feb 2019 04:25:17 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:16 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 1/8] lightnvm: pblk: stop taking the free lock in in pblk_lines_free Date: Mon, 11 Feb 2019 13:25:02 +0100 Message-Id: <20190211122509.19910-2-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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 pblk_line_meta_free might sleep (it can end up calling vfree, depending on how we allocate lba lists), and this can lead to a BUG() if we wake up on a different cpu and release the lock. As there is no point of grabbing the free lock when pblk has shut down, remove the lock. Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-init.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index f9a3e47b6a93..eb0135c77805 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -584,14 +584,12 @@ static void pblk_lines_free(struct pblk *pblk) struct pblk_line *line; int i; - spin_lock(&l_mg->free_lock); for (i = 0; i < l_mg->nr_lines; i++) { line = &pblk->lines[i]; pblk_line_free(line); pblk_line_meta_free(l_mg, line); } - spin_unlock(&l_mg->free_lock); pblk_line_mg_free(pblk); From patchwork Mon Feb 11 12:25:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E5DE917E0 for ; Mon, 11 Feb 2019 12:26:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE5212A15D for ; Mon, 11 Feb 2019 12:26:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C28A72A163; Mon, 11 Feb 2019 12:26:05 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 B8BFF2A155 for ; Mon, 11 Feb 2019 12:26:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727280AbfBKM0E (ORCPT ); Mon, 11 Feb 2019 07:26:04 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39554 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727281AbfBKMZU (ORCPT ); Mon, 11 Feb 2019 07:25:20 -0500 Received: by mail-lj1-f193.google.com with SMTP id v12-v6so3850156ljc.6 for ; Mon, 11 Feb 2019 04:25:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aPqNfQfc1x7Ctx+Hrva5vIaSgQJbQvQq7LNoEgp6zBs=; b=XTK1ndTuzO9MANc3qb+2im7yByKWCMX3ge+mWO5pzGVkpwprpwSmohjsTEEW5kMDap BrsU6SCHss4pStE9FLL9oHQ7JUmlETI6aY0a3M7PkbU5wK7IRs73ZDVvX/p1Hv7s5/7/ URcpggj/hOfyFmBaZH5441VUsLGWAOOQXiqib8jfDgO6wtmM2V9buvp+QJzR0xbTxXn6 YwG6adZcCv+NXzPvtzREyVSlstQrXRavPjkOojgkimCiC9/lRU1oEEkkZsnu3feyncoX Vm/ukWS9PpJIuFH2BPqnUowRyHZw4XYix5ac1SOo8XDQLO0Bn/9A5OiGPaeoTDpv98mV 6emw== 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=aPqNfQfc1x7Ctx+Hrva5vIaSgQJbQvQq7LNoEgp6zBs=; b=MtMTfJ1RYWNceLUU7KUz2CUOjZGKxaalzcjaw1rVW1QxFwHB7ALPbYr4kG9SboG0yW JoqI9wZvUzV8q8aFeIoyoXtHbZh+Isnut4D7BGFWslgXwBm5IHk/TnNGIM4OUNGf0HLK h6WC0NVIHy0TTJEMRwSvC9zyRu89G2oKH7wF3EUMBP+ni9YzHmqdIBdCp1JcGn6wLtv3 dlO24XVq7wGB358SPzor5LWfxfe9Ynu3hIQWnJhMYuZCIXLwUnNMyUHlerQtBEHfVCq/ tSmK8OPzdq2LafrHMkGItTf/FtHW+vST8LbBEnxfrnk6b/UpcmxVExDmBuvzCP/eFi/+ 4KCQ== X-Gm-Message-State: AHQUAuYhpmdvOmt/YlIOH23If/30scHzTzDKFfM0pyC2mgaHwd3mHz+G k3qImHC9lxTLwK4gPkGz8LTIRg== X-Google-Smtp-Source: AHgI3IYx5x5MagVlcrHSOfbNqh+KmAib2TjETzeyEeQP9W5L1l1Bl6/t0Ut89x2xO6fanMv65iyK4Q== X-Received: by 2002:a2e:3603:: with SMTP id d3-v6mr21153964lja.46.1549887918637; Mon, 11 Feb 2019 04:25:18 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:17 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 2/8] lightnvm: pblk: use vfree to free metadata on error path Date: Mon, 11 Feb 2019 13:25:03 +0100 Message-Id: <20190211122509.19910-3-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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 As chunk metadata is allocated using vmalloc, we need to free it using vfree. Fixes: 090ee26fd512 ("lightnvm: use internal allocation for chunk log page") Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 1ff165351180..1b5ff51faa63 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -141,7 +141,7 @@ struct nvm_chk_meta *pblk_get_chunk_meta(struct pblk *pblk) ret = nvm_get_chunk_meta(dev, ppa, geo->all_chunks, meta); if (ret) { - kfree(meta); + vfree(meta); return ERR_PTR(-EIO); } From patchwork Mon Feb 11 12:25:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805581 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CE4C217E0 for ; Mon, 11 Feb 2019 12:26:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BCFE42A157 for ; Mon, 11 Feb 2019 12:26:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A6EC528F39; Mon, 11 Feb 2019 12:26:03 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 3E5382A157 for ; Mon, 11 Feb 2019 12:26:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727327AbfBKMZY (ORCPT ); Mon, 11 Feb 2019 07:25:24 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44640 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727318AbfBKMZX (ORCPT ); Mon, 11 Feb 2019 07:25:23 -0500 Received: by mail-lj1-f194.google.com with SMTP id a16so4463021ljb.11 for ; Mon, 11 Feb 2019 04:25:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P5r+7TNRpT4IOWYOkJ4Od3nYrWD71FZGJYmKpbNhmMc=; b=hWGNlgok/Afol8f4prcEdIM03knAXuUS0vPIR4Hals6x65dhEhbnf2mQ1g/bMijxYo w/bDGAcgT3GK9B3tKPICceWVw6KsFTqmyLhweCa8nYGhjA22iGcI+4+nTajupEJ8mznq JcH3K71jvHWI3FDygU3iy2n4HluzEsWWXVcOLhnehicnOmJjdRE0MyO9Tz2rb1dheBBE JGwMvzTvuabjkd4RHxiQRVrFBMGexU+0UQqkQGaQhfz02iBIW9PHbj49AiPQ0nY9ZO93 68WdUOV2nx+V+ygfEwP7qjyKHz/y9QdvTPpyT62SiFpM8TaGJa1EdzNNhQYrQIPKcr+6 pJCg== 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=P5r+7TNRpT4IOWYOkJ4Od3nYrWD71FZGJYmKpbNhmMc=; b=t3koqk2NOHjWoIRXG4NJp9QzmPlrN1CZUXQj94al7T3x5dgqakZv1j//0ad3Gx9yLP fU0QSXhGWhYT3H73Gs5grj5elGrk+9+haf7XewEBMBfYaGaAQNvn1NOPJ9Y2LZj9g3aU rm6iXDG7tr/FLpFuqyGoJPD68giCMwpIzM7MAMggzwFe2I4/gkj7HxsXNoMV3zg7GGrH gjK2urC1CgXR5OwrwLmiAIl3VXyxuSMGzw+qCfOS+MczpwXVClU/E4EgW2I0MJnWN8y8 7ryquzkTuu/4pnstW3ZguK1sb9LF5mjheV2z1uoBDARqNti8bnyzL15B0q5q27YlLZNE 696g== X-Gm-Message-State: AHQUAuZ7ThgJC2qC2ZaqnWcqaRQ7V6jmagV7dWn2nTXnDFnB0Ji/Pgzn boe6mPoB2YcIuxAPS9Mb8Y+IOQ== X-Google-Smtp-Source: AHgI3IaCLBCua02CbzvdHEmPu3Nkd8IDEQ+Yxcn2u6gB8rwYt+beBOVndsaXB+ZEI2VSY/caHhqSkg== X-Received: by 2002:a2e:2416:: with SMTP id k22-v6mr8066565ljk.80.1549887921125; Mon, 11 Feb 2019 04:25:21 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:18 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , =?utf-8?q?Matias_Bj?= =?utf-8?q?=C3=B8rling?= Subject: [GIT PULL 3/8] lightnvm: Use u64 instead of __le64 for CPU visible side Date: Mon, 11 Feb 2019 13:25:04 +0100 Message-Id: <20190211122509.19910-4-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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: Andy Shevchenko Sparse complains about using strict data types: drivers/lightnvm/pblk-read.c:254:43: warning: incorrect type in assignment (different base types) drivers/lightnvm/pblk-read.c:254:43: expected restricted __le64 drivers/lightnvm/pblk-read.c:254:43: got unsigned long long [unsigned] [usertype] drivers/lightnvm/pblk-read.c:255:29: warning: cast from restricted __le64 drivers/lightnvm/pblk-read.c:268:29: warning: cast from restricted __le64 drivers/lightnvm/pblk-read.c:328:41: warning: incorrect type in assignment (different base types) drivers/lightnvm/pblk-read.c:328:41: expected restricted __le64 drivers/lightnvm/pblk-read.c:328:41: got unsigned long long [unsigned] [usertype] In the code it seems explicit that lba_list_mem and lba_list_media members of struct pblk_pr_ctx are used on CPU side, which means they should not be of strict types. Change types of lba_list_mem and lba_list_media members to be u64. Signed-off-by: Andy Shevchenko Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 85e38ed62f85..0dd697ea201e 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -131,8 +131,8 @@ struct pblk_pr_ctx { unsigned int bio_init_idx; void *ppa_ptr; dma_addr_t dma_ppa_list; - __le64 lba_list_mem[NVM_MAX_VLBA]; - __le64 lba_list_media[NVM_MAX_VLBA]; + u64 lba_list_mem[NVM_MAX_VLBA]; + u64 lba_list_media[NVM_MAX_VLBA]; }; /* Pad context */ From patchwork Mon Feb 11 12:25:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 41B8B17E0 for ; Mon, 11 Feb 2019 12:25:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A7B7285A8 for ; Mon, 11 Feb 2019 12:25:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F0D528BA0; Mon, 11 Feb 2019 12:25:30 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 9DC0A285A8 for ; Mon, 11 Feb 2019 12:25:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727348AbfBKMZ1 (ORCPT ); Mon, 11 Feb 2019 07:25:27 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:36852 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727333AbfBKMZ1 (ORCPT ); Mon, 11 Feb 2019 07:25:27 -0500 Received: by mail-lj1-f193.google.com with SMTP id g11-v6so8601405ljk.3 for ; Mon, 11 Feb 2019 04:25:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=u99sfZGMW+gKwnhlHoCgtcN3E+Mx1BLTxSFc1sUIIAQ=; b=OeTqf7vwVFPb4XWTOINv2Nkr1BygqM1y3N6yQWHuu1MSTXIDLvWOsn7ZFiDSeuSar8 UrNO9siXy9X6UpnwJ9qANneuy9rASLM12VE58revt2WDNfM/ptdR3UM53Dw7+6OH6Sm+ Rr/zKg2Ah4S50Qg4rLHKbqGbjDnF8M9PO+dvLr1/4+wBG8lAKE1wdz6sVSSxC5BSXTBD Kao3MGDgRDBvt/Mekjn2joA5bzJJldp55rJvof4zFT/3NcKRW362UZX1PRVMD5sYB+3L hW9R836AL4EQJp7XeZY2CFeAUKjAT9BHyd1HansGVq4kNiGX8sykmr7UZ9r4Z6V2Qalb /Vrw== 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=u99sfZGMW+gKwnhlHoCgtcN3E+Mx1BLTxSFc1sUIIAQ=; b=fFVejbtohkMZbaSN0CbkRQn1iqf76gwvIsEeC7xYzOn1Irz8U9EkuxEsmbTnIBJyDB vw1IofmoVi756EmJUJpYV+V4m1i2ZWF7qMFYiYAXO2FxxCCUjWAJEMCkC5CyFov6TnUg NLhfQaKobVgbZa1YQWsf+LyigRHUpeQNrYdsPcf2V9SwbBgO2Jne2sKouP9nGVghpJ1T +FHlQpsCPn48wy+LM8BhI7Jyt5ACmgpOEJAqTcc3B2b75DxHdBmAHXr2A1q7MoqBCyi6 myei2beFlzVdn0EI5iD0Ig/zMd+QgYocKYX6aDFyYGQOlVQc0Tw9girOaOnJ2t+ulL3j nVVg== X-Gm-Message-State: AHQUAuY/g2L5zxUq9P8oL42r5NMkE/7aPHCsiYMPUZOT5A1xSfCxERKZ /NE8Sw0skAvCbliETK1n0A7xOg== X-Google-Smtp-Source: AHgI3IaI1+WNJ5na+cip9KhRZd9N3GXJsoiKwIpZ9RQUMoZbviUrr9vmJ2+PBClmv+qJyQIG0LFT0A== X-Received: by 2002:a2e:90ca:: with SMTP id o10-v6mr8403783ljg.134.1549887924179; Mon, 11 Feb 2019 04:25:24 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:22 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , =?utf-8?q?Matias_Bj?= =?utf-8?q?=C3=B8rling?= Subject: [GIT PULL 4/8] lightnvm: pblk: Switch to use new generic UUID API Date: Mon, 11 Feb 2019 13:25:05 +0100 Message-Id: <20190211122509.19910-5-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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: Andy Shevchenko There are new types and helpers that are supposed to be used in new code. As a preparation to get rid of legacy types and API functions do the conversion here. Signed-off-by: Andy Shevchenko Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 5 +++-- drivers/lightnvm/pblk-init.c | 2 +- drivers/lightnvm/pblk-recovery.c | 8 +++++--- drivers/lightnvm/pblk.h | 10 +--------- 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 1b5ff51faa63..2a9e9facf44f 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1065,7 +1065,7 @@ static int pblk_line_init_metadata(struct pblk *pblk, struct pblk_line *line, bitmap_set(line->lun_bitmap, 0, lm->lun_bitmap_len); smeta_buf->header.identifier = cpu_to_le32(PBLK_MAGIC); - memcpy(smeta_buf->header.uuid, pblk->instance_uuid, 16); + guid_copy((guid_t *)&smeta_buf->header.uuid, &pblk->instance_uuid); smeta_buf->header.id = cpu_to_le32(line->id); smeta_buf->header.type = cpu_to_le16(line->type); smeta_buf->header.version_major = SMETA_VERSION_MAJOR; @@ -1874,7 +1874,8 @@ void pblk_line_close_meta(struct pblk *pblk, struct pblk_line *line) if (le32_to_cpu(emeta_buf->header.identifier) != PBLK_MAGIC) { emeta_buf->header.identifier = cpu_to_le32(PBLK_MAGIC); - memcpy(emeta_buf->header.uuid, pblk->instance_uuid, 16); + guid_copy((guid_t *)&emeta_buf->header.uuid, + &pblk->instance_uuid); emeta_buf->header.id = cpu_to_le32(line->id); emeta_buf->header.type = cpu_to_le16(line->type); emeta_buf->header.version_major = EMETA_VERSION_MAJOR; diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index eb0135c77805..8b643d0bffae 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c @@ -130,7 +130,7 @@ static int pblk_l2p_recover(struct pblk *pblk, bool factory_init) struct pblk_line *line = NULL; if (factory_init) { - pblk_setup_uuid(pblk); + guid_gen(&pblk->instance_uuid); } else { line = pblk_recov_l2p(pblk); if (IS_ERR(line)) { diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 5ee20da7bdb3..6761d2afa4d0 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -703,11 +703,13 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk) /* The first valid instance uuid is used for initialization */ if (!valid_uuid) { - memcpy(pblk->instance_uuid, smeta_buf->header.uuid, 16); + guid_copy(&pblk->instance_uuid, + (guid_t *)&smeta_buf->header.uuid); valid_uuid = 1; } - if (memcmp(pblk->instance_uuid, smeta_buf->header.uuid, 16)) { + if (!guid_equal(&pblk->instance_uuid, + (guid_t *)&smeta_buf->header.uuid)) { pblk_debug(pblk, "ignore line %u due to uuid mismatch\n", i); continue; @@ -737,7 +739,7 @@ struct pblk_line *pblk_recov_l2p(struct pblk *pblk) } if (!found_lines) { - pblk_setup_uuid(pblk); + guid_gen(&pblk->instance_uuid); spin_lock(&l_mg->free_lock); WARN_ON_ONCE(!test_and_clear_bit(meta_line, diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 0dd697ea201e..72ae8755764e 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -646,7 +646,7 @@ struct pblk { int sec_per_write; - unsigned char instance_uuid[16]; + guid_t instance_uuid; /* Persistent write amplification counters, 4kb sector I/Os */ atomic64_t user_wa; /* Sectors written by user */ @@ -1360,14 +1360,6 @@ static inline unsigned int pblk_get_secs(struct bio *bio) return bio->bi_iter.bi_size / PBLK_EXPOSED_PAGE_SIZE; } -static inline void pblk_setup_uuid(struct pblk *pblk) -{ - uuid_le uuid; - - uuid_le_gen(&uuid); - memcpy(pblk->instance_uuid, uuid.b, 16); -} - static inline char *pblk_disk_name(struct pblk *pblk) { struct gendisk *disk = pblk->disk; From patchwork Mon Feb 11 12:25:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805579 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87E8713BF for ; Mon, 11 Feb 2019 12:26:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 785182A0F3 for ; Mon, 11 Feb 2019 12:26:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C7732A155; Mon, 11 Feb 2019 12:26:02 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 16FD62A139 for ; Mon, 11 Feb 2019 12:26:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726025AbfBKMZ4 (ORCPT ); Mon, 11 Feb 2019 07:25:56 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:43920 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727317AbfBKMZ2 (ORCPT ); Mon, 11 Feb 2019 07:25:28 -0500 Received: by mail-lf1-f67.google.com with SMTP id j1so7561496lfb.10 for ; Mon, 11 Feb 2019 04:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JYcMZJWwnYjs5lNvrgyZLyaYKBt0sZAp/myA2P7sIbo=; b=rWXNsjXbmZRuP4V37SAe41A7qIqA7ZErIo6Hfvpds9wsuH7zdPODlASLsSnE7yWdHE 8K89N6rsJVc3pIr+yUi9Mk9h8xjcTe39T9A80gmusY+M4/WPD8hIJ3HC1kxv05biOCZw cZQhVEsE2ZV/ESxWaEkDAQG9nh1+9s6w0r2MfcqHm41uCvGjkDksgDWaTV2kF5xb5l/S QUcCsQsCQcXuT4xJtL1K7vpF6KETYUfT8S9NmQoniden8HUrS+XqBtRJ7QeImtQ9W7gS +L69bITr6NV/dIRAbzx9qQhBlqiJLNZtpcnMDq6twhHzADTRhiOYChFOvwVRXlWSZImk eMAw== 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=JYcMZJWwnYjs5lNvrgyZLyaYKBt0sZAp/myA2P7sIbo=; b=WuagV/JbeNV2cYDNTA6uSbrMzdmQau/YcQ3HBH0cU5yAiKdFnAusBd4RHvcEnY4qdW 5itDxgnivHTgBL9Kk2hRCZ3+6LKHw15bMwRDsMlu3jDyVW6dHAjuK8DrThs4b02FN9WW vUAPqDj2i9uLnAO6hqhGvTDo3oV3yrMk9v7LrjyXmLnkzHdACLU9/blxT/Vagy/usR5E Vpooii/uwd6PvXK0tQ79g5PvLr8m4H40HUvYKLEkHGhUnwCzfUbozANYpHYT3kJ974zr ACcHAXKt26EJZgxjfRBLwR7ghZKggiX59YMXnVX7ie7v+8ffigkRFD4OaSAed1SWa5bl FajQ== X-Gm-Message-State: AHQUAuYudL7fKZYcz505zOCo+P/61vGc3A1WUIo2so6IJvRQhCgkeS87 +O4fsfSjbdI6BYiEa5Rn6BmT0g== X-Google-Smtp-Source: AHgI3IbaVOEWADoPTXHQsqYo7sf9mLdjXcq0ZGzfX1pYex22caB4DgD6cJDkjqcm1Vr1zG7p+xBQ+Q== X-Received: by 2002:a19:f013:: with SMTP id p19mr3370775lfc.154.1549887926166; Mon, 11 Feb 2019 04:25:26 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:24 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Masahiro Yamada , =?utf-8?q?Matias_Bj=C3=B8r?= =?utf-8?q?ling?= Subject: [GIT PULL 5/8] lightnvm: pblk: fix TRACE_INCLUDE_PATH Date: Mon, 11 Feb 2019 13:25:06 +0100 Message-Id: <20190211122509.19910-6-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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: Masahiro Yamada As the comment block in include/trace/define_trace.h says, TRACE_INCLUDE_PATH should be a relative path to the define_trace.h ../../drivers/lightnvm is the correct relative path. ../../../drivers/lightnvm is working by coincidence because the top Makefile adds -I$(srctree)/arch/$(SRCARCH)/include as a header search path, but we should not rely on it. Signed-off-by: Masahiro Yamada Reviewed-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-trace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/lightnvm/pblk-trace.h b/drivers/lightnvm/pblk-trace.h index 679e5c458ca6..9534503b69d9 100644 --- a/drivers/lightnvm/pblk-trace.h +++ b/drivers/lightnvm/pblk-trace.h @@ -139,7 +139,7 @@ TRACE_EVENT(pblk_state, /* This part must be outside protection */ #undef TRACE_INCLUDE_PATH -#define TRACE_INCLUDE_PATH ../../../drivers/lightnvm +#define TRACE_INCLUDE_PATH ../../drivers/lightnvm #undef TRACE_INCLUDE_FILE #define TRACE_INCLUDE_FILE pblk-trace #include From patchwork Mon Feb 11 12:25:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805577 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 198FB13BF for ; Mon, 11 Feb 2019 12:25:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09C4D285A8 for ; Mon, 11 Feb 2019 12:25:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F269F28BA0; Mon, 11 Feb 2019 12:25:55 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 73545285A8 for ; Mon, 11 Feb 2019 12:25:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbfBKMZc (ORCPT ); Mon, 11 Feb 2019 07:25:32 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40752 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbfBKMZa (ORCPT ); Mon, 11 Feb 2019 07:25:30 -0500 Received: by mail-lf1-f66.google.com with SMTP id t14so7570348lfk.7 for ; Mon, 11 Feb 2019 04:25:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=horUJaYN1AtPap9Tf3+ti1ICSvr2tumzRYfiNboXyUE=; b=qdkB2bHQC/o2xcAnKZMyX7sQM6OtYJVunYcRuZpTUU5MWef4Wu/5X7VcEHyruwl2DJ aiHkB/BV4PVUjVABDCT2ui+/3H+mkiJNGBqxNuEmOyTWkxP12wIopAZGOMRiUcra48EK pxEnFE38dJgZul2XO+jq3pY/NLMntCuolNkI0zVX1BtEtAI39DqbQeN0NyWAruQm7l/V aCGoxbQT+181G1LNP9mEO9dG9OSrDL3ZcUr+gg3HKc3H17d5WoN2vYAaAd2Jg/5AFJ1Y 6qs5Y2L/EPuGcKFVgifa6vTSeQ+NRNq8UP6IaYfQl19F/RCb72C8GHIcOUZ/FxScDn+Q qIGQ== 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=horUJaYN1AtPap9Tf3+ti1ICSvr2tumzRYfiNboXyUE=; b=XR1OOGfnk/YyEUzmw0yGoVkvl/SKcw5weocHXDJH0CxUOL2Q9A9z/Je9gK5TrzGnZn 5uuJdiPzpN/2QAppKDhTa+BfSxotvr7nhtsWddXVUvzUtD2gZ/mAF/2qsL8zvI31ahde 6yOUqPXgoKGa7yVg9uIZNlPWWtaS/1mRWBsi0Nj0Xsy2HaiDEfRpTRu92V/CPQkjb3A0 KG35xLhokIREqso9iP/bBj6egrVZKC7aPiSQgIsnfJYxecbxRDKmTBVP9zf+sIT0Jw+d K/m9cn/TWYKj8Hk4SgnKWXYPXqEg0/GH4wAQJT4KxWrvxF8Q1UO9WupCAzx/9EV6nPRx E+TQ== X-Gm-Message-State: AHQUAuZvZLAcRcxj5gcnIYQI9UymOa53DpCWP1HfdP5CcC+sNo4Jv0hp rEEMLvzHUZ+HRMy1QTVeixfnGzIyB8I= X-Google-Smtp-Source: AHgI3IbygmPsrWZPYgAX+rA3ObHONfRmKTMYSb3mt49tm2O2rMaNdVESnZBVJbL2WBN8vSgxfmMalg== X-Received: by 2002:ac2:5085:: with SMTP id f5mr21611025lfm.30.1549887928681; Mon, 11 Feb 2019 04:25:28 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:27 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 6/8] lightnvm: pblk: extend line wp balance check Date: Mon, 11 Feb 2019 13:25:07 +0100 Message-Id: <20190211122509.19910-7-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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 pblk stripes writes of minimal write size across all non-offline chunks in a line, which means that the maximum write pointer delta should not exceed the minimal write size. Extend the line write pointer balance check to cover this case, and ignore the offline chunk wps. This will render us a warning during recovery if something unexpected has happened to the chunk write pointers (i.e. powerloss, a spurious chunk reset, ..). Reported-by: Zhoujie Wu Tested-by: Zhoujie Wu Reviewed-by: Javier González Signed-off-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-recovery.c | 56 ++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 6761d2afa4d0..d86f580036d3 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c @@ -302,35 +302,55 @@ static int pblk_pad_distance(struct pblk *pblk, struct pblk_line *line) return (distance > line->left_msecs) ? line->left_msecs : distance; } -static int pblk_line_wp_is_unbalanced(struct pblk *pblk, - struct pblk_line *line) +/* Return a chunk belonging to a line by stripe(write order) index */ +static struct nvm_chk_meta *pblk_get_stripe_chunk(struct pblk *pblk, + struct pblk_line *line, + int index) { struct nvm_tgt_dev *dev = pblk->dev; struct nvm_geo *geo = &dev->geo; - struct pblk_line_meta *lm = &pblk->lm; struct pblk_lun *rlun; - struct nvm_chk_meta *chunk; struct ppa_addr ppa; - u64 line_wp; - int pos, i; + int pos; - rlun = &pblk->luns[0]; + rlun = &pblk->luns[index]; ppa = rlun->bppa; pos = pblk_ppa_to_pos(geo, ppa); - chunk = &line->chks[pos]; - line_wp = chunk->wp; + return &line->chks[pos]; +} - for (i = 1; i < lm->blk_per_line; i++) { - rlun = &pblk->luns[i]; - ppa = rlun->bppa; - pos = pblk_ppa_to_pos(geo, ppa); - chunk = &line->chks[pos]; +static int pblk_line_wps_are_unbalanced(struct pblk *pblk, + struct pblk_line *line) +{ + struct pblk_line_meta *lm = &pblk->lm; + int blk_in_line = lm->blk_per_line; + struct nvm_chk_meta *chunk; + u64 max_wp, min_wp; + int i; - if (chunk->wp > line_wp) + i = find_first_zero_bit(line->blk_bitmap, blk_in_line); + + /* If there is one or zero good chunks in the line, + * the write pointers can't be unbalanced. + */ + if (i >= (blk_in_line - 1)) + return 0; + + chunk = pblk_get_stripe_chunk(pblk, line, i); + max_wp = chunk->wp; + if (max_wp > pblk->max_write_pgs) + min_wp = max_wp - pblk->max_write_pgs; + else + min_wp = 0; + + i = find_next_zero_bit(line->blk_bitmap, blk_in_line, i + 1); + while (i < blk_in_line) { + chunk = pblk_get_stripe_chunk(pblk, line, i); + if (chunk->wp > max_wp || chunk->wp < min_wp) return 1; - else if (chunk->wp < line_wp) - line_wp = chunk->wp; + + i = find_next_zero_bit(line->blk_bitmap, blk_in_line, i + 1); } return 0; @@ -356,7 +376,7 @@ static int pblk_recov_scan_oob(struct pblk *pblk, struct pblk_line *line, int ret; u64 left_ppas = pblk_sec_in_open_line(pblk, line) - lm->smeta_sec; - if (pblk_line_wp_is_unbalanced(pblk, line)) + if (pblk_line_wps_are_unbalanced(pblk, line)) pblk_warn(pblk, "recovering unbalanced line (%d)\n", line->id); ppa_list = p.ppa_list; From patchwork Mon Feb 11 12:25:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805575 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 527CC17E0 for ; Mon, 11 Feb 2019 12:25:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41E54285A8 for ; Mon, 11 Feb 2019 12:25:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 365E128BA0; Mon, 11 Feb 2019 12:25:51 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 248D9285A8 for ; Mon, 11 Feb 2019 12:25:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727191AbfBKMZs (ORCPT ); Mon, 11 Feb 2019 07:25:48 -0500 Received: from mail-lf1-f65.google.com ([209.85.167.65]:45703 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbfBKMZd (ORCPT ); Mon, 11 Feb 2019 07:25:33 -0500 Received: by mail-lf1-f65.google.com with SMTP id b20so7553595lfa.12 for ; Mon, 11 Feb 2019 04:25:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8V6tAD6ianDzVJV9jLJWZ3zCHF2Gv41r5hfwz3shMqg=; b=tNVuQrmcOX9opYuNSkmd2cHthVde2CNQLD1Nz9ouyMyZuF4l0axH/ecLCeC8U2QYb6 FXh16jdx8F0F2KWMmOHDZ0oYURAMVU2RC0acvMSD1Y2zDVMgsm7sd1J3LVNqPqv2wuG9 tDgzlv1W2Dr+6l9OU6bBPaWgUP69BH+Jzh34xIoqU/yxSt6sU1PhF3p/PdrQK5fU9tdM xTIQEX3sc2LhYsSrEqHd157OhaETG6cTZtSHsUo/+XR6SicJEyKjcD1JjNRPrp5XmAFF 0ymahKfDaQkGoiAr5t6lvY2d3B+d2XdlMEc75C4V38BS5iiZ1FMJ0tkQlbe+3twYZlg+ DODA== 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=8V6tAD6ianDzVJV9jLJWZ3zCHF2Gv41r5hfwz3shMqg=; b=lgGLN/wSsk6xD25DuZHbgRhVPkKUqL+ZxOpakG7B+DM+7VSQtX5X3XDYmwle+Pw79R dEldcLiHkquSbnw228Ck1LaiUqT27/ybP7ZN1jULh+ot7Bags/mihZsHzAMW2yDMPHHk mONqFz4sP2WzZUyOGXPoLaLYf6RTcC/k6iP2rmpBugwUDfhnQIBT8vFhJmMBEegDs510 rTJCBWE8m5v7jr6TjxX4p3uGMXwdXCJ3OKbF5nx8D+V7LSq39cfja9gnslg9VmwQe8bK LrQknSvOEdp0TQrYFbDLcEE9AdA/WTN5gqUDlfCzVQX8qwNvCROujyA3+Zcl/cGyEhVD sduA== X-Gm-Message-State: AHQUAubko8reTXft1mEbsA8UcZhj1R9CjiK8HXyBGDIuE5t+Q7fkgQK2 IpCVf7ISAQpCkHdvl0JuFN91MA== X-Google-Smtp-Source: AHgI3IZbPjmbsyg6LgZObXJHFaFiGAkIyErZ8bk/8BCvzRYONOMO/bUfFKP09S5CeJJIPdP891bZUQ== X-Received: by 2002:a19:2242:: with SMTP id i63mr6828146lfi.39.1549887930167; Mon, 11 Feb 2019 04:25:30 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:29 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Jav?= =?utf-8?q?ier_Gonz=C3=A1lez?= , =?utf-8?q?Matias_Bj?= =?utf-8?q?=C3=B8rling?= Subject: [GIT PULL 7/8] lightnvm: pblk: prevent stall due to wb threshold Date: Mon, 11 Feb 2019 13:25:08 +0100 Message-Id: <20190211122509.19910-8-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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: Javier González In order to respect mw_cuinits, pblk's write buffer maintains a backpointer to protect data not yet persisted; when writing to the write buffer, this backpointer defines a threshold that pblk's rate-limiter enforces. On small PU configurations, the following scenarios might take place: (i) the threshold is larger than the write buffer and (ii) the threshold is smaller than the write buffer, but larger than the maximun allowed split bio - 256KB at this moment (Note that writes are not always split - we only do this when we the size of the buffer is smaller than the buffer). In both cases, pblk's rate-limiter prevents the I/O to be written to the buffer, thus stalling. This patch fixes the original backpointer implementation by considering the threshold both on buffer creation and on the rate-limiters path, when bio_split is triggered (case (ii) above). Fixes: 766c8ceb16fc ("lightnvm: pblk: guarantee that backpointer is respected on writer stall") Signed-off-by: Javier González Reviewed-by: Hans Holmberg Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-rb.c | 25 +++++++++++++++++++------ drivers/lightnvm/pblk-rl.c | 5 ++--- drivers/lightnvm/pblk.h | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c index d4ca8c64ee0f..a6133b50ed9c 100644 --- a/drivers/lightnvm/pblk-rb.c +++ b/drivers/lightnvm/pblk-rb.c @@ -45,10 +45,23 @@ void pblk_rb_free(struct pblk_rb *rb) /* * pblk_rb_calculate_size -- calculate the size of the write buffer */ -static unsigned int pblk_rb_calculate_size(unsigned int nr_entries) +static unsigned int pblk_rb_calculate_size(unsigned int nr_entries, + unsigned int threshold) { - /* Alloc a write buffer that can at least fit 128 entries */ - return (1 << max(get_count_order(nr_entries), 7)); + unsigned int thr_sz = 1 << (get_count_order(threshold + NVM_MAX_VLBA)); + unsigned int max_sz = max(thr_sz, nr_entries); + unsigned int max_io; + + /* Alloc a write buffer that can (i) fit at least two split bios + * (considering max I/O size NVM_MAX_VLBA, and (ii) guarantee that the + * threshold will be respected + */ + max_io = (1 << max((int)(get_count_order(max_sz)), + (int)(get_count_order(NVM_MAX_VLBA << 1)))); + if ((threshold + NVM_MAX_VLBA) >= max_io) + max_io <<= 1; + + return max_io; } /* @@ -67,12 +80,12 @@ int pblk_rb_init(struct pblk_rb *rb, unsigned int size, unsigned int threshold, unsigned int alloc_order, order, iter; unsigned int nr_entries; - nr_entries = pblk_rb_calculate_size(size); + nr_entries = pblk_rb_calculate_size(size, threshold); entries = vzalloc(array_size(nr_entries, sizeof(struct pblk_rb_entry))); if (!entries) return -ENOMEM; - power_size = get_count_order(size); + power_size = get_count_order(nr_entries); power_seg_sz = get_count_order(seg_size); down_write(&pblk_rb_lock); @@ -149,7 +162,7 @@ int pblk_rb_init(struct pblk_rb *rb, unsigned int size, unsigned int threshold, * Initialize rate-limiter, which controls access to the write buffer * by user and GC I/O */ - pblk_rl_init(&pblk->rl, rb->nr_entries); + pblk_rl_init(&pblk->rl, rb->nr_entries, threshold); return 0; } diff --git a/drivers/lightnvm/pblk-rl.c b/drivers/lightnvm/pblk-rl.c index 76116d5f78e4..b014957dde0b 100644 --- a/drivers/lightnvm/pblk-rl.c +++ b/drivers/lightnvm/pblk-rl.c @@ -207,7 +207,7 @@ void pblk_rl_free(struct pblk_rl *rl) del_timer(&rl->u_timer); } -void pblk_rl_init(struct pblk_rl *rl, int budget) +void pblk_rl_init(struct pblk_rl *rl, int budget, int threshold) { struct pblk *pblk = container_of(rl, struct pblk, rl); struct nvm_tgt_dev *dev = pblk->dev; @@ -217,7 +217,6 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) int sec_meta, blk_meta; unsigned int rb_windows; - /* Consider sectors used for metadata */ sec_meta = (lm->smeta_sec + lm->emeta_sec[0]) * l_mg->nr_free_lines; blk_meta = DIV_ROUND_UP(sec_meta, geo->clba); @@ -234,7 +233,7 @@ void pblk_rl_init(struct pblk_rl *rl, int budget) /* To start with, all buffer is available to user I/O writers */ rl->rb_budget = budget; rl->rb_user_max = budget; - rl->rb_max_io = budget >> 1; + rl->rb_max_io = threshold ? (budget - threshold) : (budget - 1); rl->rb_gc_max = 0; rl->rb_state = PBLK_RL_HIGH; diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index 72ae8755764e..a6386d5acd73 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -924,7 +924,7 @@ int pblk_gc_sysfs_force(struct pblk *pblk, int force); /* * pblk rate limiter */ -void pblk_rl_init(struct pblk_rl *rl, int budget); +void pblk_rl_init(struct pblk_rl *rl, int budget, int threshold); void pblk_rl_free(struct pblk_rl *rl); void pblk_rl_update_rates(struct pblk_rl *rl); int pblk_rl_high_thrs(struct pblk_rl *rl); From patchwork Mon Feb 11 12:25:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Matias Bjorling X-Patchwork-Id: 10805573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AC73813BF for ; Mon, 11 Feb 2019 12:25:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C472285A8 for ; Mon, 11 Feb 2019 12:25:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90A4328BA0; Mon, 11 Feb 2019 12:25:37 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 6C841285A8 for ; Mon, 11 Feb 2019 12:25:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727352AbfBKMZf (ORCPT ); Mon, 11 Feb 2019 07:25:35 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:40290 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727375AbfBKMZe (ORCPT ); Mon, 11 Feb 2019 07:25:34 -0500 Received: by mail-lj1-f195.google.com with SMTP id z25-v6so8550888ljk.7 for ; Mon, 11 Feb 2019 04:25:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vV7BdTFxfdzellee6uLIM4zSFMN2KdjxRkfq0QP0Mnw=; b=SwBiHcRHaReRUBX3NUdT3JJX8GHBqAYHk9Q3Y23lE33VP3qkEtK9T5TGtXLONXXdoC mIofGS8dl8HeeVZTG/N5JvdnHTVWkf5ONR6Y4FlZD6LNPNV5Ds4bINVtJEt6aIYVZ/6V Em7WJ7Ineffg52+1REN0QJ/WAFYwjczf0oUlWXn3FmvU1cqhczJpImGRQeqIkGLUwbYf edzjb2OQ077IL2CXd99IGoyfXGuknFyPOZ95hO5r/e249qQtVxZZLM/EVRGQCD83armx OCxS++XtssfsunN27u4LxK+0gYGONnVvqAB3Vfqsrq1sLJcl/3w3kMGfkSZSiy94fQYJ AOVA== 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=vV7BdTFxfdzellee6uLIM4zSFMN2KdjxRkfq0QP0Mnw=; b=sWwhJNfqiHv6qgWoyADDHhkLAavRjY/3COlk/Okqoa3SUi1oUW1b6LrjB7nBxG/bCl QPIrHmVnFXkZ2nL25SVUupMuZhHk+pItYd945GF2f/PpOTXudJgyO95E64RJgoBS22vJ seZW8EL5yU5wAWwF1scmuN2OovBmoq0XPFpUJ+4bFXOGDMsCPEeLqgkQViIiyGycahb9 k/UyVVawUok6p8tgUXu/ddLmVvCo2j7+BLgMTlfSZLlPNMxgc5LSLUbAcS2Yw4J+ObI6 EYDO6P0BQrEpoT1p35dRew78gUgWDxa6Ch93r7rhsVZxDxvX6syyNq7Ifk5R+A4fjWbu /IFA== X-Gm-Message-State: AHQUAuZEWg+eUPy7aC87dXkOW12WwzXC/hkCwG5lgjXhMJD6o1wqdZkN o9gRHUciM/cmZWOi6/Qc3n1rlg== X-Google-Smtp-Source: AHgI3IYAIQwYNPqNHt4HZTpxCTC8Z//w29sS8X6jPtLPb1FwvXaxauLhKhug1TooU36tx282bQmUWQ== X-Received: by 2002:a2e:9855:: with SMTP id e21-v6mr7076398ljj.76.1549887932382; Mon, 11 Feb 2019 04:25:32 -0800 (PST) Received: from skyninja.webspeed.dk (2-111-91-225-cable.dk.customer.tdc.net. [2.111.91.225]) by smtp.gmail.com with ESMTPSA id d70sm2278481lfe.14.2019.02.11.04.25.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Feb 2019 04:25:30 -0800 (PST) From: =?utf-8?q?Matias_Bj=C3=B8rling?= To: axboe@fb.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Heiner Litz , =?utf-8?q?Matias_Bj=C3=B8rling?= Subject: [GIT PULL 8/8] lightnvm: pblk: fix race condition on GC Date: Mon, 11 Feb 2019 13:25:09 +0100 Message-Id: <20190211122509.19910-9-mb@lightnvm.io> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190211122509.19910-1-mb@lightnvm.io> References: <20190211122509.19910-1-mb@lightnvm.io> 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: Heiner Litz This patch fixes a race condition where a write is mapped to the last sectors of a line. The write is synced to the device but the L2P is not updated yet. When the line is garbage collected before the L2P update is performed, the sectors are ignored by the GC logic and the line is freed before all sectors are moved. When the L2P is finally updated, it contains a mapping to a freed line, subsequent reads of the corresponding LBAs fail. This patch introduces a per line counter specifying the number of sectors that are synced to the device but have not been updated in the L2P. Lines with a counter of greater than zero will not be selected for GC. Signed-off-by: Heiner Litz Reviewed-by: Hans Holmberg Reviewed-by: Javier González Signed-off-by: Matias Bjørling --- drivers/lightnvm/pblk-core.c | 1 + drivers/lightnvm/pblk-gc.c | 22 ++++++++++++++-------- drivers/lightnvm/pblk-map.c | 1 + drivers/lightnvm/pblk-rb.c | 1 + drivers/lightnvm/pblk-write.c | 1 + drivers/lightnvm/pblk.h | 1 + 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/drivers/lightnvm/pblk-core.c b/drivers/lightnvm/pblk-core.c index 2a9e9facf44f..6ca868868fee 100644 --- a/drivers/lightnvm/pblk-core.c +++ b/drivers/lightnvm/pblk-core.c @@ -1278,6 +1278,7 @@ static int pblk_line_prepare(struct pblk *pblk, struct pblk_line *line) spin_unlock(&line->lock); kref_init(&line->ref); + atomic_set(&line->sec_to_update, 0); return 0; } diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 2fa118c8eb71..26a52ea7ec45 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c @@ -365,16 +365,22 @@ static struct pblk_line *pblk_gc_get_victim_line(struct pblk *pblk, struct list_head *group_list) { struct pblk_line *line, *victim; - int line_vsc, victim_vsc; + unsigned int line_vsc = ~0x0L, victim_vsc = ~0x0L; victim = list_first_entry(group_list, struct pblk_line, list); + list_for_each_entry(line, group_list, list) { - line_vsc = le32_to_cpu(*line->vsc); - victim_vsc = le32_to_cpu(*victim->vsc); - if (line_vsc < victim_vsc) + if (!atomic_read(&line->sec_to_update)) + line_vsc = le32_to_cpu(*line->vsc); + if (line_vsc < victim_vsc) { victim = line; + victim_vsc = le32_to_cpu(*victim->vsc); + } } + if (victim_vsc == ~0x0) + return NULL; + return victim; } @@ -448,12 +454,12 @@ static void pblk_gc_run(struct pblk *pblk) do { spin_lock(&l_mg->gc_lock); - if (list_empty(group_list)) { - spin_unlock(&l_mg->gc_lock); - break; - } line = pblk_gc_get_victim_line(pblk, group_list); + if (!line) { + spin_unlock(&l_mg->gc_lock); + break; + } spin_lock(&line->lock); WARN_ON(line->state != PBLK_LINESTATE_CLOSED); diff --git a/drivers/lightnvm/pblk-map.c b/drivers/lightnvm/pblk-map.c index 79df583ea709..7fbc99b60cac 100644 --- a/drivers/lightnvm/pblk-map.c +++ b/drivers/lightnvm/pblk-map.c @@ -73,6 +73,7 @@ static int pblk_map_page_data(struct pblk *pblk, unsigned int sentry, */ if (i < valid_secs) { kref_get(&line->ref); + atomic_inc(&line->sec_to_update); w_ctx = pblk_rb_w_ctx(&pblk->rwb, sentry + i); w_ctx->ppa = ppa_list[i]; meta->lba = cpu_to_le64(w_ctx->lba); diff --git a/drivers/lightnvm/pblk-rb.c b/drivers/lightnvm/pblk-rb.c index a6133b50ed9c..03c241b340ea 100644 --- a/drivers/lightnvm/pblk-rb.c +++ b/drivers/lightnvm/pblk-rb.c @@ -260,6 +260,7 @@ static int __pblk_rb_update_l2p(struct pblk_rb *rb, unsigned int to_update) entry->cacheline); line = pblk_ppa_to_line(pblk, w_ctx->ppa); + atomic_dec(&line->sec_to_update); kref_put(&line->ref, pblk_line_put); clean_wctx(w_ctx); rb->l2p_update = pblk_rb_ptr_wrap(rb, rb->l2p_update, 1); diff --git a/drivers/lightnvm/pblk-write.c b/drivers/lightnvm/pblk-write.c index 06d56deb645d..6593deab52da 100644 --- a/drivers/lightnvm/pblk-write.c +++ b/drivers/lightnvm/pblk-write.c @@ -177,6 +177,7 @@ static void pblk_prepare_resubmit(struct pblk *pblk, unsigned int sentry, * re-map these entries */ line = pblk_ppa_to_line(pblk, w_ctx->ppa); + atomic_dec(&line->sec_to_update); kref_put(&line->ref, pblk_line_put); } spin_unlock(&pblk->trans_lock); diff --git a/drivers/lightnvm/pblk.h b/drivers/lightnvm/pblk.h index a6386d5acd73..ac3ab778e976 100644 --- a/drivers/lightnvm/pblk.h +++ b/drivers/lightnvm/pblk.h @@ -487,6 +487,7 @@ struct pblk_line { __le32 *vsc; /* Valid sector count in line */ struct kref ref; /* Write buffer L2P references */ + atomic_t sec_to_update; /* Outstanding L2P updates to ppa */ struct pblk_w_err_gc *w_err_gc; /* Write error gc recovery metadata */