From: Ben Myers <bpm@sgi.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs@oss.sgi.com, Andrew Dahl <adahl@sgi.com>
Subject: Re: [PATCH 1/4] xfs: remove xfs_tosspages
Date: Tue, 13 Nov 2012 15:29:03 -0600 [thread overview]
Message-ID: <20121113212903.GC19387@sgi.com> (raw)
In-Reply-To: <20121112230029.GW24575@dastard>
Hi Dave,
On Tue, Nov 13, 2012 at 10:00:29AM +1100, Dave Chinner wrote:
> On Mon, Nov 12, 2012 at 02:43:03PM -0600, Andrew Dahl wrote:
> > On 11/09/2012 04:10 AM, Dave Chinner wrote:
> > > From: Dave Chinner <dchinner@redhat.com>
> > >
> > > It's a buggy, unnecessary wrapper that is duplicating
> > > truncate_pagecache_range().
> > >
> > > When replacing the call in xfs_change_file_space(), also ensure that
> > > the length being allocated/freed is always positive before making
> > > any changes. These checks are done in the lower extent manipulation
> > > functions, too, but we need to do them before any page cache
> > > operations.
> > >
> > > Reported-by: Andrew Dahl <adahl@sgi.com>
> > > Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ....
> > > @@ -2169,7 +2186,8 @@ xfs_change_file_space(
> > > switch (cmd) {
> > > case XFS_IOC_ZERO_RANGE:
> > > prealloc_type |= XFS_BMAPI_CONVERT;
> > > - xfs_tosspages(ip, startoffset, startoffset + bf->l_len, 0);
> > > + truncate_pagecache_range(VFS_I(ip), startoffset,
> > > + round_down(startoffset + bf->l_len, PAGE_SIZE) - 1);
> >
> > When calling XFS_IOC_ZERO_RANGE with a range [0, 4095] or [0,1] it's
> > tossing pages because the call to round_down() is returning 0 and
> > passing -1 in for the end will toss all pages. So, we need to make sure
> > round_down() isn't going to return a 0, or that (startoffset +
> > bf->l_len) > PAGE_SIZE.
>
> Right, which was the original bug. I didn't think that through
> fully....
>
> > So, something like...
> >
> >
> > xfs_off_t end;
> >
> > [...]
> >
> > if((end = round_down(startoffset + bf->l_len, PAGE_SIZE)) > 0) {
> > truncate_pagecache_range(VFS_I(ip), startoffset, end - 1);
> > }
>
> Actually, it is more complex than that. Think of the range [4096,
> 4097]. That would result in passing 4096, 4095 to
> truncate_pagecache_range(), which is also wrong but implicitly
> handled correctly in truncate_inode_pages_range(). Hence it should
> be:
>
> end = round_down(startoffset + bf->l_len, PAGE_SIZE) - 1;
> if (startoffset > end)
> truncate_pagecache_range(VFS_I(ip), startoffset, end);
>
> That's similar to your original fix, which had a last < first check
> in it. I'll post a fix in a few minutes...
I'd like to pull this in tomorrow. Could you get this one sorted out today?
If not, I think we could also enlist Andrew to fix it.
Regards,
Ben
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-11-13 21:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-09 10:10 [PATCH 0/4] xfs: fs/xfs/xfs_fs_subr.c die die die Dave Chinner
2012-11-09 10:10 ` [PATCH 1/4] xfs: remove xfs_tosspages Dave Chinner
2012-11-12 20:43 ` Andrew Dahl
2012-11-12 23:00 ` Dave Chinner
2012-11-13 21:29 ` Ben Myers [this message]
2012-11-09 10:10 ` [PATCH 2/4] xfs: remove xfs_wait_on_pages() Dave Chinner
2012-11-12 20:44 ` Andrew Dahl
2012-11-09 10:10 ` [PATCH 3/4] xfs: remove xfs_flush_pages Dave Chinner
2012-11-12 20:50 ` Andrew Dahl
2012-11-09 10:10 ` [PATCH 4/4] xfs: remove xfs_flushinval_pages Dave Chinner
2012-11-12 22:38 ` Andrew Dahl
2012-11-09 17:40 ` [PATCH 0/4] xfs: fs/xfs/xfs_fs_subr.c die die die Ben Myers
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=20121113212903.GC19387@sgi.com \
--to=bpm@sgi.com \
--cc=adahl@sgi.com \
--cc=david@fromorbit.com \
--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 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.