From: Hugh Dickins <hugh@veritas.com>
To: "Michael S. Tsirkin" <mst@mellanox.co.il>
Cc: Gleb Natapov <gleb@minantech.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Petr Vandrovec <vandrove@vc.cvut.cz>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Badari Pulavarty <pbadari@us.ibm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: set_page_dirty vs set_page_dirty_lock
Date: Thu, 8 Dec 2005 19:19:45 +0000 (GMT) [thread overview]
Message-ID: <Pine.LNX.4.61.0512081908530.11737@goblin.wat.veritas.com> (raw)
In-Reply-To: <20051208190913.GA28482@mellanox.co.il>
On Thu, 8 Dec 2005, Michael S. Tsirkin wrote:
> Hi!
> The comment at set_page_dirty_lock says:
>
> /*
> * set_page_dirty() is racy if the caller has no reference against
> * page->mapping->host, and if the page is unlocked. This is because another
> * CPU could truncate the page off the mapping and then free the mapping.
> *
> * Usually, the page _is_ locked, or the caller is a user-space process which
> * holds a reference on the inode by having an open file.
> *
> * In other cases, the page should be locked before running set_page_dirty().
> */
>
> Still, I wander whether it might be OK to use set_page_dirty
> in another case - if I previously got a reference to the page
> with get_user_pages?
> The page wouldnt be written back in this case, would it?
It might be, there's no guarantee not. So if it was written back just
before you did your own dirtying of the page, you do need to set page dirty
again after (usually when releasing the pages got). And get_user_pages is
a typical case when set_page_dirty_lock is really needed - you don't
usually have any hold on the inode (if any) that backs those pages.
It can be very inconvenient (I don't know what to do for drivers/scsi/sg.c
than set_page_dirty and hope for the best, since it cannot wait for a lock
where it needs to). But I'm afraid you do have the very case where
set_page_dirty_lock is appropriate.
Many would be pleased if we could manage without set_page_dirty_lock.
> What if I'm in the middle of a system call?
What if you are?
Hugh
next prev parent reply other threads:[~2005-12-08 19:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-08 19:09 Michael S. Tsirkin
2005-12-08 19:19 ` Hugh Dickins [this message]
2005-12-08 19:29 ` Michael S. Tsirkin
2005-12-08 19:54 ` Jens Axboe
2005-12-08 21:56 ` Michael S. Tsirkin
2005-12-12 3:28 ` Nick Piggin
2005-12-12 6:35 ` Michael S. Tsirkin
2005-12-12 7:10 ` Nick Piggin
2005-12-12 8:14 ` Michael S. Tsirkin
2005-12-12 8:32 ` Nick Piggin
2005-12-12 8:55 ` Michael S. Tsirkin
2005-12-12 9:23 ` Nick Piggin
2005-12-12 9:59 ` Michael S. Tsirkin
2005-12-13 21:07 ` Michael S. Tsirkin
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=Pine.LNX.4.61.0512081908530.11737@goblin.wat.veritas.com \
--to=hugh@veritas.com \
--cc=benh@kernel.crashing.org \
--cc=gleb@minantech.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@mellanox.co.il \
--cc=nickpiggin@yahoo.com.au \
--cc=pbadari@us.ibm.com \
--cc=vandrove@vc.cvut.cz \
/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
all inboxes | Powered by JetHome®