LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Richard Weinberger <richard@nod.at>
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 10/14] ubi: fastmap: Change a WARN_ON() to ubi_err()
Date: Sun, 24 Jun 2018 15:04:47 +0200	[thread overview]
Message-ID: <20180624150447.0a2c745d@bbrezillon> (raw)
In-Reply-To: <20180613212344.11608-11-richard@nod.at>

On Wed, 13 Jun 2018 23:23:40 +0200
Richard Weinberger <richard@nod.at> wrote:

> This WARN_ON() was used while development of fastmap, now
> it can be a regular ubi_err().
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>  drivers/mtd/ubi/fastmap.c | 14 ++++++++------
>  1 file changed, 8 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
> index dabeb01af24a..d5506152c9f7 100644
> --- a/drivers/mtd/ubi/fastmap.c
> +++ b/drivers/mtd/ubi/fastmap.c
> @@ -949,14 +949,16 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
>  	ubi_assert(list_empty(&free));
>  
>  	/*
> -	 * If fastmap is leaking PEBs (must not happen), raise a
> -	 * fat warning and fall back to scanning mode.
> -	 * We do this here because in ubi_wl_init() it's too late
> -	 * and we cannot fall back to scanning.
> +	 * The orginal purpose of this check was detecting fastmap bugs were
> +	 * it missed blocks. Now it helps to detect mis-flashed UBIs.
> +	 * E.g. when a fastmap enabled UBI is copied to another target with
> +	 * different bad blocks.
>  	 */
> -	if (WARN_ON(count_fastmap_pebs(ai) != ubi->peb_count -
> -		    ai->bad_peb_count - fm->used_blocks))
> +	if (count_fastmap_pebs(ai) != ubi->peb_count - ai->bad_peb_count -
> +		fm->used_blocks) {

Nitpick, but can you align things like that:

	if (count_fastmap_pebs(ai) != ubi->peb_count - ai->bad_peb_count -
				      fm->used_blocks) {

or

	if (count_fastmap_pebs(ai) !=
	    ubi->peb_count - ai->bad_peb_count - fm->used_blocks) {

or even better, have an avail_peb_count variable:

	avail_peb_count = ubi->peb_count - ai->bad_peb_count - fm->used_blocks;
	if (count_fastmap_pebs(ai) != avail_peb_count)

> +		ubi_err(ubi, "number of PEBs referenced by fastmap does not match MTD!");
>  		goto fail_bad;

Also, I'm not sure I get it. Why is that an error now that we have
preseeded fastmap? Isn't it expected to have a potential mismatch the
first time we boot, or is it already taken into account before we reach
this point?



> +	}
>  
>  	return 0;
>  


  reply	other threads:[~2018-06-24 13:05 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-13 21:23 [PATCH 00/14] ubi: Fastmap updates Richard Weinberger
2018-06-13 21:23 ` [PATCH 01/14] ubi: fastmap: Read PEB numbers more carefully Richard Weinberger
2018-06-14  1:04   ` kbuild test robot
2018-06-14  6:23     ` Richard Weinberger
2018-06-20 10:17   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 02/14] ubi: Fix assert in ubi_wl_init Richard Weinberger
2018-06-20 10:11   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 03/14] ubi: fastmap: Add support for flags Richard Weinberger
2018-06-24 12:49   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 04/14] ubi: fastmap: Add UBI_FM_SB_PRESEEDED_FLG flag Richard Weinberger
2018-06-24 12:53   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 05/14] ubi: fastmap: Implement PEB translation Richard Weinberger
2018-06-13 21:23 ` [PATCH 06/14] ubi: fastmap: Handle bad block count for preseeded fastmap case Richard Weinberger
2018-06-13 21:23 ` [PATCH 07/14] ubi: fastmap: Fixup pool sizes for preseeded fastmaps Richard Weinberger
2018-06-13 21:23 ` [PATCH 08/14] ubi: fastmap: Scan empty space if fastmap is preseeded Richard Weinberger
2018-06-13 21:23 ` [PATCH 09/14] ubi: fastmap: Relax size check Richard Weinberger
2018-06-24 12:55   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 10/14] ubi: fastmap: Change a WARN_ON() to ubi_err() Richard Weinberger
2018-06-24 13:04   ` Boris Brezillon [this message]
2018-06-13 21:23 ` [PATCH 11/14] ubi: Add module parameter to force a full scan Richard Weinberger
2018-06-24 13:09   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 12/14] ubi: uapi: Add mode selector to attach request Richard Weinberger
2018-06-24 13:12   ` Boris Brezillon
2018-06-13 21:23 ` [PATCH 13/14] ubi: Wire up attach mode selector Richard Weinberger
2018-06-13 21:23 ` [PATCH 14/14] ubi: Remove experimental stigma from Fastmap Richard Weinberger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180624150447.0a2c745d@bbrezillon \
    --to=boris.brezillon@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=richard@nod.at \
    --subject='Re: [PATCH 10/14] ubi: fastmap: Change a WARN_ON() to ubi_err()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).