linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Dave Chinner <david@fromorbit.com>
Cc: Jan Kara <jack@suse.cz>,
	linux-fsdevel@vger.kernel.org,
	Christoph Hellwig <hch@infradead.org>,
	darrick.wong@oracle.com, linux-xfs@vger.kernel.org,
	Matthew Bobrowski <mbobrowski@mbobrowski.org>
Subject: Re: [PATCH 0/2] iomap: Waiting for IO in iomap_dio_rw()
Date: Thu, 10 Oct 2019 11:18:31 +0200	[thread overview]
Message-ID: <20191010091831.GA25364@quack2.suse.cz> (raw)
In-Reply-To: <20191009230227.GH16973@dread.disaster.area>

On Thu 10-10-19 10:02:27, Dave Chinner wrote:
> On Wed, Oct 09, 2019 at 10:41:24PM +0200, Jan Kara wrote:
> > Hello,
> > 
> > when doing the ext4 conversion of direct IO code to iomap, we found it very
> > difficult to handle inode extension with what iomap code currently provides.
> > Ext4 wants to do inode extension as sync IO (so that the whole duration of
> > IO is protected by inode->i_rwsem), also we need to truncate blocks beyond
> > end of file in case of error or short write. Now in ->end_io handler we don't
> > have the information how long originally the write was (to judge whether we
> > may have allocated more blocks than we actually used) and in ->write_iter
> > we don't know whether / how much of the IO actually succeeded in case of AIO.
> > 
> > Thinking about it for some time I think iomap code makes it unnecessarily
> > complex for the filesystem in case it decides it doesn't want to perform AIO
> > and wants to fall back to good old synchronous IO. In such case it is much
> > easier for the filesystem if it just gets normal error return from
> > iomap_dio_rw() and not just -EIOCBQUEUED.
> 
> Yeah, that'd be nice. :)
> 
> > The first patch in the series adds argument to iomap_dio_rw() to wait for IO
> > completion (internally iomap_dio_rw() already supports this!) and the second
> > patch converts XFS waiting for unaligned DIO write to this new API.
> > 
> > What do people think?
> 
> I've just caught up on the ext4 iomap dio thread where this came up,
> so I have some idea of what is going on now :)
> 
> My main issue is that I don't like the idea of a "force_wait"
> parameter to iomap_dio_rw() that overrides what the kiocb says to
> do inside iomap_dio_rw(). It just seems ... clunky.
> 
> I'd much prefer that the entire sync/async IO decision is done in
> one spot, and the result of that is passed into iomap_dio_rw(). i.e.
> the caller always determines the behaviour.
> 
> That would mean the callers need to do something like this by
> default:
> 
> 	ret = iomap_dio_rw(iocb, iter, ops, dops, is_sync_kiocb(iocb));
> 
> And filesystems like XFS will need to do:
> 
> 	ret = iomap_dio_rw(iocb, iter, ops, dops,
> 			is_sync_kiocb(iocb) || unaligned);

Yeah, I've considered that as well. I just didn't like repeating
is_sync_kiocb(iocb) in all the callers when all the callers actually have
to have something like (is_sync_kiocb(iocb) || (some special conditions))
to be correct. And in fact it is not a definitive decision either as
iomap_dio_rw() can decide to override caller's wish and do the IO
synchronously anyway (when it gets -ENOTBLK from the filesystem). That's why
I came up with 'force_wait' argument, which isn't exactly beautiful either, I
agree.

> and ext4 will calculate the parameter in whatever way it needs to.
> 
> In fact, it may be that a wrapper function is better for existing
> callers:
> 
> static inline ssize_t iomap_dio_rw()
> {
> 	return iomap_dio_rw_wait(iocb, iter, ops, dops, is_sync_kiocb(iocb));
> }
> 
> And XFS/ext4 writes call iomap_dio_rw_wait() directly. That way we
> don't need to change the read code at all...

Yeah, this is similar to what I had in my previous version [1]. There I had
__iomap_dio_rw() with bool argument, iomap_dio_rw() passing is_sync_kiocb(iocb)
to __iomap_dio_rw() (i.e., fully backward compatible), and iomap_dio_rw_wait()
which executed IO synchronously. But Christoph didn't like the wrappers.

I can go with just one wrapper like you suggest if that's what people
prefer. I don't care much we just have to settle on something...

								Honza

[1] https://lore.kernel.org/linux-ext4/20191008151238.GK5078@quack2.suse.cz/
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      parent reply	other threads:[~2019-10-10  9:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-09 20:41 [PATCH 0/2] iomap: Waiting for IO in iomap_dio_rw() Jan Kara
2019-10-09 20:41 ` [PATCH 1/2] iomap: Allow forcing of waiting for running DIO " Jan Kara
2019-10-09 20:41 ` [PATCH 2/2] xfs: Use iomap_dio_rw_wait() Jan Kara
2019-10-09 23:02 ` [PATCH 0/2] iomap: Waiting for IO in iomap_dio_rw() Dave Chinner
2019-10-10  7:54   ` Christoph Hellwig
2019-10-10 14:47     ` Darrick J. Wong
2019-10-10 15:09       ` Jan Kara
2019-10-10  9:18   ` Jan Kara [this message]

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=20191010091831.GA25364@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mbobrowski@mbobrowski.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).