mbox series

[0/2,v3] iomap: Waiting for IO in iomap_dio_rw()

Message ID 20191014082418.13885-1-jack@suse.cz (mailing list archive)
Headers show
Series iomap: Waiting for IO in iomap_dio_rw() | expand

Message

Jan Kara Oct. 14, 2019, 8:26 a.m. UTC
Hello,

here is new version of the series with the small change requested by Darrick.

Changes since v2:
* Changed iomap_dio_rw() to return -EIO in case caller doesn't ask it to wait
  for sync kiocb.

Changes since v1:
* The new function argument of iomap_dio_rw() does not get overridden by
 is_sync_kiocb() the caller is responsible for this.

---
Original motivation:

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.

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.

								Honza 

Previous versions:
Link: http://lore.kernel.org/r/20191009202736.19227-1-jack@suse.cz
Link: http://lore.kernel.org/r/20191011125520.11697-1-jack@suse.cz

Comments

Matthew Bobrowski Oct. 14, 2019, 8:52 a.m. UTC | #1
On Mon, Oct 14, 2019 at 10:26:01AM +0200, Jan Kara wrote:
> Original motivation:
> 
> 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.
> 
> 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.

Ah, wonderful, I was waiting for this to come through.

I'll rebase my EXT4 direct I/O port on top of these patches and apply
the discussed changes. Any objections? :)

--<M>--
Jan Kara Oct. 14, 2019, 9:32 a.m. UTC | #2
On Mon 14-10-19 19:52:18, Matthew Bobrowski wrote:
> On Mon, Oct 14, 2019 at 10:26:01AM +0200, Jan Kara wrote:
> > Original motivation:
> > 
> > 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.
> > 
> > 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.
> 
> Ah, wonderful, I was waiting for this to come through.
> 
> I'll rebase my EXT4 direct I/O port on top of these patches and apply
> the discussed changes. Any objections? :)

No, go ahead. Thanks!

								Honza