[PATCH 2/3] ubifs: add ubifs_mount_fixup_lebs()

Artem Bityutskiy dedekind1 at gmail.com
Thu May 5 07:49:10 EDT 2011


On Wed, 2011-05-04 at 18:02 -0400, Matthew L. Creech wrote:
> All makes sense Artem, thanks for the feedback.
> 
> On Wed, May 4, 2011 at 7:13 AM, Artem Bityutskiy <dedekind1 at gmail.com> wrote:
> > On Tue, 2011-05-03 at 18:55 -0400, Matthew L. Creech wrote:
> >> +
> >> +             if (!(lprops->flags & LPROPS_EMPTY) &&
> >
> > I think this is not quite right, because empty taken LEBs will not be
> > fixed up. I think you should only look at free space and nothing else.
> >
> 
> OK, however I did find that I needed to check for (lprops->flags &
> LPROPS_TAKEN) in addition to (lprops->free == c->leb_size) before
> unmapping a LEB.  Failing to do so caused this:
> 
> UBIFS error (pid 1): check_lpt_type: invalid type (15) in LPT node type 1
> UBIFS error (pid 1): ubifs_read_nnode: error -22 reading nnode at 8:783
> 
> so apparently it was unmapping part of the LPT, I guess?

Oh, right, the LPT subsystem contains the information about LEBs in the
main area, i.e., from LEBs number c->main_first to LEB number c->leb_cnt
- 1

The area which go _fefore_ the main are are special case.

The lprops area are LEBs from number c->lpt_first to number c->lpt_last.
For those you need to look at the ltab: 

c->ltab[lnum - c->lpt_first].free is what you need, where lnum is the
LEB number you need the amount of free space for.

For the orphans area [c->orph_first, c->orph_last] - you may to just
unmap them all, because when after mount this area does not contain any
useful data.

Master area - LEBs UBIFS_MST_LNUM and UBIFS_MST_LNUM + 1 - you know the
free space start at c->mst_offs + c->mst_node_alsz. So the amount of
used space there is c->mst_offs + c->mst_node_alsz and free space is
c->leb_size - c->mst_offs - c->mst_node_alsz; And it is the same for
both master area LEBs.

And finally the SB area (1 LEB) - you can skip this, but for
consistency, you can also fix it up. Amount of used space there is
always UBIFS_SB_NODE_SZ.

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




More information about the linux-mtd mailing list