From: Andrew Morton <akpm@digeo.com>
To: "Stephen C. Tweedie" <sct@redhat.com>
Cc: Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>,
Jan Hudec <bulb@ucw.cz>, Martin Maletinsky <maletinsky@scs.ch>,
linux-mm@kvack.org, kernelnewbies@nl.linux.org
Subject: Re: Question on set_page_dirty()
Date: Thu, 12 Dec 2002 10:20:05 -0800 [thread overview]
Message-ID: <3DF8D355.2219084A@digeo.com> (raw)
In-Reply-To: <1039696963.2420.1.camel@sisko.scot.redhat.com>
"Stephen C. Tweedie" wrote:
>
> Hi,
>
> On Thu, 2002-12-12 at 09:29, Ingo Oeser wrote:
> > set_page_dirty() can be used in all cases, IMHO, since it:
> > - will not sleep
> ...
>
> Unfortunately, it can take both the inode_lock and pagecache_lock
> spinlocks, so if you use it in the wrong place, with other locks already
> held, you can cause a deadlock. So you _do_ need to be a bit careful,
> and you can't just use it with abandon.
>
And in 2.5 the pagecache_lock is per-inode. This ends up meaning that
it is not legal to run set_page_dirty(page) unless the caller has
done something to prevent the thing at page->mapping from being freed.
If that has not been done, it is conceivable (but hugely unlikely) that
the page could be truncated from its mapping and that mapping could be
thrown away while set_page_dirty() is trying to claim its ->page_lock.
So in 2.5, set_page_dirty() is only legal if the caller has a ref against
page->mapping->host, or if the page is locked.
It's currently wrong in a couple of places. I have local fixes for
the VM, and direct-IO still needs to be done. It will just be:
lock_page(page); /* pins page->mapping */
set_page_dirty(page);
unlock_page(page);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/
prev parent reply other threads:[~2002-12-12 18:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-10 9:59 Martin Maletinsky
2002-12-11 8:01 ` Jan Hudec
2002-12-12 9:29 ` Ingo Oeser
2002-12-12 12:42 ` Stephen C. Tweedie
2002-12-12 18:20 ` Andrew Morton [this message]
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=3DF8D355.2219084A@digeo.com \
--to=akpm@digeo.com \
--cc=bulb@ucw.cz \
--cc=ingo.oeser@informatik.tu-chemnitz.de \
--cc=kernelnewbies@nl.linux.org \
--cc=linux-mm@kvack.org \
--cc=maletinsky@scs.ch \
--cc=sct@redhat.com \
/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