Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4619459imu; Tue, 29 Jan 2019 04:50:01 -0800 (PST) X-Google-Smtp-Source: ALg8bN404ukRZy3RlJJZnL63hlbUix+IcdSHViBpmvMqKIldS/oRYp3VeZ3PoLQ74LF/NpYJIRq2 X-Received: by 2002:a63:6cc8:: with SMTP id h191mr22682410pgc.366.1548766201499; Tue, 29 Jan 2019 04:50:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548766201; cv=none; d=google.com; s=arc-20160816; b=axkyzFHgtgC5qKTtKcIf/5FDXkPo+qVy0CqzHrCNgV8dGd7QHtbdH66aQRjGsD5uJf pvkD2ZfOlnRZQBmPsAqptyKal4TNfnb4gjduqX3OJZShrl7ZcIgjMdOeMvn+PSRRtpqT pHaSYr0BoLyM+oOQj7+Nav2TMvOSUr1q35I7s18Q6kwsyIDtI5uHLT/1Hrtbvp54MnkA VzI6/kzE2Ab4DxS8iCAamdwd8L7Tk7XIeo1NliXdMXX0IHzv2HOAUk2NuAd28KbMQ9Sg mW6tYDjAeKmGoaUDfYYGV375XW93n1B/0IP4dF5RSeY5YlIlfbQeSVIzyN/TxnLo+BTX o1Kg== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=no+1oS4s347G7gknih83cWmNsSUn8v8xk/1BuDFSPFA=; b=q/TpnnaTGAXwoZ14A6K2/JT5fN5fZP6fBDFP3McidLATqhxJbdv08XR1p/8jyi3BU3 f+oQGjMivqAtksYwyMzBk0lkCKb9pbaDFSoJwwZyhOqBXEqPuepdzd7Vez5k/5iwj9qv i2jUXrmcvNhIz6fDsgYOJ4qKaK66lBY4krSXOV94h7h1o6RZ83YynfynkrtPo6xpQFL5 4/2i26XcxJh/ZIrXh70uxzHMLxjj7V6rZqn9GdzCK6XtJLYxczwJIlHv4yyrp2yc+xsq z6lRddFhChgPTU+MOP/ReMVxoVjZsz4/VrqYiaftIiK4+m6Uw9apeKdTAG6os6DEvnRx At/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=U2UAgSpo; 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 v20si5672108pgk.103.2019.01.29.04.49.44; Tue, 29 Jan 2019 04:50:01 -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=@owltronix-com.20150623.gappssmtp.com header.s=20150623 header.b=U2UAgSpo; 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 S1726430AbfA2MtP (ORCPT + 99 others); Tue, 29 Jan 2019 07:49:15 -0500 Received: from mail-vs1-f65.google.com ([209.85.217.65]:32934 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726790AbfA2MtO (ORCPT ); Tue, 29 Jan 2019 07:49:14 -0500 Received: by mail-vs1-f65.google.com with SMTP id p74so11877257vsc.0 for ; Tue, 29 Jan 2019 04:49:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=owltronix-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=no+1oS4s347G7gknih83cWmNsSUn8v8xk/1BuDFSPFA=; b=U2UAgSpoWIi3HVQAxj0CknNsg59AiX9gJp2xCNzzZ9cjYPj564cMioogfZX7EahEIH sgf34BIR/cYFhEo4MQW4IHlD/5k83AdRIkfYmu1scuOEZ3EIOCw+NrdbygfmzUTwgnhg zdAAnGEmUBOnKhhM1tAX9OkSPfGROaMZ5S+SyvHp0JNa69IHd+H7e2mrs7XDkdDO5fUi FOgt9uLcTtGzicCGBM9eoNfnsbJ3cPqrKaDssrI1Bzf2OXim4lLI+yOFEH72Wt9/0Ngh 5pW1GKWroG+H7O2gAqxzwe1ngGLVQ6eUTRcHGNV6uR9FhORR/fcLbdDRccVYVkAKhRL7 L7RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=no+1oS4s347G7gknih83cWmNsSUn8v8xk/1BuDFSPFA=; b=g3gOOn7Q7LVYJK+45gQ/OSkSka4QyYbnaA3XQmksfG9/qg6LuMiz69x0cKPxczd+7T YgWiZ0q/i3RiR+ZIZyLT1MEwMS2OtO2a3vv1U0n1WKKLqas9ImK8/44QS/WBpmaryqC5 HiSo1WA4024s9VKblp2H2Fv5mwMX1CwSFOHQ7jzqGM4ejWtCMag5BVmKpkKIVuHccD0r yKtt8oi1/qqYmAHX8IWFuuaNh6ztjkAbXxOaA6pG/K7e04PMXaNftX2KXIzb/nginiRO Q67D/bHNEKBvemz2xYnKqc1zjV+U7Y/ir2+mLemqy/uTB5Zp4IzeVE+4RMXVI4P5iFOh q8mQ== X-Gm-Message-State: AJcUukftWc8GaQMLF3MwavXQac4gIJxR2G2z39zqny6aC0KIqLjp69uy EpHcgGNi5aKisAi878oCb92PhQZm+0WNkSv1a5l20A== X-Received: by 2002:a67:6f82:: with SMTP id k124mr10474631vsc.42.1548766153268; Tue, 29 Jan 2019 04:49:13 -0800 (PST) MIME-Version: 1.0 References: <20190129084737.718-1-hans@owltronix.com> In-Reply-To: From: Hans Holmberg Date: Tue, 29 Jan 2019 13:49:02 +0100 Message-ID: Subject: Re: [PATCH] lightnvm: pblk: extend line wp balance check To: =?UTF-8?Q?Javier_Gonz=C3=A1lez?= Cc: =?UTF-8?Q?Matias_Bj=C3=B8rling?= , Zhoujie Wu , linux-block@vger.kernel.org, Linux Kernel Mailing List , Hans Holmberg Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 29, 2019 at 12:19 PM Javier Gonz=C3=A1lez = wrote: > > > > On 29 Jan 2019, at 09.47, 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 ch= eck > > to cover this case. > > > > Signed-off-by: Hans Holmberg > > --- > > > > This patch applies on top of Zhoujie's V3 of > > "lightnvm: pblk: ignore bad block wp for pblk_line_wp_is_unbalanced > > > > drivers/lightnvm/pblk-recovery.c | 60 ++++++++++++++++++++------------ > > 1 file changed, 37 insertions(+), 23 deletions(-) > > > > diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-r= ecovery.c > > index 02d466e6925e..d86f580036d3 100644 > > --- a/drivers/lightnvm/pblk-recovery.c > > +++ b/drivers/lightnvm/pblk-recovery.c > > @@ -302,41 +302,55 @@ static int pblk_pad_distance(struct pblk *pblk, s= truct pblk_line *line) > > return (distance > line->left_msecs) ? line->left_msecs : distanc= e; > > } > > > > -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 =3D pblk->dev; > > struct nvm_geo *geo =3D &dev->geo; > > - struct pblk_line_meta *lm =3D &pblk->lm; > > struct pblk_lun *rlun; > > - struct nvm_chk_meta *chunk; > > struct ppa_addr ppa; > > - u64 line_wp; > > - int pos, i, bit; > > + int pos; > > > > - bit =3D find_first_zero_bit(line->blk_bitmap, lm->blk_per_line); > > - if (bit >=3D lm->blk_per_line) > > - return 0; > > - rlun =3D &pblk->luns[bit]; > > + rlun =3D &pblk->luns[index]; > > ppa =3D rlun->bppa; > > pos =3D pblk_ppa_to_pos(geo, ppa); > > - chunk =3D &line->chks[pos]; > > > > - line_wp =3D chunk->wp; > > + return &line->chks[pos]; > > +} > > > > - for (i =3D bit + 1; i < lm->blk_per_line; i++) { > > - rlun =3D &pblk->luns[i]; > > - ppa =3D rlun->bppa; > > - pos =3D pblk_ppa_to_pos(geo, ppa); > > - chunk =3D &line->chks[pos]; > > +static int pblk_line_wps_are_unbalanced(struct pblk *pblk, > > + struct pblk_line *line) > > +{ > > + struct pblk_line_meta *lm =3D &pblk->lm; > > + int blk_in_line =3D lm->blk_per_line; > > + struct nvm_chk_meta *chunk; > > + u64 max_wp, min_wp; > > + int i; > > > > - if (chunk->state & NVM_CHK_ST_OFFLINE) > > - continue; > > + i =3D 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 >=3D (blk_in_line - 1)) > > + return 0; > > > > - if (chunk->wp > line_wp) > > + chunk =3D pblk_get_stripe_chunk(pblk, line, i); > > + max_wp =3D chunk->wp; > > + if (max_wp > pblk->max_write_pgs) > > + min_wp =3D max_wp - pblk->max_write_pgs; > > + else > > + min_wp =3D 0; > > + > > + i =3D find_next_zero_bit(line->blk_bitmap, blk_in_line, i + 1); > > + while (i < blk_in_line) { > > + chunk =3D 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 =3D chunk->wp; > > + > > + i =3D find_next_zero_bit(line->blk_bitmap, blk_in_line, i= + 1); > > } > > > > return 0; > > @@ -362,7 +376,7 @@ static int pblk_recov_scan_oob(struct pblk *pblk, s= truct pblk_line *line, > > int ret; > > u64 left_ppas =3D pblk_sec_in_open_line(pblk, line) - lm->smeta_s= ec; > > > > - 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 =3D p.ppa_list; > > -- > > 2.17.1 > > If I am understanding correctly, you want to protect against the case > where a pfail has broken the ws_min partition of a chunk, right? I say > this because there is a guarantee that the minimal write size and pblk's > write size align with ws_min and ws_opt. Even if we have grown bad > blocks on pfail for the current line (which is a bigger problem because > we have potentially lost data), this guarantee would remain. > > If this is the case, my first reaction would be to say that the > controller is responsible for guaranteeing atomicity for both scalar and > vector I/Os. If this is not guaranteed, we have bigger problems than > this (e.g., for the write error recovery path). > > Are you thinking of a different case? The write pointer check triggers a warning if something unexpected has happened to the chunks. i.e. if something else than pblk messed with the disk, or if the user tries to recover a pblk instance with an invalid lun configuration. This patch adds a warning if a chunk wp is too small(i.e. if a chunk was unexpectedly reset) > > Javier >