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

From: David Howells
Date: Fri May 19 2023 - 12:49:32 EST


Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:

> > + if (S_ISREG(file_inode(in)->i_mode) ||
> > + S_ISBLK(file_inode(in)->i_mode)) {
>
> This really feels fundamentally wrong to me.
>
> If block and regular files have this limit, they should have their own
> splice_read() function that implements that limit.
>
> Not make everybody else check it.
>
> IOW, this should be a separate function ("block_splice_read()" or
> whatever), not inside a generic function that other users use.

This is just an optimisation to cut down the amount of bufferage allocated, so
I could just drop it and leave it to userspace for now as the filesystem/block
layer will stop anyway if it hits the EOF. Christoph would prefer that I call
direct_splice_read() from generic_file_splice_read() in all O_DIRECT cases, if
that's fine with you.

David