Re: JFFS2 oops when writing to two partitions simultaneously

Joakim Tjernlund
2012-01-26T11:53:09Z

linux-mtd-bounces@lists.infradead.org wrote on 2012/01/26 10:02:07:

> From: Orjan Friberg <of@flatfrog.com>
> To: <linux-mtd@lists.infradead.org>
> Date: 2012/01/26 10:15
> Subject: Re: JFFS2 oops when writing to two partitions simultaneously
> Sent by: linux-mtd-bounces@lists.infradead.org
>
> On 01/25/2012 10:01 PM, Orjan Friberg wrote:
> > That one-liner was boiled down from the following program, which still
> > oopses instantly:
>
> The C program seems to work fine with CONFIG_PREEMPT_NONE=y.
>
> If that is indeed the problem I guess it's reasonable that it worked
> better with PREEMPT_VOLUNTARY than PREEMPT because there are fewer
> preemtion points.

The spin locking in jffs2_compress() seems broken:

case JFFS2_COMPR_MODE_SIZE:
case JFFS2_COMPR_MODE_FAVOURLZO:
orig_slen = *datalen;
orig_dlen = *cdatalen;
spin_lock(&jffs2_compressor_list_lock);
list_for_each_entry(this, &jffs2_compressor_list, list) {
/* Skip decompress-only backwards-compatibility and disabled modules */
if ((!this->compress)||(this->disabled))
continue;
/* Allocating memory for output buffer if necessary */
if ((this->compr_buf_size < orig_slen) && (this->compr_buf)) {
spin_unlock(&jffs2_compressor_list_lock);

kfree(this->compr_buf);
spin_lock(&jffs2_compressor_list_lock);
this->compr_buf_size=0;
this->compr_buf=NULL;
}

....

if 2 threads are competing here, I don't think you can drop the spin lock
temporarily as this routine do.

Jocke