From: Theodore Ts'o <tytso@mit.edu>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Mike Marshall <hubcap@omnibond.com>,
Christoph Hellwig <hch@lst.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Stephen Rothwell <sfr@canb.auug.org.au>,
Boaz Harrosh <ooo@electrozaur.com>,
Greg Kroah-Hartman <greg@kroah.com>
Subject: Re: [GIT PULL] Orangefs (text only resend)
Date: Mon, 7 Sep 2015 20:47:54 -0400 [thread overview]
Message-ID: <20150908004754.GA690@thunk.org> (raw)
In-Reply-To: <20150907232206.GL22011@ZenIV.linux.org.uk>
On Tue, Sep 08, 2015 at 12:22:06AM +0100, Al Viro wrote:
> You don't want e.g. to have allocation request triggering an attempt to write
> a dirty page on a shared mapping of a file from your fs while you are holding
> a mutex that would block that attempt *and* waiting for a allocation to
> succeed.
Mike,
To be more explicit --- any code in your writepage/writepages
function, or code called from your writepage/writepages function has
to do all of its allocations using GFP_NOFS. Otherwise, you can end
up in a recursion where an attempt to writeback a page can trigger the
VM system to try to writeback either the same page or another page,
and then Hilarity Ensues, with either the code self-deadlocking, or in
the best case, the kernel stack getting overrun.
Note that in some cases, you could be calling kernel code that has no
idea that it is being called a context which requires GFP_NOFS. In
the past, I've had to change code in fs/buffer.c so that it would take
a gfp_t argument, so that when it is called from a GFP_NOFS context,
we can pass in a GFP so memory allocations won't result in a recursion
back into the fs code.
Similarly, if you have code which is not in the writepage/writepages
code path, but which holds a lock which would block
writepage()/writepages() from making forward progress, then you could
be holding the lock, have the memory allocation force the page cleaner
into action, which then tries calling your writepage()/writepages()
function, which then runs into the lock that was being held at the
time of the memory allocation, and once again, Hilarity Ensues[1].
Hope this helps,
- Ted
[1] http://tvtropes.org/pmwiki/pmwiki.php/Main/HilarityEnsues
(Well, it may not be that hilarious if you're the poor sucker trying
to debug the deadlock, but....)
next prev parent reply other threads:[~2015-09-08 0:48 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 15:42 [GIT PULL] Orangefs (text only resend) Mike Marshall
2015-09-02 23:34 ` Linus Torvalds
2015-09-03 1:13 ` Mike Marshall
2015-09-03 1:28 ` Linus Torvalds
2015-09-03 20:22 ` Linus Torvalds
2015-09-03 22:18 ` Mike Marshall
2015-09-03 22:44 ` Greg Kroah-Hartman
2015-09-06 6:35 ` Christoph Hellwig
2015-09-06 9:08 ` Al Viro
2015-09-06 14:52 ` Mike Marshall
2015-09-06 15:00 ` Mike Marshall
2015-09-06 20:20 ` Al Viro
2015-09-07 6:37 ` Al Viro
2015-09-07 21:10 ` Mike Marshall
2015-09-07 23:22 ` Al Viro
2015-09-08 0:47 ` Theodore Ts'o [this message]
2015-09-08 2:49 ` Dave Chinner
2015-09-08 14:48 ` Christoph Hellwig
2015-09-08 18:21 ` Mike Marshall
2015-09-09 15:05 ` Mike Marshall
2015-09-11 21:12 ` Mike Marshall
2015-09-11 22:24 ` Al Viro
2015-09-13 11:56 ` Mike Marshall
2015-09-11 23:20 ` Linus Torvalds
2015-09-13 11:59 ` Mike Marshall
2015-09-06 14:35 ` Mike Marshall
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=20150908004754.GA690@thunk.org \
--to=tytso@mit.edu \
--cc=akpm@linux-foundation.org \
--cc=greg@kroah.com \
--cc=hch@lst.de \
--cc=hubcap@omnibond.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=ooo@electrozaur.com \
--cc=sfr@canb.auug.org.au \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.