Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5898790imu; Wed, 30 Jan 2019 05:33:52 -0800 (PST) X-Google-Smtp-Source: ALg8bN4k59bfNhcrq+0JUrXHEc/n7xh/+JaNyHNb+AnleWJ6W59947Ymt7sGX5j4iZtfyHonZz/k X-Received: by 2002:aa7:8608:: with SMTP id p8mr30980130pfn.125.1548855232592; Wed, 30 Jan 2019 05:33:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548855232; cv=none; d=google.com; s=arc-20160816; b=IWNJGckq4W/by/HaXcsj6EjUkZqeXkkHTUCWj9AyuUBOv9o1O1r1nTyG/sPqC89aAc ZNZQDh//VlrCB+tcG6L53azfkYrvuJIjuEYfAzg6yugpIPxbgAhsiRnt1yZzRoqcv+K6 k6hXpbKcEKAlsIIxRrxAQvPrACKFYLlFx5LFXgOOI2G819eTPTgWJIbY5ZBspWjoeNiz +2bkMonk3pS8aL2Dm7GzN69iolrQYAUoRz/U9/yPseGz7uMrAYWzZlSI9U7zAHy5v9iz TkYQxm2LQECYQwI8vmdFbzgIyuGcYLjtaVmDI8Uf/za5tuOBwCdNIz0whUN81u6Qbrrl rMzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=MWOHj8i9VGFnozURvSgdoAGxbNrdHu0U7DXiOt979AI=; b=fItWWjOpWv5u5o2Xb/v1vm3pY+X/z0Y+C/HJ++MPFNNties2sS7GbWz39yTZ+etbh7 h0sr/4S0tGTXDhFhuafuoqDZhFFJwmjQp/WGxnUWpcb1xHftUX54bGH7//8kXOVrr25N NwZduV/SYuDnf89lWL3x8XjBeBrN2PS6039eOhyc3NGrCRCRDRIqDKTcHPQC0QpqM9C5 i38oTLoRB/oYDP2sG2EYXVv3V3aEKmRsojHOD9t66pQOr3/ggnzxgh4f3DGoPW5hBTLA 82/RAQaqesZ1xtjqDYLcNd/yTPs8bn6IZtxJ1JX9Gj2+K79/C55Ofl8wNjm7zryoVLx/ vk5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="IvQ/madw"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g66si1404593pgc.226.2019.01.30.05.33.36; Wed, 30 Jan 2019 05:33:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="IvQ/madw"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730883AbfA3NdY (ORCPT + 99 others); Wed, 30 Jan 2019 08:33:24 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37923 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727162AbfA3NdY (ORCPT ); Wed, 30 Jan 2019 08:33:24 -0500 Received: by mail-pl1-f193.google.com with SMTP id e5so11067493plb.5 for ; Wed, 30 Jan 2019 05:33:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=MWOHj8i9VGFnozURvSgdoAGxbNrdHu0U7DXiOt979AI=; b=IvQ/madwRTrRb9HueMOLTd4fGcNH1NgZWXvdQVVrunQcOlMR2Tb/mEXxcPJcGW+CzJ RlGuBO+kmjexKCWipsEFo6iDtxDGdzJ/JaPrMq0W2hDG6cDrSBiFMyLCPTSzcQyfOmv/ HMO36GdEYVcy5bh3XAS2DTT4UktmR1hLLzXmxT4nUQk70kFozYVf+uTMp4u610jBectL rN3K/IE76sYq+ySLhfBPjfA5E/Ez1X1Fw2kOqhj9plJUj3Vc865x4b+PdkrZKfaIjo5J FkDRlmMNXySbV7h1FSnw3xHI92RKzV6lDCi2Tn5NTREtkLVV+uScAVgNmXLG7zdzMDVC UOeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=MWOHj8i9VGFnozURvSgdoAGxbNrdHu0U7DXiOt979AI=; b=eh1L1XlRrDuDAUTuM/KTsbzVcLCQaeWc6KbU3B5OTCWjI/QRIZVzIlZIYyyvZ9vOg5 k1YemYBQ6ML6bZR9wg13Ho7Q1p7fQ5WhJZ2e6j9TgPPBnlY7DUVvYrJcD4wnKujhu1Dh AM4nuIGlL3JszVhS8OYE/gBaWzjoNxiU/uzp7ww5G0NjnstabFgZhttXX3sBxzWMtful fDf48s+JqwmauldR0sf24gFIHe6pkzYyvtX5NdE33EciYMX3xvPhxZfZF5gf/x5ZeP6p RDxj4JwQI/wbMD4/aHLJ0/ck2Xhs7up8zrVRWA8ZluVdsGRfIadvJO3goG2VJLi7FrZ2 knyA== X-Gm-Message-State: AJcUukd+GaB2sTpckPLbNl43aed0Sx7aJjm6WKPsMnvJFqOoJVMih9ih W5h102JwuvOWRwErwpsBiyqfaxm33WyY5w== X-Received: by 2002:a17:902:780a:: with SMTP id p10mr31103181pll.54.1548855203207; Wed, 30 Jan 2019 05:33:23 -0800 (PST) Received: from [192.168.15.224] (71-6-111-190.static-ip.telepacific.net. [71.6.111.190]) by smtp.gmail.com with ESMTPSA id y89sm3331224pfa.136.2019.01.30.05.33.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Jan 2019 05:33:22 -0800 (PST) Subject: Re: [PATCH V2] lightnvm: pblk: extend line wp balance check To: hans@owltronix.com Cc: javier@javigon.com, Zhoujie Wu , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Hans Holmberg References: <20190130081857.6779-1-hans@owltronix.com> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Wed, 30 Jan 2019 14:33:19 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190130081857.6779-1-hans@owltronix.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/30/19 9:18 AM, hans@owltronix.com wrote: > 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 > Signed-off-by: Hans Holmberg > --- > > Changes since V1: > > * Squashed with Zhoujie's: > "lightnvm: pblk: ignore bad block wp for pblk_line_wp_is_unbalanced" > * Clarified commit message based on Javier's comments. > > > 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; > + > + i = find_first_zero_bit(line->blk_bitmap, blk_in_line); > > - if (chunk->wp > line_wp) > + /* 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; > Thanks Hans and Zhoujie. I've applied it for 5.1.