Commit 60392573 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

direct-io: add flag to allow aio writes beyond i_size

Some filesystems can handle direct I/O writes beyond i_size safely,
so allow them to opt into receiving them.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 38dbfb59
...@@ -1194,13 +1194,19 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, ...@@ -1194,13 +1194,19 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
} }
/* /*
* For file extending writes updating i_size before data * For file extending writes updating i_size before data writeouts
* writeouts complete can expose uninitialized blocks. So * complete can expose uninitialized blocks in dumb filesystems.
* even for AIO, we need to wait for i/o to complete before * In that case we need to wait for I/O completion even if asked
* returning in this case. * for an asynchronous write.
*/ */
dio->is_async = !is_sync_kiocb(iocb) && !((rw & WRITE) && if (is_sync_kiocb(iocb))
(end > i_size_read(inode))); dio->is_async = false;
else if (!(dio->flags & DIO_ASYNC_EXTEND) &&
(rw & WRITE) && end > i_size_read(inode))
dio->is_async = false;
else
dio->is_async = true;
dio->inode = inode; dio->inode = inode;
dio->rw = rw; dio->rw = rw;
......
...@@ -2527,6 +2527,9 @@ enum { ...@@ -2527,6 +2527,9 @@ enum {
/* filesystem does not support filling holes */ /* filesystem does not support filling holes */
DIO_SKIP_HOLES = 0x02, DIO_SKIP_HOLES = 0x02,
/* filesystem can handle aio writes beyond i_size */
DIO_ASYNC_EXTEND = 0x04,
}; };
void dio_end_io(struct bio *bio, int error); void dio_end_io(struct bio *bio, int error);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment