From: Chris Mason <chris.mason@oracle.com>
To: David Chinner <dgc@sgi.com>
Cc: Hugh Dickins <hugh@veritas.com>,
xfs@oss.sgi.com, linux-fsdevel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH 1 of 2] Implement generic block_page_mkwrite() functionality
Date: Thu, 8 Feb 2007 08:11:00 -0500 [thread overview]
Message-ID: <20070208131100.GH11967@think.oraclecorp.com> (raw)
In-Reply-To: <20070207225013.GQ44411608@melbourne.sgi.com>
On Thu, Feb 08, 2007 at 09:50:13AM +1100, David Chinner wrote:
> > You don't need to lock out all truncation, but you do need to lock
> > out truncation of the page in question. Instead of your i_size
> > checks, check page->mapping isn't NULL after the lock_page?
>
> Yes, that can be done, but we still need to know if part of
> the page is beyond EOF for when we call block_commit_write()
> and mark buffers dirty. Hence we need to check the inode size.
>
> I guess if we block the truncate with the page lock, then the
> inode size is not going to change until we unlock the page.
> If the inode size has already been changed but the page not yet
> removed from the mapping we'll be beyond EOF.
>
> So it seems to me that we can get away with not using the i_mutex
> in the generic code here.
vmtruncate changes the inode size before waiting on any pages. So,
i_size could change any time during page_mkwrite.
Since the patch does:
if (((page->index + 1) << PAGE_CACHE_SHIFT) > i_size_read(inode))
end = i_size_read(inode) & ~PAGE_CACHE_MASK;
else
end = PAGE_CACHE_SIZE;
It would be a good idea to read i_size once and put it in a local var
instead.
The FS truncate op should be locking the last page in the file to make
sure it is properly zero filled. The worst case should be that we zero
too many bytes in page_mkwrite (expanding truncate past our current
i_size), but at least it won't expose stale data.
-chris
next prev parent reply other threads:[~2007-02-08 13:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-07 12:49 [PATCH 1 of 2] Implement generic block_page_mkwrite() functionality David Chinner
2007-02-07 12:55 ` David Chinner
2007-02-07 13:00 ` Hugh Dickins
2007-02-07 14:44 ` David Chinner
2007-02-07 15:52 ` Chris Mason
2007-02-08 2:34 ` Nick Piggin
2007-02-07 15:56 ` Hugh Dickins
2007-02-07 22:50 ` David Chinner
2007-02-08 13:11 ` Chris Mason [this message]
2007-02-08 22:30 ` David Chinner
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=20070208131100.GH11967@think.oraclecorp.com \
--to=chris.mason@oracle.com \
--cc=dgc@sgi.com \
--cc=hugh@veritas.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=xfs@oss.sgi.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;
as well as URLs for NNTP newsgroup(s).