[PATCH] [RFC] UBI: Implement Fastmap support

Adrian Hunter adrian.hunter at intel.com
Thu May 31 06:37:56 EDT 2012


On 23/05/12 14:06, Richard Weinberger wrote:
> Fastmap (aka checkpointing) allows attaching of an UBI volume in nearly
> constant time. Only a fixed number of PEBs has to be scanned.
> 
> Signed-off-by: Richard Weinberger <richard at nod.at>
> ---
>  drivers/mtd/ubi/Makefile    |    2 +-
>  drivers/mtd/ubi/attach.c    |   34 +-
>  drivers/mtd/ubi/build.c     |   25 +
>  drivers/mtd/ubi/eba.c       |   18 +-
>  drivers/mtd/ubi/fastmap.c   | 1240 +++++++++++++++++++++++++++++++++++++++++++
>  drivers/mtd/ubi/ubi-media.h |  119 +++++
>  drivers/mtd/ubi/ubi.h       |   68 +++-
>  drivers/mtd/ubi/wl.c        |  184 +++++++-
>  8 files changed, 1667 insertions(+), 23 deletions(-)
>  create mode 100644 drivers/mtd/ubi/fastmap.c
> 

...

> diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
> new file mode 100644
> index 0000000..7757e5a

...

> +/**
> + * ubi_find_fastmap - searches the first UBI_FM_MAX_START PEBs for the
> + * fastmap super block.
> + * @ubi: UBI device object
> + */
> +static int ubi_find_fastmap(struct ubi_device *ubi, int *fm_start)
> +{
> +	int i, ret;
> +	struct ubi_vid_hdr *vhdr;
> +
> +	vhdr = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL);
> +	if (!vhdr)
> +		return -ENOMEM;
> +
> +	for (i = 0; i < UBI_FM_MAX_START; i++) {
> +		ret = ubi_io_read_vid_hdr(ubi, i, vhdr, 0);
> +		if (ret < 0)
> +			break;
> +		else if (ret > 0)
> +			continue;
> +
> +		if (be32_to_cpu(vhdr->vol_id) == UBI_FM_SB_VOLUME_ID) {
> +			*fm_start = i;
> +			dbg_bld("Found fastmap super block at PEB %i\n", i);
> +			ret = 0;
> +
> +			break;

How do you know that this is the current fastmap and not a remnant of an old
fastmap?

> +		}
> +	}
> +
> +	ubi_free_vid_hdr(ubi, vhdr);
> +
> +	return ret;
> +}




More information about the linux-mtd mailing list