From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] iomap: zero cached pages over unwritten extents on zero range
Date: Wed, 28 Oct 2020 07:31:36 -0400 [thread overview]
Message-ID: <20201028113136.GB1610972@bfoster> (raw)
In-Reply-To: <20201027181552.GB32577@infradead.org>
On Tue, Oct 27, 2020 at 06:15:52PM +0000, Christoph Hellwig wrote:
> On Tue, Oct 20, 2020 at 12:21:50PM -0400, Brian Foster wrote:
> > Ugh, so the above doesn't quite describe historical behavior.
> > block_truncate_page() converts an unwritten block if a page exists
> > (dirty or not), but bails out if a page doesn't exist. We could still do
> > the above, but if we wanted something more intelligent I think we need
> > to check for a page before we get the mapping to know whether we can
> > safely skip an unwritten block or need to write over it. Otherwise if we
> > check for a page within the actor, we have no way of knowing whether
> > there was a (possibly dirty) page that had been written back and/or
> > reclaimed since ->iomap_begin(). If we check for the page first, I think
> > that the iolock/mmaplock in the truncate path ensures that a page can't
> > be added before we complete. We might be able to take that further and
> > check for a dirty || writeback page, but that might be safer as a
> > separate patch. See the (compile tested only) diff below for an idea of
> > what I was thinking.
>
> The idea looks reasonable, but a few comment below:
>
JFYI, I had posted an implementation of this idea here[1] and followed
up with some details on a similar COW related issue that was exposed
once the unwritten variant was addressed. I was reasoning about a
slightly different approach that might more clearly facilitate handling
both scenarios, but I think I mentioned to Darrick offline that this all
has me back to preferring the original patch to flush the new EOF block
first, at least as a first step.
I have a couple other fixes (one being the discard_page() patch you've
already commented on) related to iomap and I'm going to be offline for a
few weeks after this week so I'll try to collect them in a series and
get them posted together soon..
Brian
[1] https://lore.kernel.org/linux-fsdevel/20201021133329.1337689-1-bfoster@redhat.com/
> > +struct iomap_trunc_priv {
> > + bool *did_zero;
>
> I don't think there is any point on using a pointer here, when we
> can trivially copy out the scalar value.
>
> > + bool has_page;
>
> The naming of this flag really confuses me. Maybe has_data or
> in_pagecache might be better options?
>
> > +static loff_t
> > +iomap_truncate_page_actor(struct inode *inode, loff_t pos, loff_t count,
> > + void *data, struct iomap *iomap, struct iomap *srcmap)
> > +{
> > + struct iomap_trunc_priv *priv = data;
> > + unsigned offset;
> > + int status;
> > +
> > + if (srcmap->type == IOMAP_HOLE)
> > + return count;
> > + if (srcmap->type == IOMAP_UNWRITTEN && !priv->has_page)
> > + return count;
>
> Maybe add a comment here to explain why priv->has_page matters?
>
> > +
> > + offset = offset_in_page(pos);
>
> I'd move this on the initialization line.
>
> > + ret = iomap_apply(inode, pos, blocksize - off, IOMAP_ZERO, ops, &priv,
> > + iomap_truncate_page_actor);
> > + if (ret <= 0)
> > + return ret;
>
> The check could just be < 0 and would be a little more obvious.
>
next prev parent reply other threads:[~2020-10-29 2:45 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-12 14:03 [PATCH 0/2] iomap: zero dirty pages over unwritten extents Brian Foster
2020-10-12 14:03 ` [PATCH 1/2] iomap: use page dirty state to seek data " Brian Foster
2020-10-13 12:30 ` Brian Foster
2020-10-13 22:53 ` Dave Chinner
2020-10-14 12:59 ` Brian Foster
2020-10-14 22:37 ` Dave Chinner
2020-10-15 9:47 ` Christoph Hellwig
2020-10-19 16:55 ` Brian Foster
2020-10-27 18:07 ` Christoph Hellwig
2020-10-28 11:31 ` Brian Foster
2020-10-12 14:03 ` [PATCH 2/2] iomap: zero cached pages over unwritten extents on zero range Brian Foster
2020-10-15 9:49 ` Christoph Hellwig
2020-10-19 16:55 ` Brian Foster
2020-10-19 18:01 ` Brian Foster
2020-10-20 16:21 ` Brian Foster
2020-10-27 18:15 ` Christoph Hellwig
2020-10-28 11:31 ` Brian Foster [this message]
2020-10-23 1:02 ` [iomap] 11b5156248: xfstests.xfs.310.fail kernel test robot
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=20201028113136.GB1610972@bfoster \
--to=bfoster@redhat.com \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/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).