Re: [PATCH v20 03/32] splice: Make direct_read_splice() limit to eof where appropriate
From: Linus Torvalds
Date: Fri May 19 2023 - 12:38:32 EST
On Fri, May 19, 2023 at 12:41 AM David Howells <dhowells@xxxxxxxxxx> 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.
The zero size checking looks fine, although I wondered about that too.
Some special files do traditionally have special meanings for
zero-sized reads (as in "packet boundary"). But I suspect that isn't
an issue for splice, and perhaps more importantly, I think the same
rule should be in place: special files that want special rules
shouldn't be using this generic function directly then.
Linus