From: Andrew Morton <akpm@linux-foundation.org>
To: Dave Kleikamp <shaggy@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Will Trives <will@trivescon.com.au>,
linux-kernel@vger.kernel.org,
Nick Piggin <nickpiggin@yahoo.com.au>,
Chuck Ebbert <cebbert@redhat.com>
Subject: Re: [PATCH] fs: nobh_truncate_page() fix
Date: Mon, 5 Mar 2007 15:31:08 -0800 [thread overview]
Message-ID: <20070305153108.27bd0f33.akpm@linux-foundation.org> (raw)
In-Reply-To: <1173136211.9109.81.camel@kleikamp.austin.ibm.com>
On Mon, 05 Mar 2007 17:10:11 -0600
Dave Kleikamp <shaggy@linux.vnet.ibm.com> wrote:
> On Mon, 2007-03-05 at 14:57 -0800, Andrew Morton wrote:
> > Is OK, I think. nobh_prepare_write() brings the outside-from-and-to
> > sections of the page uptodate and memset in nobh_truncate_page() brings the
> > rest of the page uptodate.
> >
> > We bring the to->PAGE_CACHE_SIZE section uptodate twice, which could be
> > optimised.
>
> Why not have nobh_truncate_page() call prepare_write() with to =
> PAGE_CACHE_SIZE? I don't really grok:
>
> to = (offset + blocksize) & ~(blocksize - 1);
OK, let's say we have a 4k pagesize and a 1k fs blocksize and someone does
ftruncate(fd, 1024 + 100).
We need to:
- load bytes (0 ... 1024+100) from disk (these are live file data)
- zero the bytes (1024+100 ... 1024+1024) (these are data outside the
truncation point, but inside the fs block which straddles the truncation
point)
- zero the bytes (1024+1024 ... 4096) (these are the rest of the
pagecache page, outside the truncation point).
- mark the page dirty so those zeroes outside the truncation point but
inside the block which straddles i_size (ie: (1024+100 ... 1024+1024)
get written back.
Now, it just so happens that
nobh_prepare_write(NULL, page, 1024+100, 1024+1024)
will indeed load bytes (0 ... 1024+1024) from disk, and will then zero out
bytes (1024+100 ... 4096) for us (I think - assumes that ->get_block does
the right thing with buffer_mapped)). We could exploit that knowledge of
prepare_write() internals in nobh_truncate_page().
But as it stands, nobh_truncate_page() is being formal and is not making
assumptions about what nobh_prepare_write() does with blocks outside
i_size.
next prev parent reply other threads:[~2007-03-05 23:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-05 4:03 2.6.21-rc2-git3 Unstable for me Will Trives
2007-03-05 14:59 ` Chuck Ebbert
2007-03-05 15:36 ` Dave Kleikamp
2007-03-05 15:50 ` Dave Kleikamp
2007-03-05 20:58 ` [PATCH] fs: nobh_truncate_page() fix Dave Kleikamp
2007-03-05 21:43 ` Linus Torvalds
2007-03-05 22:57 ` Andrew Morton
2007-03-05 23:10 ` Dave Kleikamp
2007-03-05 23:31 ` Andrew Morton [this message]
2007-03-05 23:02 ` Dave Kleikamp
2007-03-05 22:25 ` 2.6.21-rc2-git3 Unstable for me Will Trives
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=20070305153108.27bd0f33.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=cebbert@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nickpiggin@yahoo.com.au \
--cc=shaggy@linux.vnet.ibm.com \
--cc=torvalds@linux-foundation.org \
--cc=will@trivescon.com.au \
/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