Commit 0525dac9 authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBI: do not put eraseblocks to the corrupted list unnecessarily

Currently UBI maintains 2 lists of PEBs during scanning:
1. 'erase' list - PEBs which have no corruptions but should be erased
2. 'corr' list - PEBs which have some corruptions and should be erased

But we do not really need 2 lists for PEBs which should be erased after
scanning is done - this is redundant. So this patch makes sure all PEBs
which are corrupted are moved to the head of the 'erase' list. We add
them to the head to make sure they are erased first and we get rid of
corruption ASAP.

However, we do not remove the 'corr' list and realted functions, because
the plan is to use this list for other purposes. Namely, we plan to
put eraseblocks with corruption which does not look like it was caused
by unclean power cut. Then we'll preserve thes PEBs in order to avoid
killing potentially valuable user data.

This patch also amends PEBs accounting, because it was closely tight to
the 'erase'/'corr' lists separation.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 3fb34124
This diff is collapsed.
......@@ -91,14 +91,13 @@ struct ubi_scan_volume {
* @erase: list of physical eraseblocks which have to be erased
* @alien: list of physical eraseblocks which should not be used by UBI (e.g.,
* those belonging to "preserve"-compatible internal volumes)
* @used_peb_count: count of used PEBs
* @corr_peb_count: count of PEBs in the @corr list
* @read_err_count: count of PEBs read with error (%UBI_IO_BAD_HDR_EBADMSG was
* returned)
* @free_peb_count: count of PEBs in the @free list
* @erase_peb_count: count of PEBs in the @erase list
* @empty_peb_count: count of PEBs which are presumably empty (contain only
* 0xFF bytes)
* @alien_peb_count: count of PEBs in the @alien list
* @bad_peb_count: count of bad physical eraseblocks
* @maybe_bad_peb_count: count of bad physical eraseblocks which are not marked
* as bad yet, but which look like bad
* @vols_found: number of volumes found during scanning
* @highest_vol_id: highest volume ID
* @is_empty: flag indicating whether the MTD device is empty or not
......@@ -119,13 +118,11 @@ struct ubi_scan_info {
struct list_head free;
struct list_head erase;
struct list_head alien;
int used_peb_count;
int corr_peb_count;
int read_err_count;
int free_peb_count;
int erase_peb_count;
int empty_peb_count;
int alien_peb_count;
int bad_peb_count;
int maybe_bad_peb_count;
int vols_found;
int highest_vol_id;
int is_empty;
......
......@@ -366,7 +366,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si,
* Probably this physical eraseblock went bad, try to pick
* another one.
*/
list_add_tail(&new_seb->u.list, &si->corr);
list_add(&new_seb->u.list, &si->erase);
goto retry;
}
kfree(new_seb);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment