public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: Sascha Hauer <s.hauer@pengutronix.de>, linux-mtd@lists.infradead.org
Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Subject: Re: [PATCH 2/2] ubiformat: Leave space for fastmap anchor
Date: Wed, 22 Oct 2014 10:15:01 +0200	[thread overview]
Message-ID: <54476785.5020603@nod.at> (raw)
In-Reply-To: <1413964111-4048-3-git-send-email-s.hauer@pengutronix.de>

Am 22.10.2014 um 09:48 schrieb Sascha Hauer:
> The fastmap code needs a free eraseblock in the first 64 erasblocks
> to write a fastmap anchor. Since ubiformat continuously writes the
> image to the flash the fastmap code won't find a free block and
> fastmap will be disabled. 

If UBI is unable to write a fastmap it will try again later.
So, it will be not disabled.

> With this patch ubiformat skips flashing
> a block at the beginning thus allowing the fastmap code to write
> an anchor.

Hmm, this is a bit hacky. What prevents UBI itself from using this free PEB
after the first attach? I.e. if a bitflip happens?
The in kernel code has already a mechanism to move used PEBs < 64 to make space
for the anchor.
IMHO the only sane approach is to create a fastmap enabled image directly with ubiformat.
While creating the initial fastmap code I had the plan to make mtd-tools fastmap aware
but simply run out of budget and so far nobody cared enough.

Thanks,
//richard

> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
>  ubi-utils/ubiformat.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
> index 2269cdf..df43df3 100644
> --- a/ubi-utils/ubiformat.c
> +++ b/ubi-utils/ubiformat.c
> @@ -518,6 +518,7 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
>  		       const struct ubigen_info *ui, struct ubi_scan_info *si)
>  {
>  	int fd, img_ebs, eb, written_ebs = 0, divisor, skip_data_read = 0;
> +	int fastmap_anchor_done = 0;
>  	off_t st_size;
>  
>  	fd = open_file(&st_size);
> @@ -544,6 +545,15 @@ static int flash_image(libmtd_t libmtd, const struct mtd_dev_info *mtd,
>  		int err;
>  		char buf[mtd->eb_size];
>  
> +		if (!fastmap_anchor_done) {
> +			err = write_eraseblock(libmtd, mtd, ui, si, eb, NULL, 0);
> +			if (err < 0)
> +				goto out_close;
> +			if (err == 0)
> +				fastmap_anchor_done = 1;
> +			continue;
> +		}
> +
>  		if (!args.quiet && !args.verbose) {
>  			printf("\r" PROGRAM_NAME ": flashing eraseblock %d -- %2lld %% complete  ",
>  			       eb, (long long)(eb + 1) * 100 / divisor);
> 

  reply	other threads:[~2014-10-22  8:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-22  7:48 [PATCH] mtd-utils: ubiformat: Add fastmap support Sascha Hauer
2014-10-22  7:48 ` [PATCH 1/2] ubiformat: Factor out a write_eraseblock function Sascha Hauer
2014-10-22  7:48 ` [PATCH 2/2] ubiformat: Leave space for fastmap anchor Sascha Hauer
2014-10-22  8:15   ` Richard Weinberger [this message]
2014-10-22  8:19     ` Tanya Brokhman
2014-10-22  8:27       ` Richard Weinberger
2014-10-22  8:34       ` Richard Weinberger
2014-10-22 10:48         ` Tanya Brokhman
2014-10-22 10:51           ` Richard Weinberger
2014-10-22  9:01     ` Sascha Hauer

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=54476785.5020603@nod.at \
    --to=richard@nod.at \
    --cc=artem.bityutskiy@linux.intel.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox