Re: [PATCH] f2fs: Fix direct IO handling

From: Christoph Hellwig
Date: Tue Nov 26 2019 - 11:33:19 EST


On Tue, Nov 26, 2019 at 04:57:19PM +0900, Damien Le Moal wrote:
> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
> index 5755e897a5f0..8ac2d3b70022 100644
> --- a/fs/f2fs/data.c
> +++ b/fs/f2fs/data.c
> @@ -1073,6 +1073,8 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
> int flag;
> int err = 0;
> bool direct_io = iocb->ki_flags & IOCB_DIRECT;
> + bool do_direct_io = direct_io &&
> + !f2fs_force_buffered_io(inode, iocb, from);

I don't think this is the right fix. The proper fix is to clear
IOCB_DIRECT when falling back to buffered I/O, preferably in the
filemap.c helpers as well.