From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v3 2/4] iomap: lift zeroed mapping handling into iomap_zero_range()
Date: Fri, 15 Nov 2024 14:31:32 -0500 [thread overview]
Message-ID: <ZzehlDTBiBiVkzfC@bfoster> (raw)
In-Reply-To: <20241115170247.GH9421@frogsfrogsfrogs>
On Fri, Nov 15, 2024 at 09:02:47AM -0800, Darrick J. Wong wrote:
> On Fri, Nov 15, 2024 at 09:53:14AM -0500, Brian Foster wrote:
> > On Tue, Nov 12, 2024 at 09:00:35AM -0500, Brian Foster wrote:
> > > On Sun, Nov 10, 2024 at 10:03:44PM -0800, Christoph Hellwig wrote:
> > > > On Fri, Nov 08, 2024 at 07:42:44AM -0500, Brian Foster wrote:
> > > > > In preparation for special handling of subranges, lift the zeroed
> > > > > mapping logic from the iterator into the caller.
> > > >
> > > > What's that special code? I don't really see anything added to this
> > > > in the new code? In general I would prefer if all code for the
> > > > iteration would be kept in a single function in preparation for
> > > > unrolling these loops. If you want to keep this code separate
> > > > from the write zeroes logic (which seems like a good idea) please
> > > > just just move the actual real zeroing out of iomap_zero_iter into
> > > > a separate helper similar to how we e.g. have multiple different
> > > > implementations in the dio iterator.
> > > >
> > >
> > > There is no special code... the special treatment is to check the dirty
> > > state of a block unaligned start in isolation to decide whether to skip
> > > or explicitly zero if dirty. The fallback logic is to check the dirty
> > > state of the entire range and if needed, flush the mapping to push all
> > > pending (dirty && unwritten) instances out to the fs so the iomap is up
> > > to date and we can safely skip iomaps that are inherently zero on disk.
> > >
> > > Hmm.. so I see the multiple iter modes for dio, but it looks like that
> > > is inherent to the mapping type. That's not quite what I'm doing here,
> > > so I'm not totally clear on what you're asking for. FWIW, I swizzled
> > > this code around a few times and failed to ultimately find something I'd
> > > consider elegant. For example, initial versions would have something
> > > like another param to iomap_zero_iter() to skip the optimization logic
> > > (i.e. don't skip zeroed extents for this call), which I think is more in
> > > the spirit of what you're saying, but I ultimately found it cleaner to
> > > open code that part. If you had something else in mind, could you share
> > > some pseudocode or something to show the factoring..?
> > >
> >
> > FWIW, I'm concurrently hacking on what I'd consider a longer term fix
> > here, based on some of the earlier discussions. The idea is basically
> > iomap provides a mechanism for the fs to attach a folio_batch of dirty
> > folios to the iomap, which zero range can then use as the source of
> > truth for which subranges to zero of an unwritten mapping.
>
> That's fun! :)
>
> I wonder, can this mechanism stretch to the generic buffered write path?
> In which case, can you hang on to the folios long enough to issue
> writeback on them too, if it's a synchronous write?
>
That's an interesting idea. I think it could, but that's several steps
ahead of where I'm at. My current hope is that obviously this works
generically for zero range without the need to flush or revalidate
(unless as a fallback I suppose), and then from there the same thing can
be used for seek data/hole, which has similar wonkiness wrt unwritten
mappings.
From there, it might be interesting to see if there's value in this sort
of thing for buffered writes and whatnot. I'll keep that in mind.
> > It occurs to me that might lend itself a bit more to what you're looking
> > for here by avoiding the need for a new instance of the iter loop (I
> > assume there is some outstanding work that is affected by this?). Given
> > that this series was kind of a side quest for a band-aid performance fix
> > in the meantime, and it's not likely 6.13 material anyways, I think I'm
> > going to put it in a holding pattern and keep it in the back pocket in
> > favor of trying to move that alternate approach along, at least to where
> > I can post an RFC for discussion.
> >
> > If that doesn't work out or there proves some critical need for it in
> > the meantime, then I'll post v4 for an easy fix. I'll post a v2 of patch
> > 4 separately since that is an independent fix..
>
> I thought the bug robots were complaining about the performance hit,
> so at least this part should go in sooner than later.
>
Technically, yeah.. I've just been waffling over it because I'd rather
try to make more progress on that over trying too hard to polish up this
one. Christoph was grumbling a bit on factoring related to unrolling
these loops in the future or some such thing, so I'm not really sure
where he is on that.
Ok, maybe I'll do this.. I've already fixed the outstanding nits for v4,
so I might as well just post it. If there's anything critical that needs
fixing on review then obviously I'll address it, but otherwise I'll
prioritize working toward an RFC for the batching thing over pure
factoring/aesthetic changes, because that likely means much of this code
just goes away anyways.
Brian
> --D
>
> > Brian
> >
> > > > > + while ((ret = iomap_iter(&iter, ops)) > 0) {
> > > > > + const struct iomap *s = iomap_iter_srcmap(&iter);
> > > > > +
> > > > > + if (s->type == IOMAP_HOLE || s->type == IOMAP_UNWRITTEN) {
> > > > > + loff_t p = iomap_length(&iter);
> > > >
> > > > Also please stick to variable names that are readable and preferably
> > > > the same as in the surrounding code, e.g. s -> srcmap p -> pos.
> > > >
> > >
> > > Sure. I think I did this to avoid long lines, but I can change it.
> > > Thanks.
> > >
> > > Brian
> > >
> > >
> >
> >
>
next prev parent reply other threads:[~2024-11-15 19:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-08 12:42 [PATCH v3 0/4] iomap: zero range flush fixes Brian Foster
2024-11-08 12:42 ` [PATCH v3 1/4] iomap: reset per-iter state on non-error iter advances Brian Foster
2024-11-09 3:00 ` Darrick J. Wong
2024-11-11 5:53 ` Christoph Hellwig
2024-11-12 13:59 ` Brian Foster
2024-11-08 12:42 ` [PATCH v3 2/4] iomap: lift zeroed mapping handling into iomap_zero_range() Brian Foster
2024-11-09 3:01 ` Darrick J. Wong
2024-11-12 13:59 ` Brian Foster
2024-11-11 6:03 ` Christoph Hellwig
2024-11-12 14:00 ` Brian Foster
2024-11-15 14:53 ` Brian Foster
2024-11-15 17:02 ` Darrick J. Wong
2024-11-15 19:31 ` Brian Foster [this message]
2024-11-08 12:42 ` [PATCH v3 3/4] iomap: elide flush from partial eof zero range Brian Foster
2024-11-09 3:03 ` Darrick J. Wong
2024-11-11 6:06 ` Christoph Hellwig
2024-11-08 12:42 ` [PATCH v3 4/4] iomap: warn on zero range of a post-eof folio Brian Foster
2024-11-09 3:06 ` Darrick J. Wong
2024-11-12 14:01 ` Brian Foster
2024-11-11 6:06 ` Christoph Hellwig
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=ZzehlDTBiBiVkzfC@bfoster \
--to=bfoster@redhat.com \
--cc=djwong@kernel.org \
--cc=hch@infradead.org \
--cc=linux-fsdevel@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