From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org, axboe@fb.com,
kent.overstreet@gmail.com, linux-fsdevel@vger.kernel.org,
linux-block@vger.kernel.org
Subject: Re: [PATCH 4/5] iomap: implement direct I/O
Date: Tue, 8 Nov 2016 12:38:05 +1100 [thread overview]
Message-ID: <20161108013805.GA28922@dastard> (raw)
In-Reply-To: <20161107150807.GA10865@lst.de>
On Mon, Nov 07, 2016 at 04:08:07PM +0100, Christoph Hellwig wrote:
> On Mon, Nov 07, 2016 at 09:40:49AM +1100, Dave Chinner wrote:
> > > + case IOMAP_HOLE:
> > > + /*
> > > + * We return -ENOTBLK to fall back to buffered I/O for file
> > > + * systems that can't fill holes from direct writes.
> > > + */
> > > + if (dio->flags & IOMAP_DIO_WRITE)
> > > + return -ENOTBLK;
> > > + /*FALLTHRU*/
> >
> > This is preventing direct IO writes from being done into holes for
> > all filesystems.
>
> It's not. Hint: the whole iomap code very much assumes a file system
> fills holes before applying the actor on writes.
>
> That being said I should remove this check - as-is it's dead, untested
> code that I only used for my aborted ext2 conversion, so we're better
> off not having it.
Yup, agreed.
> > > + iov_iter_truncate(&iter, length);
> >
> > Won't this truncate the entire DIO down to the length of the first
> > extent that is mapped?
>
> It truncates a copy of the main iter down to the length of the extent
> we're working on. That allows us to limit all the iov_iter based helper
> (most importantly get_user_pages) to only operate on a given extent.
> Later in the function we then advance the primary iter when moving to
> the next extent.
Hmmm, I must be missing something here. iomap_dio_rw() stores a
pointer to the primary iter in the dio structure, and that gets
passed to the actor function, and then it....
Oh, bloody hell, Christoph! :/ You hid a structure copy in the
variable initialisations and used the same variable name for the
copy as the primary pointer:
struct iov_iter iter = *dio->submit.iter;
That's really subtle and easy for idiots like me to miss when
reading the code. Please make it clear that we're working on
a copy of the primary iter here, not the primary iter itself.
> > > + if (ret <= 0) {
> > > + /* magic error code to fall back to buffered I/O */
> > > + if (ret == -ENOTBLK)
> > > + ret = 0;
> > > + break;
> > > + }
> > > + pos += ret;
> > > + } while ((count = iov_iter_count(iter)) > 0);
> > > + blk_finish_plug(&plug);
> > > +
> > > + if (ret < 0)
> > > + cmpxchg(&dio->error, 0, ret);
> >
> > Why cmpxchg? What are we racing with here? Helper (e.g.
> > dio_set_error())?
>
> The submission thread against I/O completions (which in the worst
> case could come from multiple threads as well). Same reason as
> the one in xfs_buf_bio_end_io added in commit 9bdd9bd69b
> ("xfs: buffer ->bi_end_io function requires irq-safe lock")
Yup, that's what I suspected - a comment is needed at least, though,
IMO, a helper w/ comment is the most maintainable approach here.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2016-11-08 1:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-04 16:21 an iomap-based direct I/O implementation V2 Christoph Hellwig
2016-11-04 16:21 ` [PATCH 1/5] locking/lockdep: Provide a type check for lock_is_held Christoph Hellwig
2016-11-04 16:21 ` [PATCH 2/5] xfs: remove i_iolock and use i_rwsem in the VFS inode instead Christoph Hellwig
2016-11-04 16:21 ` [PATCH 3/5] fs: make sb_init_dio_done_wq available outside of direct-io.c Christoph Hellwig
2016-11-04 16:21 ` [PATCH 4/5] iomap: implement direct I/O Christoph Hellwig
2016-11-04 20:56 ` Jens Axboe
2016-11-05 15:10 ` Kent Overstreet
2016-11-05 18:14 ` Avi Kivity
2016-11-06 16:36 ` Christoph Hellwig
2016-11-06 22:40 ` Dave Chinner
2016-11-07 15:08 ` Christoph Hellwig
2016-11-08 1:38 ` Dave Chinner [this message]
2016-11-04 16:21 ` [PATCH 5/5] xfs: use iomap_dio_rw Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2016-11-13 19:07 an iomap-based direct I/O implementation V3 Christoph Hellwig
2016-11-13 19:07 ` [PATCH 4/5] iomap: implement direct I/O Christoph Hellwig
2016-11-29 17:28 an iomap-based direct I/O implementation V4 Christoph Hellwig
2016-11-29 17:28 ` [PATCH 4/5] iomap: implement direct I/O 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=20161108013805.GA28922@dastard \
--to=david@fromorbit.com \
--cc=axboe@fb.com \
--cc=hch@lst.de \
--cc=kent.overstreet@gmail.com \
--cc=linux-block@vger.kernel.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).