Re: [PATCH v3 5/5] shmem, overlayfs, coda, tty, proc, kernfs, random: Fix splice-read

From: Miklos Szeredi
Date: Tue Feb 14 2023 - 08:06:13 EST


On Tue, 14 Feb 2023 at 09:38, David Howells <dhowells@xxxxxxxxxx> wrote:
>
> The new filemap_splice_read() has an implicit expectation via
> filemap_get_pages() that ->read_folio() exists if ->readahead() doesn't
> fully populate the pagecache of the file it is reading from[1], potentially
> leading to a jump to NULL if this doesn't exist.
>
> A filesystem or driver shouldn't suffer from this if:
>
> - It doesn't set ->splice_read()
> - It implements ->read_folio()
> - It implements its own ->splice_read()
>
> Note that some filesystems set generic_file_splice_read() and
> generic_file_read_iter() but don't set ->read_folio(). g_f_read_iter()
> will fall back to filemap_read_iter() which looks like it should suffer
> from the same issue.
>
> Certain drivers, can just use direct_splice_read() rather than
> generic_file_splice_read() as that creates an output buffer and then just
> calls their ->read_iter() function:
>
> - random & urandom
> - tty
> - kernfs
> - proc
> - proc_namespace
>
> Stacked filesystems just need to pass the operation down a layer:
>
> - coda
> - overlayfs
>
> And finally, there's shmem (used in tmpfs, ramfs, rootfs). This needs its
> own splice-read implementation, based on filemap_splice_read(), but able to
> paste in zero_page when there's a page missing.
>
> Fixes: d9722a475711 ("splice: Do splice read from a buffered file without using ITER_PIPE")

The fixed commit is not upstream. In fact it seems to be on the same
branch as this one. Please reorder the patches so that a Fixes tag is
not needed.

Thanks,
Miklos