linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Dave Chinner <david@fromorbit.com>
Cc: Christoph Hellwig <hch@lst.de>,
	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: Mon, 7 Nov 2016 16:08:07 +0100	[thread overview]
Message-ID: <20161107150807.GA10865@lst.de> (raw)
In-Reply-To: <20161106224049.GP14023@dastard>

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.

> > +	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.

> 
> > +	if (may_zero) {
> > +		pad = pos & (fs_block_size - 1);
> > +		if (pad)
> > +			iomap_dio_zero(dio, iomap, pos, fs_block_size - pad);
> > +	}
> 
> Repeated zeroing code. helper function?

The actual repeated code is in iomap_dio_zero.  Because we once zero
the beginning of a block and once the end the arithmetics looks somewhat
similar but actually are different. We could do a trick like the end
parameter to dio_zero_block in the old dio code to save a line of code
or two, but I think it's highly confusing to the reader.

> > +	do {
> > +		ret = iomap_apply(inode, pos, count, flags, ops, dio,
> > +				iomap_dio_actor);
> > +		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")

> Comment decribing use?

Sure.

> Comment on the context the new flags are used under and what they
> mean?

Ok.

  reply	other threads:[~2016-11-07 15:08 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 [this message]
2016-11-08  1:38       ` Dave Chinner
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=20161107150807.GA10865@lst.de \
    --to=hch@lst.de \
    --cc=axboe@fb.com \
    --cc=david@fromorbit.com \
    --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).