From: Dave Chinner <david@fromorbit.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: Christoph Hellwig <hch@infradead.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH 5/7] iomap: write iomap validity checks
Date: Thu, 3 Nov 2022 11:35:15 +1100 [thread overview]
Message-ID: <20221103003515.GD3600936@dread.disaster.area> (raw)
In-Reply-To: <Y2KhurifaYbxkyNX@magnolia>
On Wed, Nov 02, 2022 at 09:58:34AM -0700, Darrick J. Wong wrote:
> On Wed, Nov 02, 2022 at 09:43:53AM -0700, Darrick J. Wong wrote:
> > On Wed, Nov 02, 2022 at 01:36:41AM -0700, Christoph Hellwig wrote:
> > > On Tue, Nov 01, 2022 at 11:34:10AM +1100, Dave Chinner wrote:
> > > > + /*
> > > > + * Now we have a locked folio, before we do anything with it we need to
> > > > + * check that the iomap we have cached is not stale. The inode extent
> > > > + * mapping can change due to concurrent IO in flight (e.g.
> > > > + * IOMAP_UNWRITTEN state can change and memory reclaim could have
> > > > + * reclaimed a previously partially written page at this index after IO
> > > > + * completion before this write reaches this file offset) and hence we
> > > > + * could do the wrong thing here (zero a page range incorrectly or fail
> > > > + * to zero) and corrupt data.
> > > > + */
> > > > + if (ops->iomap_valid) {
> > > > + bool iomap_valid = ops->iomap_valid(iter->inode, &iter->iomap);
> > > > +
> > > > + if (!iomap_valid) {
> > > > + iter->iomap.flags |= IOMAP_F_STALE;
> > > > + status = 0;
> > > > + goto out_unlock;
> > > > + }
> > > > + }
> > >
> > > So the design so far has been that everything that applies at a page (or
> > > now folio) level goes into iomap_page_ops, not iomap_ops which is just
> > > the generic iteration, and I think we should probably do it that way.
> >
> > I disagree here -- IMHO the sequence number is an attribute of the
> > iomapping, not the folio.
>
> OFC now that I've reread iomap.h I realize that iomap_page_ops are
> passed back via struct iomap, so I withdraw this comment.
My first thought was to make this a page op, but I ended up deciding
against that because it isn't operating on the folio at all.
Perhaps I misunderstood what "page_ops" was actually intended for,
because it seems that the existing hooks are to allow the filesystem
to wrap per-folio operations with an external context, not to
perform iomap-specific per-folio operations.
I guess if I read "pageops" as "operations to perform on each folio
in an operation", then validating the iomap is not stale once the
folio is locked could be considered a page op. I think we could
probably make that work for writeback, too, because we have the
folio locked when we call ->map_blocks....
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2022-11-03 0:35 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-01 0:34 xfs, iomap: fix data corrupton due to stale cached iomaps Dave Chinner
2022-11-01 0:34 ` [PATCH 1/7] xfs: write page faults in iomap are not buffered writes Dave Chinner
2022-11-02 7:17 ` Christoph Hellwig
2022-11-02 16:12 ` Darrick J. Wong
2022-11-02 21:11 ` Dave Chinner
2022-11-01 0:34 ` [PATCH 2/7] xfs: punching delalloc extents on write failure is racy Dave Chinner
2022-11-02 7:18 ` Christoph Hellwig
2022-11-02 16:22 ` Darrick J. Wong
2022-11-01 0:34 ` [PATCH 3/7] xfs: use byte ranges for write cleanup ranges Dave Chinner
2022-11-02 7:20 ` Christoph Hellwig
2022-11-02 16:32 ` Darrick J. Wong
2022-11-04 5:40 ` Dave Chinner
2022-11-07 23:53 ` Darrick J. Wong
2022-11-01 0:34 ` [PATCH 4/7] xfs: buffered write failure should not truncate the page cache Dave Chinner
2022-11-01 11:57 ` kernel test robot
2022-11-02 7:24 ` Christoph Hellwig
2022-11-02 20:57 ` Dave Chinner
2022-11-02 16:41 ` Darrick J. Wong
2022-11-02 21:04 ` Dave Chinner
2022-11-02 22:26 ` Darrick J. Wong
2022-11-04 8:08 ` Christoph Hellwig
2022-11-04 23:10 ` Dave Chinner
2022-11-07 23:48 ` Darrick J. Wong
2022-11-01 0:34 ` [PATCH 5/7] iomap: write iomap validity checks Dave Chinner
2022-11-02 8:36 ` Christoph Hellwig
2022-11-02 16:43 ` Darrick J. Wong
2022-11-02 16:58 ` Darrick J. Wong
2022-11-03 0:35 ` Dave Chinner [this message]
2022-11-04 8:12 ` Christoph Hellwig
2022-11-02 16:57 ` Darrick J. Wong
2022-11-01 0:34 ` [PATCH 6/7] xfs: use iomap_valid method to detect stale cached iomaps Dave Chinner
2022-11-01 9:15 ` kernel test robot
2022-11-02 8:41 ` Christoph Hellwig
2022-11-02 21:39 ` Dave Chinner
2022-11-04 8:14 ` Christoph Hellwig
2022-11-02 17:19 ` Darrick J. Wong
2022-11-02 22:36 ` Dave Chinner
2022-11-08 0:00 ` Darrick J. Wong
2022-11-01 0:34 ` [PATCH 7/7] xfs: drop write error injection is unfixable, remove it Dave Chinner
2022-11-01 3:39 ` xfs, iomap: fix data corrupton due to stale cached iomaps Darrick J. Wong
2022-11-01 4:21 ` Dave Chinner
2022-11-02 17:23 ` Darrick J. Wong
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=20221103003515.GD3600936@dread.disaster.area \
--to=david@fromorbit.com \
--cc=djwong@kernel.org \
--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