Re: JFFS2 oops when writing to two partitions simultaneously

Joakim Tjernlund
2012-01-26T14:23:30Z

Orjan Friberg <of@flatfrog.com> wrote on 2012/01/26 15:07:07:
>
> On 01/26/2012 02:16 PM, Joakim Tjernlund wrote:
> > Anyhow, I think it is stupid (and probably buggy) to have kfree and kmalloc
> > as separate. Why is it not done at the same time?
>
> To me it looks like the lock must be held the entire time. We can't
> allow two contexts using (i.e. freeing/allocating/writing to) the
> compressor's compr_buf.

This is more complex than I got time for. I can say there is more to it though.
Compare
case JFFS2_COMPR_MODE_PRIORITY:
output_buf = kmalloc(*cdatalen,GFP_KERNEL);

and

case JFFS2_COMPR_MODE_SIZE:
case JFFS2_COMPR_MODE_FAVOURLZO:
orig_slen = *datalen;
orig_dlen = *cdatalen;
..
tmp_buf = kmalloc(orig_slen, GFP_KERNEL);

It is not the same len used to kmalloc!

I would stay away from JFFS2_COMPR_MODE_SIZE and JFFS2_COMPR_MODE_FAVOURLZO
all together as it looks broken in more than one way.

>
> Maybe the lock used here should be on a per-compressor basis, rather
> than on the list as a whole. (The list lock is still needed when adding
> to/removing from the list of course.)
>
> --
> Orjan Friberg
> FlatFrog Laboratories AB