Re: [PATCH v20 03/32] splice: Make direct_read_splice() limit to eof where appropriate

From: Christoph Hellwig
Date: Fri May 19 2023 - 04:09:35 EST


On Fri, May 19, 2023 at 08:40:18AM +0100, David Howells wrote:
> Make direct_read_splice() limit the read to the end of the file for regular
> files and block devices, thereby reducing the amount of allocation it will
> do in such a case.
>
> This means that the blockdev code doesn't require any special handling as
> filemap_read_splice() also limits to i_size.

I'm really not sure if this is a good idea. Right now
direct_read_splice (which also appears a little misnamed) really is
a splice by calling ->read_iter helper. I we don't do any
of this validtion we can just call it directly from splice.c instead
of calling into ->splice_read for direct I/O and DAX and remove a ton
of boilerplate code.

How often do we even call into splice beyond i_size and for how much?

> + if (S_ISREG(file_inode(in)->i_mode) ||
> + S_ISBLK(file_inode(in)->i_mode)) {

Btw, having these kinds of checks in supposedly generic code is always
a marked for a bit of a layering problem.