shmem: Implement splice-read
authorDavid Howells <dhowells@redhat.com>
Tue, 14 Feb 2023 15:15:56 +0000 (15:15 +0000)
committerDavid Howells <dhowells@redhat.com>
Tue, 14 Feb 2023 16:47:10 +0000 (16:47 +0000)
commitcc606dc4fb8db137ec765d586b8bf76ba5740bbf
tree3bab445f722fcac9d4e87ecd2e9a6e1b49a9c4fa
parentf2aa2c5707ac2dfa74b6e9e9a0115ff0b32a9cd5
shmem: Implement splice-read

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.  shmem, however, (and by
extension, tmpfs, ramfs and rootfs), doesn't have ->read_folio(),

Work around this by equipping shmem with its own splice-read
implementation, based on filemap_splice_read(), but able to paste in
zero_page when there's a page missing.

Signed-off-by: David Howells <dhowells@redhat.com>
cc: Daniel Golle <daniel@makrotopia.org>
cc: Guenter Roeck <groeck7@gmail.com>
cc: Christoph Hellwig <hch@lst.de>
cc: Jens Axboe <axboe@kernel.dk>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: John Hubbard <jhubbard@nvidia.com>
cc: David Hildenbrand <david@redhat.com>
cc: Matthew Wilcox <willy@infradead.org>
cc: Hugh Dickins <hughd@google.com>
cc: linux-block@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
Link: https://lore.kernel.org/r/Y+pdHFFTk1TTEBsO@makrotopia.org/
mm/shmem.c