[Q] ubi->beb_rsvd_pebs calculations

Shmulik Ladkani shmulik.ladkani at gmail.com
Sun Jul 1 12:52:30 EDT 2012


Hi Artem,

While working on improving reserved bad PEBs calculations, I encounted
some code portion whose reasoning can't be easily understood.

I'd be happy if you can comment on the following:

from 'erase_worker' in wl.c:

> 	/* It is %-EIO, the PEB went bad */
> 
> 	if (!ubi->bad_allowed) {
> 		ubi_err("bad physical eraseblock %d detected", pnum);
> 		goto out_ro;
> 	}
> 
> 	spin_lock(&ubi->volumes_lock);
> 	need = ubi->beb_rsvd_level - ubi->beb_rsvd_pebs + 1;
> 	if (need > 0) {
> 		need = ubi->avail_pebs >= need ? need : ubi->avail_pebs;
> 		ubi->avail_pebs -= need;
> 		ubi->rsvd_pebs += need;
> 		ubi->beb_rsvd_pebs += need;
> 		if (need > 0)
> 			ubi_msg("reserve more %d PEBs", need);
> 	}

Why attempting to reclaim available PEBs into the 'beb_rsvd_pebs' here
within 'erase_worker'?
If 'beb_rsvd_pebs' was already below the required level, how could it be
that suddenly during 'erase_worker' more PEBs will be available?

The 2 other places which perform this "reclaim" are volume shrink and
volume remove. Within these places reclaim makes sense, as the
shrink/remove operations result in increasing the available PEBs.
(BTW the same code reclaiming beb_rsvd_pebs is duplicated, I've unified
all places).

However here in 'erase_worker' I expect either 'beb_rsvd_pebs' to already be
at the required level, or to be less than the required level - but in
the latter case reclaiming seems as a no-op.

What do you say?
Would you consider removing this "beb_rsvd_pebs reclaim" block?

Regards,
Shmulik



More information about the linux-mtd mailing list