[RFC] [PATCH] UBI: refine wear leveling logic

Artem Bityutskiy dedekind at infradead.org
Thu Mar 29 06:36:31 EDT 2007


Hi Alexander,

On Wed, 2007-03-28 at 15:47 +0200, Alexander Schmidt wrote:
> This patch addresses the handling of blocks that are put by the user
> while they are moved by the wear leveling thread. The schedule_erase
> function is now called by put_peb() itself instead of notifying the wear
> leveling thread.

May I ask you for more explanation why you think your code is correct?

> +
> +	if (in_wl_tree(e, &ubi->used))
> +		used_tree_del(ubi, e);
> +	else if (unlikely(in_wl_tree(e, &ubi->scrub)))
> +		scrub_tree_del(ubi, e);
> +	else if (!in_wl_tree(e, &ubi->free))
> +		prot_tree_del(ubi, e->pnum);
>  	spin_unlock(&ubi->wl_lock);
>  
>  	err = schedule_erase(ubi, e, torture);

Fine, you schedule this eraseblock for erasure. At the same time the the
WL worker moves data in there. The copy_leb() function will notice that
the LEB is unmapped, and won't do copy. Then the WL worker will insert
the eraseblock to a tree. At the same time the erase worker will insert
the same wl_entry to the free tree. One of the trees will be screwed-up.

-- 
Best regards,
Artem Bityutskiy (Битюцкий Артём)





More information about the linux-mtd mailing list