From: Brian Norris <computersforpeace@gmail.com>
To: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>,
David Woodhouse <dwmw2@infradead.org>
Cc: "sztomi89@gmail.com" <sztomi89@gmail.com>,
"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
David Woodhouse <dwmw2@infradead.org>,
Artem Bityutskiy <dedekind1@gmail.com>,
Thomas Betker <thomas.betker@freenet.de>,
Ming Liu <liu.ming50@gmail.com>,
Deng Chao <deng.chao1@zte.com.cn>,
wangzaiwei <wangzaiwei@top-vision.cn>,
Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: JFFS2 deadlock
Date: Wed, 27 Jan 2016 16:05:59 -0800 [thread overview]
Message-ID: <20160128000559.GA14270@google.com> (raw)
In-Reply-To: <1453910781.20662.35.camel@infinera.com>
+ David (maintainer), linux-fsdevel, and others
On Wed, Jan 27, 2016 at 04:05:35PM +0000, Joakim Tjernlund wrote:
> On Wed, 2016-01-27 at 16:36 +0100, Szabó Tamás wrote:
> > Hello all,
> >
> > I work on an embedded system running Linux 3.10 and found a deadlock
> > situation between jffs2_readpage and jffs2_write.
> > The problem is present on the latest 4.4 kernel too and occurs when
> > two tasks want to access the same file, one reads and the other writes it.
> >
> > The kernel stack traces for writer and reader in deadlock:
> >
> > __switch_to+0x4c/0x98
> > sleep_on_page+0x10/0x24
> > __lock_page+0x8c/0x9c
> > find_lock_page+0x7c/0x94
> > grab_cache_page_write_begin+0x64/0xd8
> > jffs2_write_begin+0x6c/0x2ec
> > generic_file_buffered_write+0x188/0x258
> > __generic_file_aio_write+0x1e0/0x484
> > generic_file_aio_write+0x70/0xfc
> > do_sync_write+0x7c/0xd4
> > vfs_write+0xc8/0x1b0
> > SyS_write+0x4c/0xa8
> > ret_from_syscall+0x0/0x38
> >
> > __switch_to+0x4c/0x98
> > jffs2_readpage+0x28/0x5c
> > generic_file_aio_read+0x22c/0x7a0
> > do_sync_read+0x7c/0xd4
> > vfs_read+0xb0/0x170
> > SyS_read+0x4c/0xa8
> > ret_from_syscall+0x0/0x38
> >
> > The root cause here is the locking order of f->sem mutex and pagelock.
> > jffs2_readpage function gets the page in locked state and then locks
> > the f->sem mutex, while jffs2_write_begin does it in reverse order.
> >
> > I found a commit that brought in this bug.
> > That was a fix for another deadlock issue:
> > https://github.com/torvalds/linux/commit/5ffd3412ae5536a4c57469cb8ea31887121dcb2e
> >
> > According to this commit and my code inspections the lock orders may be
> > the following:
> > readpage: page lock, f->sem
> > writepage_begin: f->sem, page lock
> > writepage_end: page lock, f->sem
> > GC: f->sem, page lock
>
> I am not sure if this is the first time I hear this or if someone else has reported
> a similar issue.
No, I'm pretty sure this is not the first report. I think there have
even been patches. The problem is that JFFS2 is effectively
unmaintained, despite what MAINTAINERS has to say about it.
Previous reports:
Subject: Another JFFS2 deadlock, kernel 3.4.11
http://thread.gmane.org/gmane.linux.drivers.mtd/62523
Subject: [JFFS2] Revision "jffs2: Fix lock acquisition order bug in
jffs2_write_begin" introduces another dead lock.
http://thread.gmane.org/gmane.linux.drivers.mtd/47986
There are other reports of deadlocks in jffs2_readpage, but in my
limited scanning, they look slightly different, so I won't include them
in this list.
For reference: outstanding patches, waiting for a maintainer (I've been
keeping patchwork up-to-date, mostly, but I'm not touching JFFS2 myself,
for the most part):
http://patchwork.ozlabs.org/project/linux-mtd/list/?q=jffs2
I'm tempted to resurrect this patch, to mark JFFS2 as Orphaned /
Obsolete:
http://patchwork.ozlabs.org/patch/422160/
David, can you please clarify your role here? Are you maintaining JFFS2
or not? Or perhaps someone else should be added? I don't really know any
interested parties.
Maybe the MAINTAINERS entry should be directed to linux-fsdevel too?
Brian
next parent reply other threads:[~2016-01-28 0:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAKatumo13ZM2o3dK9_ouxzta-sxeiB5E236Qh5dfbnEBc9CuMw@mail.gmail.com>
[not found] ` <1453910781.20662.35.camel@infinera.com>
2016-01-28 0:05 ` Brian Norris [this message]
2016-01-28 8:16 ` JFFS2 deadlock Thomas.Betker
2016-02-01 14:28 ` David Woodhouse
2016-02-01 18:54 ` Thomas.Betker
[not found] ` <OF2969B332.8B296F0B-ONC1257F4C.006307EB-C1257F4C.0067DE44@LocalDomain>
2016-02-18 9:57 ` Thomas.Betker
2016-02-25 7:46 ` Joakim Tjernlund
2016-02-25 9:57 ` Thomas.Betker
2016-02-25 11:22 ` David Woodhouse
2016-02-25 17:57 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160128000559.GA14270@google.com \
--to=computersforpeace@gmail.com \
--cc=Joakim.Tjernlund@infinera.com \
--cc=dedekind1@gmail.com \
--cc=deng.chao1@zte.com.cn \
--cc=dwmw2@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=liu.ming50@gmail.com \
--cc=sztomi89@gmail.com \
--cc=thomas.betker@freenet.de \
--cc=viro@zeniv.linux.org.uk \
--cc=wangzaiwei@top-vision.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).