JFFS2 deadlock, kernel 3.4.11
Joakim Tjernlund
joakim.tjernlund at transmode.se
Thu Oct 4 14:55:28 EDT 2012
>
> Thomas.Betker at rohde-schwarz.com wrote on 2012/10/04 18:51:58:
> >
> > Hello Joakim:
> >
> > > Try Reply With Internet-style History (We use Notes here too)
> >
> > Got it. Thanks!
> >
> > > > jffs2_reserve_space() must not be called with f->sem held because it
> > > > acquires c->alloc_sem.
> > >
> > > hmm, are you sure? Did it fail?
> > > As far as I can see jffs2_garbage_collect_live() does this.
> >
> > jffs2_reserve_space() does mutex_lock(&c->alloc_sem) first thing, and
> > README.Locking says "Never attempt to allocate space or lock alloc_sem
> > with any f->sem held.". So I didn't even try; yes, I am a coward. (:-)
> > Also, all the code I checked carefully releases f->sem before calling
> > jffs2_reserve_space().
>
> I see, thanks.
>
> >
> > jffs2_garbage_collect_live() doesn't call jffs2_reserve_space() directly.
> > Is it called indirectly somehow?
>
> hmm, misread the code a bit so forget this comment.
>
> >
> > > > So I have moved mutex_lock(&f->sem) and grab_cache_page_write_begin()
> > > > after jffs2_reserve_space(). Attached is my 3.4.11 patch (which is
> > based
> > > > on your patch) for review; I hope it is not mangled by Lotus Notes ...
> > >
> > > don't have time to look ATM
> >
> > Okay. When the tests succeed, I will simply mail it to the list as a
> > regular patch, for general review.
>
> I think your patch will work, but I don't like having 2 call sites
> to grab_cache_page_write_begin(mapping, index, flags) so I came
> up with this instead(untested as well):
Forgot, could you add some debug code to test if pageofs <= inode->i_size:
ri.isize = cpu_to_je32(max((uint32_t)inode->i_size, pageofs));
....
if(pageofs <= inode->i_size) {
print debug stuff here
}
ri.dsize = cpu_to_je32(pageofs - inode->i_size);
Jocke
More information about the linux-mtd
mailing list