Re: [PATCH 2/5] ubi: Limit amount of reserved eraseblocks for bad PEB handling

Richard Genoud
2012-07-09T10:15:34Z

2012/7/4 Shmulik Ladkani <shmulik.ladkani@gmail.com>:
> diff --git a/drivers/mtd/ubi/misc.c b/drivers/mtd/ubi/misc.c
> index f6a7d7a..e9dcb83 100644
> --- a/drivers/mtd/ubi/misc.c
> +++ b/drivers/mtd/ubi/misc.c
> @@ -98,10 +98,18 @@ int ubi_check_volume(struct ubi_device *ubi, int vol_id)
> */
> void ubi_calculate_reserved(struct ubi_device *ubi)
> {
> - ubi->beb_rsvd_level = ubi->good_peb_count/100;
> - ubi->beb_rsvd_level *= CONFIG_MTD_UBI_BEB_RESERVE;
> - if (ubi->beb_rsvd_level < MIN_RESEVED_PEBS)
> - ubi->beb_rsvd_level = MIN_RESEVED_PEBS;
> + /*
> + * Calculate the actual number of PEBs currently needed to be reserved
> + * for future bad eraseblock handling.
> + */
> + ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count;
> + if (ubi->beb_rsvd_level < 0) {
> + ubi->beb_rsvd_level = 0;
> + ubi_warn("number of bad PEBs (%d) is above the expected limit "
> + "(%d), not reserving any PEBs for bad PEB handling, "
> + "will use available PEBs (if any)",
> + ubi->bad_peb_count, ubi->bad_peb_limit);
> + }
> }
is it ok for beb_rsvd_level to be in the range [0..x[ instead of [2..x[ ?