public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* UBI: Incorrect initial value for ubi->avail_pebs
@ 2007-07-14 18:08 John Smith
  2007-07-17  8:29 ` Artem Bityutskiy
  0 siblings, 1 reply; 2+ messages in thread
From: John Smith @ 2007-07-14 18:08 UTC (permalink / raw)
  To: linux-mtd

Hello,

I suggest that the initial calculation of ubi->avail_pebs
is incorrect. But perhaps it is intentionally done this way.

A number of erase blocks, controlled by CONFIG_MTD_UBI_BEB_RESERVE,
are reserved for handling bad blocks. The number of actual bad blocks
are also reserved. I think it would be better if the actual bad blocks
were taken from the CONFIG_MTD_UBI_BEB_RESERVE allocation.

In more detail, during scan time the calculation of ubi->avail_pebs
goes roughly:

  /* in attach_by_scanning() */
  ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;

  /* in ubi_read_volume_table() */
  ubi->avail_pebs = ubi->good_peb_count;

  /* in init_volumes() */
  reserved_pebs =  sum of volume sizes
  reserved_pebs += size of layout volume
  ubi->avail_pebs -= reserved_pebs

  /* in ubi_wl_init_scan() */
  #define WL_RESERVED_PEBS 1
  ubi->avail_pebs -= WL_RESERVED_PEBS

  /* In calculate_reserved() */
  ubi->beb_rsvd_level = ubi->good_peb_count/100;
  ubi->beb_rsvd_level *= CONFIG_MTD_UBI_BEB_RESERVE;

  /* in ubi_eba_init_scan() */
  ubi->beb_rsvd_pebs = min(ubi->beb_rsvd_level, ubi->avail_pebs)
  ubi->avail_pebs -= ubi->beb_rsvd_pebs;

The effect is that existing bad blocks on the device are allocated
from the budget of blocks for data rather than from the budget of
blocks for bad blocks.

To fix, I suggest that in ubi_read_volume_table() in vtbl.c the
initial value of ubi->avail_pebs should be set by

    ubi->avail_pebs = ubi->peb_count ;

and for consistancy, the beb_rsvd_level should come from

  ubi->beb_rsvd_level = ubi->peb_count/100;
  ubi->beb_rsvd_level *= CONFIG_MTD_UBI_BEB_RESERVE;

But I accept that one could argue that the current implementation is
correct.

Regards,
John

John Smith
Blackburn, England.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-17  8:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-14 18:08 UBI: Incorrect initial value for ubi->avail_pebs John Smith
2007-07-17  8:29 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox